Bravo List
Register
Go Back   > Bravo List > Source Code > Active Trackers > Torrent Trader
Reply
  #1  
Old 28th August 2010, 08:26
cilcil cilcil is offline
Member
 
Join Date: Jan 2010
Korea South
Posts: 3
Default TPB scrape
Hi, have a good day!!!

TPB please refer to page
TPB scrape to take advantage of this article here?

:: http://scrape.thepiratebay.org/

Scrape all torrents from the open trackers at once. get this file.

The file is in the the following format:
[info_hash_base64]:[seeders]:[leechers]\n

The [info_hash_base64] is the binary info_hash base64 encoded.
[seeders] are number of seeders in base10 ascii
[leechers] are number of leechers in base10 ascii
There is one line per info_hash terminated by the \n character.

The file is updated every 3 minutes, please don't retrieve it more than every 3 minutes.

Please use this way of scraping if you scrape alot of torrents from our trackers,
this will reduce load on our trackers and at the same time give you all the stats at once.
It will also give you a simpler handling of your indexed torrents that uses our tracker.

Using this metod is higly recommended if you index more then 10.000 torrents using our trackers.


PHP/MySQL code example:

test.sql
PHP Code:
-- Example torrents table

--  last_scrapedunixtime format
-- info_hashstored in base64 encoding

CREATE  TABLE 
`torrents` (
  `
idint(10unsigned NOT NULL auto_increment,
  `
name`  varchar(255) default NULL,
  `
trackervarchar(255) default NULL,
  `
seeders`  int(10unsigned default NULL,
  `
leechersint(10unsigned default  NULL,
  `
last_scrapedint(10unsigned default NULL,
  `
info_hash`  varchar(40) default NULL,
  
PRIMARY KEY  (`id`),
  
UNIQUE KEY  `info_hash` (`info_hash`)
);

--
Some sample data:
-- (
just  some current torrents on the tracker they might disapear)

INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('k37dQKfsLJ98NIm19v3lG32EWrw=',5+5,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XdDGpJBm2eSbrwJOjifBjYKRG0E=',5+2,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('u5Y2QOgvN+Sux8O7elTmZSnV45I=',5+0,8+1,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Lc9x9zMdGYRA0B9Oa7j0GC3FRM8=',5+0,8+2,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('ufZcoUP56DzOxhh4iZdYwWUxM9k=',5+6,8+9,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('a6S4USSJA8wq2mKsCBXv4eYt8SE=',5+3,8+10,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Ho4+xsmm0SUi08lfqgj6QKUsG3Q=',5+0,8+5,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XI0RCfsDPOEc4uE/VE67GJNdsEU=',5+8,8+6,'http://tv.tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Y+DQ4oHQ5AKMF93n/DJb/kSqdWU=',5+1,8+1,'http://tv.tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('X98AZNOuPAbA1DRcHujovGzCJy0=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('xuDNk5x5hsQJtvlXywkL6dCpfk8=',5+3,8+13,'http://open.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('s+HjXfq7Kkx45gh6ifRp1tmHbxo=',5+1,8+2,'http://tpb.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/Jx5zoZfPE3P3Xi8YjdsoqHmliA=',5+9,8+25,'http://tpb.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('MF2MXmNBOws1W+1XFi5jWnsW/u4=',5+5,8+3,'http://other.tracker.org/announce');  
INSERT INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/Jx5zoZfPE3P3Xi8YjdsoqHmlis=',5+3,8+0,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('NEt3Qy+WvEh2DSG0ik9pYLfgRJM=',5+10,8+3,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('tX03O1rr3ut6sL61/aZkoKSP9Ik=',5+2,8+6,'http://open.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('bR4qXRcr4mrRlcdzJtOeRK6sVkw=',5+0,8+1,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('+lo4+vo4EOtmfSAhGnA5y5Vg9rs=',5+1,8+0,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('BQ2nGY+gjtS5DBdFsaF85jwPhS8=',5+1,8+5,'http://tracker.prq.to/announce');  
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('VgbRqfwogEIGSwaBuAiWzBqSBuM=',5+0,8+4,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('k0tMHF1bRnkVKiWkxKkkWdsMzMg=',5+29,8+2,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('xvxizrMTO3CFVOAOY9FOxsGFMCQ=',5+0,8+1,'http://vip.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('23Hn73X4OOOLX1MehQ4mKMoXbVU=',5+9,8+13,'http://tv.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('wZkn9HfxW83bNrh0OVKHKPDjhAY=',5+1,8+3,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('ZqiFqXTRZ4rSE8xCNAPB5n8WKOA=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('waE8U1Ggn4EHfRY/VhYbh9c1aRg=',5+3,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('oRQ32XCmNpqSDbuJRr5cqxuuIRY=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Vs/XPyW+berBeyXLhwZ2nesTLo4=',5+0,8+5,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('QMtgehc5Fc7mm/xtiD5iW1MoLJs=',5+1,8+2,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Ok8lq9i5cKVQWp3AhBv5fPMY9q0=',5+6,8+6,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('CFGSx5DYw+KKqiVbfgE3kChdhPE=',5+1,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/MuHkhlGMozI8HTm+aoaNiG4HNk=',5+4,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('LrwNc8m+qzrwC+me63BEwnlWzDQ=',5+6,8+6,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('FCCOqJMbM4tb1a3xBpTAkY/VF3o=',5+3,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('tFn1pHUU7/3c2sWIETbyBfou6uY=',5+1,8+5,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('6K8GwrYqvJtxPHgU1pGW7jqXkm0=',5+7,8+6,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('6/vG/71oAzrULIbjYRJQs+dC1Vc=',5+1,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('KEyT5o+FSezV+XlOxBn2VnlWk9E=',5+0,8+11,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Q1antpizQSbdw1VgFcs1ClhyQD4=',5+1,8+3,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('esByCfSnnMc6VnKYfYm+hdsH5A8=',5+1,8+4,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('psn29ZsLXpXbZs1P+iXxa4ueUpc=',5+1,8+1,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('r9w7ZTIY2eFVuC9hDR5+4EqdddI=',5+1,8+0,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XV2JK0rMS0iM/zDn8rKzLMNTh0g=',5+8,8+6,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('4ZVlA2egK7IoREmKxfNoqIh9qXA=',5+11,8+29,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('GmAkI7zF1MThqb+885qRB/7pGLs=',5+5,8+5,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('T1btxBua9BBFa/Ls4hOy6NRrnyA=',5+0,8+2,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('fyzefMY8PhoJUagPJlaEK/v4CrY=',5+0,8+9,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Cb+CGrtxEKCZ/c+uQsA8iQv8pxA=',5+0,8+2,'http://tracker.prq.to/announce'); 
tpb.php
PHP Code:
<?

$mysql_host  
"127.0.0.1";
$mysql_user "root";
$mysql_pass "502t";
$mysql_db  "ob";
$connection =  @mysql_connect("$mysql_host","$mysql_user","$mysql_pass") or dberr();
$db  = @mysql_select_db("$mysql_db"$connection) or die("Couldn't select  database.");

// Get info_hash for all our torrents by trackers  included in the bulk-scrape.
 
$r=mysql_query("SELECT  info_hash,seeders,leechers FROM torrents WHERE tracker LIKE  '%thepiratebay.org/announce%' OR tracker LIKE  '%tracker.prq.to/announce%'");


// Count total number of  torrents we have that are tracked by trackers included in the  bulk-scrape.
 
$totaltorrents=mysql_num_rows($r);

while  (
$rs=mysql_fetch_assoc($r)) {

   
/*
    *  Here is the place  to recode the info_hash to however you stored it in your real database.
    *  For  example if you store it base64-encoded you would:
    *
    *  $rs[info_hash]=base64_encode(urldecode($rs[info_hash]))
    */

    
$torrents[$rs[info_hash]][seeders]=$rs[seeders];
    
$torrents[$rs[info_hash]][leechers]=$rs[leechers];

  
//  Download the scrape data  
  
$fp=bzopen("http://scrape.thepiratebay.org/all.txt.bz2""r");

//  Read data from file.
 
$scrape_data="";
 while (!
feof($fp)) {
    
$scrape_data .= bzread($fp65536);
 }
 
bzclose($fp);

$scrape_data_rows=explode("\n",  $scrape_data);

// Save some memory.
 
unset($scrape_data);

$updated=0;  // count how many torrents we updated;

foreach  ($scrape_data_rows as $rows) {
  
$row=explode(":"$rows);  //  $row[0] is info_hash in base64 encoding
                              // $row[1] is number of seeders
                             //  $row[2] is number of leechers

  
if (is_array($torrents[$row[0]]))  {  // We have the torrent in our database.

    // if we already  have the correct number of peers, no need to update the database.
      
if (($torrents[$row[0]][seeders] != $row[1]) &&  ($torrents[$row[0]][leechers] != $row[2])) {
        
$r=mysql_query("UPDATE torrents SET seeders=$row[1], leechers=$row[2],  last_scraped=unix_timestamp() WHERE info_hash='$row[0]'");
        
$updated++;
     }

  }

}

// Set seeders/leechers  to 0 for torrents we have'nt seen for 2 days.
$r=mysql_query("UPDATE  torrents SET seeders=0, leechers=0 WHERE last_scraped <  unix_timestamp() - (86400*2) AND (tracker LIKE  '%thepiratebay.org/announce%' OR tracker LIKE  '%tracker.prq.to/announce%')");

echo 
"We updated $updated of  $totaltorrents in our database\n";
?>
Thank you!

Last edited by cilcil; 28th August 2010 at 09:33. Reason: code set
Reply With Quote
  #2  
Old 26th November 2013, 18:34
rtmrtm's Avatar
rtmrtm rtmrtm is offline
Member
 
Join Date: Jan 2010
Posts: 12
Wink Mega Scrape
PHP Code:
<?php
// Mega Scrape
// Version 2.x
//
// Authors: FLASH & TorrentialStorm
// Last Updated: 06/Jan/2011 @ 04:49 by TorrentialStorm

require_once("backend/functions.php");
require_once(
"backend/BDecode.php");
require_once(
"backend/parse.php");
dbconn(false);

set_time_limit(0);

$interval 100// Rescrape torrents every x seconds. (Default: 2 days)

$ts gmtime() - $interval;
$res mysql_query("SELECT id, info_hash FROM torrents WHERE external =  'yes' AND last_action <= FROM_UNIXTIME($ts) ORDER BY last_action DESC  LIMIT 3");
$count get_row_count("torrents""WHERE external = 'yes' AND last_action <= FROM_UNIXTIME($ts)");

while (
$row mysql_fetch_array($res)) {
echo 
"<B>ID: $row[id]</B><BR>";
    
$tres mysql_query("SELECT `url` FROM `announce` WHERE `torrent` = $row[id]");
    
$annlist = array();
    while (
$trow mysql_fetch_array($tres)) {
        
$annlist[] = $trow["url"];
    }
    
$seeders $leechers $downloaded null;
    echo 
"Info_Hash: $row[info_hash]<BR>";
    foreach (
$annlist as $ann) {
        
$tracker explode("/"$ann);
        
$path array_pop($tracker);
        
$oldpath $path;
        
$path preg_replace("/^announce/""scrape"$path);
        
$tracker implode("/"$tracker)."/".$path;
        if (
$oldpath == $path) {
            echo 
"<BR><B>$ann</B>: Scrape not supported.<BR>";
            continue;
        }

        
$stats torrent_scrape_url($tracker$row["info_hash"]);
        if (
$stats['seeds'] != -1) {
            
$seeders += $stats['seeds'];
            
$leechers += $stats['peers'];
            
$downloaded += $stats['downloaded'];
            echo 
"<BR><B>$ann</B><BR>";
            echo 
"Seeders: $stats[seeds]<BR>";
            echo 
"Leechers: $stats[peers]<BR>";
            echo 
"Downloaded: $stats[downloaded]<BR>";
            
mysql_query("UPDATE `announce` SET `online` = 'yes',  `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed`  = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` =  $row[id]");
        } else {
            echo 
"<BR><B>$ann</B>: Tracker timeout.<BR>";
            
mysql_query("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
        }
    }

    if (
$seeders !== null){
        echo 
"<BR><B>Totals:</B><BR>";
        echo 
"Seeders: $seeders<BR>";
        echo
"Leechers: $leechers<BR>";
        echo 
"Completed: $downloaded<BR><BR>";

        
mysql_query("UPDATE torrents SET leechers='".$leechers."',  seeders='".$seeders."',times_completed='".$downloaded."',last_action=  '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
    }else{
        echo 
"All trackers timed out.<BR>";
        
mysql_query("UPDATE torrents SET last_action= '".get_date_time()."' WHERE id='".$row['id']."'");
    }
}
?>





<script language="JavaScript">

//Refresh page script- By Brett Taylor (glutnix@yahoo.com.au)
//Modified by Dynamic Drive for NS4, NS6+
//Visit http://www.dynamicdrive.com for this script

//configure refresh interval (in seconds)
<? if ($count)
echo 
"var countDownInterval=6;";
else
echo 
"var countDownInterval=900;"// No torrents to scrape, refresh in 15mins
?>
//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="javascript:window.location.reload()">refresh</a> in <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('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
countDown()
}

if (document.all||document.getElementById)
startit()
else
window.onload=startit

</script>

Last edited by rtmrtm; 26th November 2013 at 18:36. Reason: Mega Scrape
Reply With Quote
  #3  
Old 10th December 2013, 16:20
Extremlym's Avatar
Extremlym Extremlym is offline
Senior Member
 
Join Date: Oct 2012
P2P
Posts: 102
Default
Quote:
Originally Posted by cilcil View Post
Hi, have a good day!!!

TPB please refer to page
TPB scrape to take advantage of this article here?

:: http://scrape.thepiratebay.org/

Scrape all torrents from the open trackers at once. get this file.

The file is in the the following format:
[info_hash_base64]:[seeders]:[leechers]\n

The [info_hash_base64] is the binary info_hash base64 encoded.
[seeders] are number of seeders in base10 ascii
[leechers] are number of leechers in base10 ascii
There is one line per info_hash terminated by the \n character.

The file is updated every 3 minutes, please don't retrieve it more than every 3 minutes.

Please use this way of scraping if you scrape alot of torrents from our trackers,
this will reduce load on our trackers and at the same time give you all the stats at once.
It will also give you a simpler handling of your indexed torrents that uses our tracker.

Using this metod is higly recommended if you index more then 10.000 torrents using our trackers.


PHP/MySQL code example:

test.sql
PHP Code:
-- Example torrents table

--  last_scrapedunixtime format
-- info_hashstored in base64 encoding

CREATE  TABLE 
`torrents` (
  `
idint(10unsigned NOT NULL auto_increment,
  `
name`  varchar(255) default NULL,
  `
trackervarchar(255) default NULL,
  `
seeders`  int(10unsigned default NULL,
  `
leechersint(10unsigned default  NULL,
  `
last_scrapedint(10unsigned default NULL,
  `
info_hash`  varchar(40) default NULL,
  
PRIMARY KEY  (`id`),
  
UNIQUE KEY  `info_hash` (`info_hash`)
);

--
Some sample data:
-- (
just  some current torrents on the tracker they might disapear)

INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('k37dQKfsLJ98NIm19v3lG32EWrw=',5+5,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XdDGpJBm2eSbrwJOjifBjYKRG0E=',5+2,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('u5Y2QOgvN+Sux8O7elTmZSnV45I=',5+0,8+1,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Lc9x9zMdGYRA0B9Oa7j0GC3FRM8=',5+0,8+2,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('ufZcoUP56DzOxhh4iZdYwWUxM9k=',5+6,8+9,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('a6S4USSJA8wq2mKsCBXv4eYt8SE=',5+3,8+10,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Ho4+xsmm0SUi08lfqgj6QKUsG3Q=',5+0,8+5,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XI0RCfsDPOEc4uE/VE67GJNdsEU=',5+8,8+6,'http://tv.tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Y+DQ4oHQ5AKMF93n/DJb/kSqdWU=',5+1,8+1,'http://tv.tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('X98AZNOuPAbA1DRcHujovGzCJy0=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('xuDNk5x5hsQJtvlXywkL6dCpfk8=',5+3,8+13,'http://open.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('s+HjXfq7Kkx45gh6ifRp1tmHbxo=',5+1,8+2,'http://tpb.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/Jx5zoZfPE3P3Xi8YjdsoqHmliA=',5+9,8+25,'http://tpb.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('MF2MXmNBOws1W+1XFi5jWnsW/u4=',5+5,8+3,'http://other.tracker.org/announce');  
INSERT INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/Jx5zoZfPE3P3Xi8YjdsoqHmlis=',5+3,8+0,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('NEt3Qy+WvEh2DSG0ik9pYLfgRJM=',5+10,8+3,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('tX03O1rr3ut6sL61/aZkoKSP9Ik=',5+2,8+6,'http://open.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('bR4qXRcr4mrRlcdzJtOeRK6sVkw=',5+0,8+1,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('+lo4+vo4EOtmfSAhGnA5y5Vg9rs=',5+1,8+0,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('BQ2nGY+gjtS5DBdFsaF85jwPhS8=',5+1,8+5,'http://tracker.prq.to/announce');  
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('VgbRqfwogEIGSwaBuAiWzBqSBuM=',5+0,8+4,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('k0tMHF1bRnkVKiWkxKkkWdsMzMg=',5+29,8+2,'http://tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('xvxizrMTO3CFVOAOY9FOxsGFMCQ=',5+0,8+1,'http://vip.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('23Hn73X4OOOLX1MehQ4mKMoXbVU=',5+9,8+13,'http://tv.tracker.thepiratebay.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('wZkn9HfxW83bNrh0OVKHKPDjhAY=',5+1,8+3,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('ZqiFqXTRZ4rSE8xCNAPB5n8WKOA=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('waE8U1Ggn4EHfRY/VhYbh9c1aRg=',5+3,8+4,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('oRQ32XCmNpqSDbuJRr5cqxuuIRY=',5+0,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Vs/XPyW+berBeyXLhwZ2nesTLo4=',5+0,8+5,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('QMtgehc5Fc7mm/xtiD5iW1MoLJs=',5+1,8+2,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Ok8lq9i5cKVQWp3AhBv5fPMY9q0=',5+6,8+6,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('CFGSx5DYw+KKqiVbfgE3kChdhPE=',5+1,8+3,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('/MuHkhlGMozI8HTm+aoaNiG4HNk=',5+4,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('LrwNc8m+qzrwC+me63BEwnlWzDQ=',5+6,8+6,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('FCCOqJMbM4tb1a3xBpTAkY/VF3o=',5+3,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('tFn1pHUU7/3c2sWIETbyBfou6uY=',5+1,8+5,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('6K8GwrYqvJtxPHgU1pGW7jqXkm0=',5+7,8+6,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('6/vG/71oAzrULIbjYRJQs+dC1Vc=',5+1,8+0,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('KEyT5o+FSezV+XlOxBn2VnlWk9E=',5+0,8+11,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Q1antpizQSbdw1VgFcs1ClhyQD4=',5+1,8+3,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('esByCfSnnMc6VnKYfYm+hdsH5A8=',5+1,8+4,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('psn29ZsLXpXbZs1P+iXxa4ueUpc=',5+1,8+1,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('r9w7ZTIY2eFVuC9hDR5+4EqdddI=',5+1,8+0,'http://other.tracker.org/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('XV2JK0rMS0iM/zDn8rKzLMNTh0g=',5+8,8+6,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('4ZVlA2egK7IoREmKxfNoqIh9qXA=',5+11,8+29,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('GmAkI7zF1MThqb+885qRB/7pGLs=',5+5,8+5,'http://yetanother.tracker.org/announce.php');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('T1btxBua9BBFa/Ls4hOy6NRrnyA=',5+0,8+2,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('fyzefMY8PhoJUagPJlaEK/v4CrY=',5+0,8+9,'http://tracker.prq.to/announce');
INSERT  INTO torrents (info_hash,seeders,leechers,tracker)  VALUES('Cb+CGrtxEKCZ/c+uQsA8iQv8pxA=',5+0,8+2,'http://tracker.prq.to/announce'); 
tpb.php
PHP Code:
<?

$mysql_host  
"127.0.0.1";
$mysql_user "root";
$mysql_pass "502t";
$mysql_db  "ob";
$connection =  @mysql_connect("$mysql_host","$mysql_user","$mysql_pass") or dberr();
$db  = @mysql_select_db("$mysql_db"$connection) or die("Couldn't select  database.");

// Get info_hash for all our torrents by trackers  included in the bulk-scrape.
 
$r=mysql_query("SELECT  info_hash,seeders,leechers FROM torrents WHERE tracker LIKE  '%thepiratebay.org/announce%' OR tracker LIKE  '%tracker.prq.to/announce%'");


// Count total number of  torrents we have that are tracked by trackers included in the  bulk-scrape.
 
$totaltorrents=mysql_num_rows($r);

while  (
$rs=mysql_fetch_assoc($r)) {

   
/*
    *  Here is the place  to recode the info_hash to however you stored it in your real database.
    *  For  example if you store it base64-encoded you would:
    *
    *  $rs[info_hash]=base64_encode(urldecode($rs[info_hash]))
    */

    
$torrents[$rs[info_hash]][seeders]=$rs[seeders];
    
$torrents[$rs[info_hash]][leechers]=$rs[leechers];

  
//  Download the scrape data  
  
$fp=bzopen("http://scrape.thepiratebay.org/all.txt.bz2""r");

//  Read data from file.
 
$scrape_data="";
 while (!
feof($fp)) {
    
$scrape_data .= bzread($fp65536);
 }
 
bzclose($fp);

$scrape_data_rows=explode("\n",  $scrape_data);

// Save some memory.
 
unset($scrape_data);

$updated=0;  // count how many torrents we updated;

foreach  ($scrape_data_rows as $rows) {
  
$row=explode(":"$rows);  //  $row[0] is info_hash in base64 encoding
                              // $row[1] is number of seeders
                             //  $row[2] is number of leechers

  
if (is_array($torrents[$row[0]]))  {  // We have the torrent in our database.

    // if we already  have the correct number of peers, no need to update the database.
      
if (($torrents[$row[0]][seeders] != $row[1]) &&  ($torrents[$row[0]][leechers] != $row[2])) {
        
$r=mysql_query("UPDATE torrents SET seeders=$row[1], leechers=$row[2],  last_scraped=unix_timestamp() WHERE info_hash='$row[0]'");
        
$updated++;
     }

  }

}

// Set seeders/leechers  to 0 for torrents we have'nt seen for 2 days.
$r=mysql_query("UPDATE  torrents SET seeders=0, leechers=0 WHERE last_scraped <  unix_timestamp() - (86400*2) AND (tracker LIKE  '%thepiratebay.org/announce%' OR tracker LIKE  '%tracker.prq.to/announce%')");

echo 
"We updated $updated of  $totaltorrents in our database\n";
?>
Thank you!
WORKS on 2.7??????
Reply With Quote
Reply

Tags
scrape , tpb

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 08:03. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.