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
Controls ·  Search New posts · Mark unread

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

2019-05-25 12:24:44
All credit to the original authors.
in torrents-details.php find
require_once("backend/BDecode.php");

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


Find (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 = mysqli_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>");
       }
   }

Replace with

/// Scrape code
//===| 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 = mysqli_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>");
               print ("</br>");
           }
           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>
                   <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_STATS")." /></div>
                   </form>
               </td>");
       }
       print ("</tr></table></td>");
   }
   //===| End Scrape External Torrents
///END SCRAPE

Add to english.php
$LANG["UPDATE_STATS"] = "Update Stats";
$LANG["EXTERNAL_TORRENT"] = "External Torrent";
$LANG["TRACKERS_OFFLINE"] = "All Trackers<br />are <b>Offline</b>";


If you want to run mega-scrape manually, add this code wherever you want to see it
echo "[<a href='mega_scrape.php'><b>Run Mega Scrape</b></a>]";

upload contents of attachment
udpscraper.zip
Download

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)
Unknown User
2019-07-05 05:23:31
Thanks
2019-07-05 18:48:28
big thanks (y)

Small addition on torrents-details

Search :

   $result = mysqli_num_rows($query);
       if($result == 0) {
           echo T_("NO_ACTIVE_PEERS")."\n";
       }else{
           ?>

           <table border="0" cellpadding="3" cellspacing="0" width="100%" class="table_table">
           <tr>
               <th class="table_head"><?php echo T_("PORT"); ?></th>
               <th class="table_head"><?php echo T_("UPLOADED"); ?></th>
               <th class="table_head"><?php echo T_("DOWNLOADED"); ?></th>
               <th class="table_head"><?php echo T_("RATIO"); ?></th>
               <th class="table_head"><?php echo T_("_LEFT_"); ?></th>
               <th class="table_head"><?php echo T_("FINISHED_SHORT"). "%"; ?></th>
               <th class="table_head"><?php echo T_("SEED"); ?></th>
               <th class="table_head"><?php echo T_("CONNECTED_SHORT"); ?></th>
               <th class="table_head"><?php echo T_("CLIENT"); ?></th>
               <th class="table_head"><?php echo T_("USER_SHORT"); ?></th>
           </tr>
   ?>


Replace with :


   $result = mysqli_num_rows($query);
       if($result == 0) {
           echo T_("NO_ACTIVE_PEERS")."\n";
       }else{
           ?>

           <table border="0" cellpadding="3" cellspacing="0" width="100%" class="table_table">
           <tr>
               <th class="table_head"><?php echo T_("PORT"); ?></th>
               <th class="table_head"><?php echo T_("UPLOADED"); ?></th>
               <th class="table_head"><?php echo T_("DOWNLOADED"); ?></th>
               <th class="table_head"><?php echo T_("RATIO"); ?></th>
               <th class="table_head"><?php echo T_("_LEFT_"); ?></th>
               <th class="table_head"><?php echo T_("FINISHED_SHORT"). "%"; ?></th>
               <th class="table_head"><?php echo T_("SEED"); ?></th>
               <th class="table_head"><?php echo T_("CONNECTED_SHORT"); ?></th>
               <th class="table_head"><?php echo T_("CLIENT"); ?></th>
               <th class="table_head"><?php echo T_("USER_SHORT"); ?></th>
           </tr>
   <script language="JavaScript">
       //--| Configure refresh interval (in seconds)
       <?php
       if ($count)
           echo "var countDownInterval = 6;";
       else
           echo "var countDownInterval = 600;"; // No torrents to scrape, refresh in 10 minutes
       ?>
       //--| Configure width of displayed text, in px (applicable only in NS4)
       var c_reloadwidth=200
   </script>

   <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>

   <script>
       var countDownTime=countDownInterval+1;
       function countDown(){
           countDownTime--;
           if (countDownTime <=0){
               countDownTime=countDownInterval;
               clearTimeout(counter)
               window.location.reload()
               return
           }
           if (document.all) //if IE 4+
               document.all.countDownText.innerText = countDownTime+" ";
           else if (document.getElementById) //--| else if NS6+
               document.getElementById("countDownText").innerHTML=countDownTime+" "
           else if (document.layers){ //--| CHANGE TEXT BELOW TO YOUR OWN
               document.c_reload.document.c_reload2.document.write('Next <a href="java script:window.location.reload()">rafraĆ®chir</a> dans <b id="countDownText">'+countDownTime+' </b> seconds')
               document.c_reload.document.c_reload2.document.close()
           }
           counter=setTimeout("countDown()", 1000);
       }

       function startit(){
           if (document.all||document.getElementById) //--| CHANGE TEXT BELOW TO YOUR OWN
           document.write('Suivant <a href="javascript:window.location.reload()">rafraĆ®chir</a> dans <b id="countDownText">'+countDownTime+' </b> seconds')
           countDown()
       }

       if (document.all||document.getElementById)
           startit()
       else
           window.onload=startit
   </script>
<?php

2019-07-05 19:15:06
does this work for everyone? Can I move it to completed or are there issues yet to be found?
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)
Unknown User
2019-07-05 19:20:26
"MicroMonkey, post: 66837, member: 311":

does this work for everyone? Can I move it to completed or are there issues yet to be found?

It works for me. Can anyone confirm does this scrape http/https as well trackers?
2019-07-05 19:29:16
"shadows, post: 66838, member: 20311":

It works for me. Can anyone confirm does this scrape http/https as well trackers?

I am in SSL and it works well ;)
Unknown User
2019-07-05 19:30:35
"spiritblue, post: 66839, member: 401":

I am in SSL and it works well ;)

i mean for http/https trackers not the site. For example:
[URL unfurl="true"]http://tracker.opentrackr.org:1337/announce[/url]
2019-07-05 19:41:30
The only thing I havent looked at yet was it seemed to have broken the scrape for a ubuntu repo or its not working for non udp sites. Can someone test this?
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)
Unknown User
2019-07-05 22:25:35
only issue ive found is no its not updating http are always offline and its also not updating the backup trackers seeders leechers and times completed
in torrent details its telling me that all udp trackers are online but no stats
Unknown User
2019-07-13 17:21:02
The bug which should be fixed is it is counting together all trackers and merging their seeders + leechers + completed together. It shouldn't do that.
Unknown User
2019-07-16 15:08:52
[USER=311]@MicroMonkey[/USER] [USER=20288]@m-jay[/USER] [USER=1398]@serph[/USER]

Here's how it needs to work, taking only the highest stats out of all trackers, not merging all together (Taken from [url="http://www.torrentgalaxy.to"]www.torrentgalaxy.to[/url])
Unknown User
2019-07-16 15:26:19
Yeah before I added this mod it did exactly that
Unknown User
2019-07-16 15:30:44
I'll take a look at the old way it was done I'm sure the stats we're split as the backup announce trackers got $stats[seeds] and the torrent was updated with $seeders1 or something
Unknown User
2019-07-16 15:31:36
"serph, post: 66950, member: 1398":

I'll take a look at the old way it was done I'm sure the stats we're split as the backup announce trackers got $stats[seeds] and the torrent was updated with $seeders1 or something

From where you got that old scraper? Can you post a link?
Unknown User
2019-07-16 16:15:12
the old scraper looked like this in torrent-details.php


   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_array($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>");
       }
   }

   echo "</tr></table>";
}
echo "</div></td></tr></table></center><br /><br />";  
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: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728