Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
BEP 12: Multitracker Metadata Extension
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2022-11-06 00:56:47
https://www.bittorrent.org/beps/bep_0012.html

Open download.php and find


$dict['announce'] = sprintf($site_config["PASSKEYURL"], $CURUSER["passkey"]);
unset($dict['announce-list']);


Replace with:


$dict = bep12_MultiTrackerExtension($dict, $CURUSER['passkey']);


Open backend/functions.php and add


function bep12_MultiTrackerExtension(array $dict, string $passkey, string $url = '', string $url2 = '', string $url3 = '')
{
   global $site_config;
   if (strlen($url) > 0) {
       $dict['announce-list'] = array(
           1 => array(
               sprintf($site_config['PASSKEYURL'], $passkey)
           ),
           2 => array(
               $url,
               $url2,
               $url3
           )
       );
       shuffle(array_merge($dict, $dict['announce-list']));
       unset($dict['announce']);
   } else if (strlen($url) === 0) {
       unset($dict['announce-list']);
       $dict['announce'] = sprintf($site_config['PASSKEYURL'], $passkey);
   }
   return $dict;
}


Example usage:


bep12_MultiTrackerExtension($dict, $CURUSER['passkey'], 'url1' 'url2', 'url3');


Use the default replacement to use only primary announce url.
Last edited by STorrents2020 on 2022-11-06 01:03:24
2022-11-06 10:39:49
cool, will give it a go. What made you decide to edit this out of curiosity?
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2022-11-06 18:17:59
V3 is the entire reason I am online (and 2.08 before that). I feel I walked off the plank a bit, while I told myself I would never forget my roots and would try to maintain it best I could.

Keep in mind, my index as it stands.. as originally (mostly visually the same) was on V3 long ago, we used to use torrenttrable() for our template! Times have certainly changed lol.

My next mods will require a PEM encoded (X509 certificate) and private key with a valid passphrase. This is the same means of encryption we use in announce & torrent signing.

Its time V3  gets a push forward.

2022-12-11 18:32:49
Hello, I just tested and when we make the modification on download.php and we want to download a torrent we have this error message,...

invalid torrent file
2022-12-11 18:45:39
scrape.php is seperatefrom download.php and should not effect the other one.

This file just acts as a peer report on the info hash. Its completely independent from any other files or functions.
2022-12-13 16:03:25
Hello what I want to explain is that when we made the modification on the file download.php there is an error message to download the torrent

invalid torrent file  😲
2022-12-13 16:59:50
Oh I see, sorry I got 2 posts confused with each other (it keeps autoscrolling down)

Thats really weird, is your PASSKEY url config setting correct and enabled?

Even if its removing the announce field, it should not effect any of the encoding or other fields. It sounds like there are modifications to download.php already that may be effecting this mod.
Last edited by STorrents2020 on 2022-12-13 17:00:45
2022-12-13 19:40:36
thank you I will look again  👍
2022-12-13 19:55:47
interesting work 👍 going to test some uploads on qbittorrent side how's this implemented
maybe the bencode class if yours is different
just reading through bep now is function to add multiple internal backup announces ?

Quote:
On each announce, first try tracker1, then if that cannot be reached, try backup1 and backup2 respectively.

On download you would still point to 1 announce.php ? so for internal would you add  3  trackers on client if so that would possible be announce-list instead of announce

Quote:
If the client is compatible with the multitracker specification, and if the "announce-list" key is present, the client will ignore the "announce" key and only use the URLs in "announce-list".

first thought was edit file somewhere else importing announce array on upload or details etc serialized into database do you want to scrape multi internal trackers because we then can simply edit file and pass to scraper

this is opened up some ideas just hoping the clients can do the leg work here

result on qbit adding multiple trackers on qbit when creating torrent
announce-
Quote:

edit
was going to call myself stupid why would you scrape your own site multiple times but then the a little voice in back of my head spoke
who said there all had to be internal ??? lol
on TT you most use announce (site_config) to upload internal but in the trackers on client side if you had 3 sites you could add all 3 on create torrent and scrape all 3
this is on upload from parse function
$TorrentInfo[6] = $array["announce-list"];

from this way the only issue would be this on torrents-upload.php
eg $site_config['announce_list'] = "$site_config[SITEURL]/announce.php, 'other', 'other1'";
	if (!in_array($announce, $announce_urls, 1)){
$external='yes';
   }else{
$external='no';
}

internal or external depends on implmentation and what backup announces
Last edited by M-jay warn on 2022-12-13 20:36:28
2022-12-13 21:47:53
Hello guys, I want to ask if it is possible to do something like this.
When you enter the torrent details will automatically update the external peers, if the torrent is external of course
2022-12-14 04:35:21
Quote:
update the external peers

do you scrape on upload ? this is rough guide for best way to scrape multi - see if you have luck with this but debugging can be pain because of server settings

for multi announce you can use this https://github.com/medariox/scrapeer
place in backend
then on torrents-upload.php
require "backend/scraper.php";

find
	if ($external=='no')
$message = sprintf( T_("TORRENT_UPLOAD_LOCAL"), $name, $id, $id );
else
$message = sprintf( T_("TORRENT_UPLOAD_EXTERNAL"), $name, $id );
show_error_msg(T_("UPLOAD_COMPLETE"), $message, 1);


replace with - this assumes internal as external but for test use external
	if ($external=='no')
$message = sprintf( T_("TORRENT_UPLOAD_LOCAL"), $name, $id, $id );
else
$message = sprintf( T_("TORRENT_UPLOAD_EXTERNAL"), $name, $id );
show_error_msg(T_("UPLOAD_COMPLETE"), $message, 1);
ScrapeId($id, $annlist, $infohash);


backend functions.php add
function ScrapeId($id, $annlist, $infohash)
   {
       $scraper = new Scraper();
       $scraped = $scraper->scrape($infohash, $annlist, 20, 4, true );

       $myarray = array_shift($scraped);

       $seeders = $leechers = $completed = 0;
       if ($myarray['seeders'] > 0) {
           $seeders = $myarray['seeders'];
       }
       if ($myarray['leechers'] > 0) {
           $leechers = $myarray['leechers'];
       }
       if ($myarray['completed'] > 0) {
           $completed = $myarray['completed'];
       }

       if ($seeders !== 0) {
          die('something happened so update db');
       } else {
           die('error or dead torrent');
       }
   }
Last edited by M-jay warn on 2022-12-14 05:06:14
2022-12-15 17:42:03
Once a torrent is uploaded, its automatically scraped by reading the peer table after upload. The torrent announces within a few minutes from that point, stats are live.

External torrents are scraped by cleanup, or simply read on torrent detail page. You hardly notice the difference, but I use a world icon to indicate its not locally tracked.

I'll check that out! I like that it provides an immediate solution to external instead of waiting around for the system to catch up.


$tracker = !empty($arr['announce']) ? array(
   $arr['announce']
) : null;
$scrape  = new Scrape;
$stats   = array();
foreach ($scrape->scrape($row['info_hash'], $tracker) as $value) {
   array_push($stats, $value);
}
if ($scrape->has_errors() && $row['external'] == 'yes') {
   printf('<span>error</span> %s', $scrape->get_errors()[0]);
}
if (!empty($stats)) {
   echo intval($stats[0]['seeders']);
   echo intval($stats[0]['leechers']);
} else {
   echo $row['seeders'];
   echo $row['leechers'];
}
Last edited by STorrents2020 on 2022-12-15 18:23:00
2022-12-18 00:45:57
Maybe I didn't express myself correctly or you didn't understand me.  :)

STorrents2020 I don't see where in your code the peers will be updated automatically when you entered the torrent details.
2022-12-18 02:32:25
I think I know what you mean. But wouldnt that be heavy on the system if every time you visit the details page it would scrape? If you have multiple users hitting the page at the same time or even close to each other, I think that would be a mess lol. Maybe running it during cleanup for external would make more sense
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2022-12-18 02:33:26
2022-12-18 02:50:42
Zero delay on any external torrents. The server is blazing fast in general.

Most of the time, the torrents are private anyway so its reading peer data on the fly.
Cleanup collects these stats from peers and updates torrent rows every hour, so in that
sense they are updated. I could decide to add a last_check DATETIME field and compare dates - 1 hour ago, and do the scrape at that point + a last_check UPDATE. But I dont feel like it, its never come up as a issue.

What is slow is the mail API via cURL (http/3) - f**** me that takes all day on a batch requests. Brutal lmao, maybe the mail API has a rate limit, who knows.

That code though, will check either case and produce stats.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728