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
Scrape UDP Trackers - Mod for v2.08
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Mods Completed

Unknown User
2014-10-11 06:54:56
First, the torrents are scraped in torrents-details.php, is the first line in that the stats are updated with UDP trackers.
I tested this mod on a tracker with 12.000 of external torrents and after a while almost all these torrents have been updated by users.
You can also use mega_scrape.php but you need to set a cronjob to your server for this file. In this mode will work permanently.
If you run this file from your PC, you have to keep the browser open until this task is ready.

First of all extracts the attached arhive udpscraper.zip and upload all included files in your root.

In torrents-details.php under this line:

require_once("backend/BDecode.php");



Add these:

require_once("backend/parse.php");
require_once"backend/udptscraper.php";



And somewhere below, replace the entire "scrape" code:

if ($row["external"]=='yes'){
        if ($scrape =='1'){
            print("<td valign='top' align='right'><b>Tracked: </b>EXTERNAL<br /><br />");
            $seeders1 = $leechers1 = $downloaded1 = null;

            $tres = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
            while ($trow = mysql_fetch_assoc($tres)) {
                $ann = $trow["url"];
                $tracker = explode("/", $ann);
                $path = array_pop($tracker);
                $oldpath = $path;
                $path = preg_replace("/^announce/", "scrape", $path);
                $tracker = implode("/", $tracker)."/".$path;

                if ($oldpath == $path) {
                    continue; // Scrape not supported, ignored
                }

                // TPB's tracker is dead. Use openbittorrent instead
                if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker)) {
                    $tracker = "http://tracker.openbittorrent.com/scrape";
                }

                $stats = torrent_scrape_url($tracker, $row["info_hash"]);
                if ($stats['seeds'] != -1) {
                    $seeders1 += $stats['seeds'];
                    $leechers1 += $stats['peers'];
                    $downloaded1 += $stats['downloaded'];
                    SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");
                } else {
                    SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");

                }
            }

            if ($seeders1 !== null){ //only update stats if data is received
                print ("<b>".T_("LIVE_STATS").": </b><br />");
                print ("Seeders: ".number_format($seeders1)."<br />");
                print ("Leechers: ".number_format($leechers1)."<br />");
                print (T_("COMPLETED").": ".number_format($downloaded1)."<br />");

                SQL_Query_exec("UPDATE torrents SET leechers='".$leechers1."', seeders='".$seeders1."', times_completed='".$downloaded1."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
            }else{
                print ("<b>".T_("LIVE_STATS").": </b><br />");
                print ("<font color='#ff0000'>Tracker Timeout<br />Please retry later</font><br />");
            }

            print ("<form action='torrents-details.php?id=$id&amp;scrape=1' method='post'><input type="submit" name="submit" value="Update Stats" /></form></td>");
        }else{
            print ("<td valign='top' align='right'><b>Tracked:</b> EXTERNAL<br /><br /><form action='torrents-details.php?id=$id&amp;scrape=1' method='post'><input type="submit" name="submit" value="Update Stats" /></form></td>");
        }
    }


With this one:

//===| Scrape External Torrents
   if ($row["external"]=='yes')
   {
       print ("<td width='160' align='right' valign='top'><table><tr>");
       if ($scrape =='1')
       {
           print("<td class='table_col1' width='150' valign='middle'>
           <div style='margin-top:5px; margin-bottom:10px; font:bold 16px Times' align='center'><font color='#FF2000'>".T_("EXTERNAL_TORRENT")."</font></div>");

           //===| UDP Scraper
           $resu = SQL_Query_exec("SELECT id, info_hash FROM torrents WHERE external = 'yes' AND id = $id");
           while ($rowu = mysql_fetch_array($resu))
           {
               $TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$rowu[id].torrent");
               $ann = $TorrentInfo[0];
               $annlist = array();

               if ($TorrentInfo[6])
               {
                   foreach ($TorrentInfo[6] as $ann)
                   {
                       $annlist[] = $ann[0];
                   }
               }
               else
                   $annlist = array($ann);

               $seeders = $leechers = $downloaded = null;
               foreach ($annlist as $ann)
               {
                   $tracker = explode("/", $ann);
                   $path = array_pop($tracker);
                   $oldpath = $path;
                   $path = str_replace("announce", "scrape", $path);
                   $tracker = implode("/", $tracker)."/".$path;

                   if ($oldpath == $path)
                   {
                       continue;
                   }
                   if ($openbittorrent_done)
                       continue;

                   if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker))
                   {
                       $tracker = "http://tracker.openbittorrent.com/scrape";
                       $openbittorrent_done = 1;
                   }
                   if(preg_match('/udp:\/\//', $tracker))
                   {
                       $udp=true;
                       try
                       {
                           $timeout = 5;
                           $udp= new udptscraper($timeout);
                           $stats=$udp->scrape($tracker,$rowu["info_hash"]);
                           //print_r($stats); exit();
                           foreach ($stats as $idu=>$scrape)
                           {
                               $seeders += $scrape['seeders'];
                               $leechers += $scrape['leechers'];
                               $downloaded    += $scrape['completed'];
                           }
                       }
                       catch(ScraperException $e)
                       {
                           $e->isConnectionError();
                       }
                   }
                   else
                   {
                       $stats = torrent_scrape_url($tracker, $rowu["info_hash"]);
                   }

                   if ($stats['seeds'] != -1)
                   {
                       $seeders += $stats['seeds'];
                       $leechers += $stats['peers'];
                       $downloaded += $stats['downloaded'];

                       SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = '".$stats[seeds]."', `leechers` = '".$stats[peers]."', `times_completed` = '".$stats[downloaded]."' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
                   }
                   else
                   {
                       SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
                   }
               }

               if ($seeders !== null)
               {
                   SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$rowu['id']."'");
               }
               else
               {
                   SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id='".$rowu['id']."'");
               }
           }
           //===| End UDP Scraper
                   
           if ($seeders !== null)
           {
               print ("<div style='margin-bottom:5px; margin-left:20px'><b>".T_("LIVE_STATS")."</b>: </div>");
               print ("<div style='margin-left:20px'>".T_("SEEDERS").": <font color='limegreen'>".$seeders."</font></div>");
               print ("<div style='margin-left:20px'>".T_("LEECHERS").": <font color='#FF2000'>".$leechers."</font></div>");
               print ("<div style='margin-left:20px'>".T_("COMPLETED").": <font color='#0080FF'>".$downloaded."</font></div>");
           }
           else
           {
               print ("<div style='margin-top:10px; margin-bottom:5px' align='center'><b>".T_("LIVE_STATS")."</b>: </div>");
               print ("<div style='font:italic 14px Times' align='center'><font color='#FF2000'>".T_("TRACKERS_OFFLINE")."!</font></div>");
           }
           print ("<div style='margin-top:10px; margin-bottom:10px' align='center'>
               <a href='torrents-details.php?id=".$id."'><input type='submit' name='submit' value=".T_("SUBMIT")."></a>
           </div>");
           print ("</td>");
       }
       else
       {
           print ("<td class='table_col1' width='150' valign='middle' align='center'>
               <div style='margin-top:5px; margin-bottom:10px; font:bold 16px Times' align='center'><font color='#FF2000'>".T_("EXTERNAL_TORRENT")."</font></div>
               <div style='font:normal 12px Times' align='center'>".T_("UPDATE_STATS")."</div></div>
                   <form action='torrents-details.php?id=$id&amp;scrape=1' method='post'>
                       <div style='margin-top:5px; margin-bottom:10px' align='center'><input type='submit' name='submit' value=".T_("UPDATE")." /></div>
                   </form>
               </td>");
       }
       print ("</tr></table></td>");
   }
   //===| End Scrape External Torrents


[ATTACH]2449._xfImport[/ATTACH]

Add to languages/english.php:

$LANG["UPDATE"] = "Update";
$LANG["EXTERNAL_TORRENT"] = "External Torrent";
$LANG["TRACKERS_OFFLINE"] = "All Trackers<br />are <b>Offline</b>";



And if you want to use mega_scrape.php manually, add this code wherever you want to see it:

echo "[<a href='mega_scrape.php'><b>Run Mega Scrape</b></a>]";







[ATTACH]2347._xfImport[/ATTACH]

EDITED and FIXED by leoncoder
scraper.png
scraper.png
udpscraper.zip
Download
Unknown User
2014-10-11 10:01:57
Good for adding UDP scraping, now no one will be screaming about udp issues...
2014-12-06 05:04:51
Wonderful We really need him
Unknown User
2014-12-12 19:30:00
Although I already have a udp support i thought i would try this one which gave me the rest for udp's to update all trackers sometimes....but i get this error after updating.

fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/tricitytorrents/public_html/backend/udptscraper.php on line 19

Warning: fsockopen(): unable to connect to udp://tracker.openbittorrent.com:80 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /home/tricitytorrents/public_html/backend/udptscraper.php on line 19

but as you can see it updated just fine:



is there a work around for this ?

I have not really tried working on a udp script like this before.
Unknown User
2014-12-13 06:45:40
I don't know exactly, before used this mod I have canceled the function 'fsockopen' in 'functions.php' because it is not supported by the newest PHP versions.

In that moment I have do that from other reasons...
2014-12-13 06:56:16
It's not because of this? [url="http://torrentfreak.com/worlds-largest-bittorrent-tracker-goes-down-141205/"]http://torrentfreak.com/worlds-largest-bittorrent-tracker-goes-down-141205/[/url]
Unknown User
2014-12-13 14:38:19
"UFFENO1, post: 93564":

It's not because of this? [url="http://torrentfreak.com/worlds-largest-bittorrent-tracker-goes-down-141205/"]http://torrentfreak.com/worlds-largest-bittorrent-tracker-goes-down-141205/[/url]

That very well might be the case UFFEN01 cause i did notice it work correctlly for a bit then once i got back on line and did a update i got that error, so it very well may be because its down.

and thanks BigMax1
Unknown User
2015-03-25 08:54:29
I used your udp scrape code and its working good showing udp trackers  seeds&leeches from mega_scrape.php but the problem is on announce table trackers not updated with its seeds&leeches only http trackers updated its seeds&leeches.Udp trackers did not updated
2015-03-26 06:55:33
how i can add to admin cp
Unknown User
2015-04-29 20:46:37
i've tried this with php 5.6 but it gives some preg_match errors.
2015-04-30 06:28:26
I have never used this and i do not know how it's working but neither "prq.to" or  "tracker.openbittorrent.com" are up and running anymore. But it is perhaps no greater significance, what do I know i'm no coder.  :(  I only noticed it in the code.  :rolleyes:

And all mysql_query should be SQL_Query_exec
Unknown User
2015-04-30 07:56:25
made it to work.. kinda. on some torrents
2015-04-30 08:20:12
Ok  :)
Unknown User
2015-05-02 17:20:58
so i've fixed the regex error that said "preg_match(): Compilation failed: unmatched parentheses" ..

but now when i hit update i get "database error, please contact administrator."

and yes. all mysql_query are SQL_Query_exec

until now, with the error, the update worked.
Unknown User
2017-03-14 09:21:59
not working for me when I put this code my page is not open please help me
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: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728