mirror of
https://github.com/torrentpier/torrentpier
synced 2025-07-06 04:51:43 -07:00
feat(magnet): Added xl
(eXact Length) parametr (#1883)
This commit is contained in:
parent
04b0a477d3
commit
c0cdcff488
5 changed files with 16 additions and 11 deletions
4
composer.lock
generated
4
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a906f822bca0d03bee43a9efe8529350",
|
||||
"content-hash": "291864741a4c19d097861853d529836c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "arokettu/bencode",
|
||||
|
@ -3741,7 +3741,7 @@
|
|||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^8.1 | ^8.2 | ^8.3 | ^8.4"
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
|
|
|
@ -149,7 +149,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
// Magnet link
|
||||
$user_passkey = \TorrentPier\Legacy\Torrent::getPasskey($bt_user_id);
|
||||
$tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_ent_decode($t_data['topic_title']));
|
||||
$tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_ent_decode($t_data['topic_title']), $tor_size);
|
||||
|
||||
// ratio limits
|
||||
$min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor'];
|
||||
|
|
|
@ -1811,14 +1811,14 @@ function decode_text_match($txt)
|
|||
/**
|
||||
* Create magnet link
|
||||
*
|
||||
* @param string $infohash
|
||||
* @param string $infohash_v2
|
||||
* @param string $auth_key
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $infohash (xt=urn:btih)
|
||||
* @param string $infohash_v2 (xt=urn:btmh:1220)
|
||||
* @param string $auth_key (tr)
|
||||
* @param string $name (dn)
|
||||
* @param int|string $length (xl)
|
||||
* @return string
|
||||
*/
|
||||
function create_magnet(string $infohash, string $infohash_v2, string $auth_key, string $name): string
|
||||
function create_magnet(string $infohash, string $infohash_v2, string $auth_key, string $name, int|string $length = 0): string
|
||||
{
|
||||
global $bb_cfg, $images, $lang;
|
||||
|
||||
|
@ -1847,6 +1847,11 @@ function create_magnet(string $infohash, string $infohash_v2, string $auth_key,
|
|||
$magnet .= 'xt=urn:btmh:1220' . bin2hex($infohash_v2);
|
||||
}
|
||||
|
||||
$length = (int)$length;
|
||||
if ($length > 0) {
|
||||
$magnet .= '&xl=' . $length;
|
||||
}
|
||||
|
||||
return '<a title="' . ($v2_support ? $lang['MAGNET_v2'] : $lang['MAGNET']) . '" href="' . $magnet . '&tr=' . urlencode($bb_cfg['bt_announce_url'] . "?{$bb_cfg['passkey_key']}=$auth_key") . '&dn=' . urlencode($name) . '"><img src="' . ($v2_support ? $images['icon_magnet_v2'] : $images['icon_magnet']) . '" width="12" height="12" border="0" /></a>';
|
||||
}
|
||||
|
||||
|
|
|
@ -713,7 +713,7 @@ if ($allowed_forums) {
|
|||
$s_last = $tor['seeder_last_seen'];
|
||||
$att_id = $tor['attach_id'];
|
||||
$size = $tor['size'];
|
||||
$tor_magnet = create_magnet($tor['info_hash'], $tor['info_hash_v2'], \TorrentPier\Legacy\Torrent::getPasskey($user_id), html_ent_decode($tor['topic_title']));
|
||||
$tor_magnet = create_magnet($tor['info_hash'], $tor['info_hash_v2'], \TorrentPier\Legacy\Torrent::getPasskey($user_id), html_ent_decode($tor['topic_title']), $size);
|
||||
$compl = $tor['complete_count'];
|
||||
$dl_sp = $dl ? humn_size($dl, min: 'KB') . '/s' : '0 KB/s';
|
||||
$ul_sp = $ul ? humn_size($ul, min: 'KB') . '/s' : '0 KB/s';
|
||||
|
|
|
@ -468,7 +468,7 @@ foreach ($topic_rowset as $topic) {
|
|||
]);
|
||||
|
||||
if (isset($topic['tor_size'])) {
|
||||
$tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_ent_decode($topic['topic_title']));
|
||||
$tor_magnet = create_magnet($topic['info_hash'], $topic['info_hash_v2'], $topic['auth_key'], html_ent_decode($topic['topic_title']), $topic['tor_size']);
|
||||
|
||||
$template->assign_block_vars('t.tor', [
|
||||
'SEEDERS' => (int)$topic['seeders'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue