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

You are in: Forum / Forum / v2.08 / v2.08 Support

2021-12-02 16:00:18
Hi guys,
I get this error after mega_scrape.php running:


Database Error in mega_scrape.php on line 104: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `url` = 'https://tracker.tamersunion.org:443/announce' AND `torrent` = 953' at line 1. Query was: UPDATE `announce` SET `online` = 'yes', `seeders` = 0, `leechers` = 0, `times_completed` =  WHERE `url` = 'https://tracker.tamersunion.org:443/announce' AND `torrent` = 953.


Line 104 is
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");


Tracker: https://tracker.tamersunion.org is gone and many of my torrents have that in torrent creation so how to exclude that tracker or how to fix error?
In SQL table  under torrents==>announce==> I have just that tracker: udp://tracker.opentrackr.org:1337/announce  

:unsure  :unsure  :unsure  :unsure


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-12-02 18:58:12
what is the times_completed, there is no number
`times_completed` =  WHERE 


maybe try set time completed to zero before this code -
$stats[downloaded]


something like
$stats[downloaded] = 0;


it must be before so it does not reset others to 0
Last edited by M-jay warn on 2021-12-02 18:58:29
2021-12-02 19:33:17
Hi mate, times_completed = number of all downloads


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-12-02 19:37:19
Here is error

Query was: UPDATE `announce` SET `online` = 'yes', `seeders` = 0, `leechers` = 0, `times_completed` =  WHERE `url`
Last edited by M-jay warn on 2021-12-02 19:38:03
2021-12-02 20:02:53
whole code is that:



<?php
#============================#
#  TorrentTrader v2.08       #
#  http://torrenttrader.org  #
#----------------------------#
#  Modified by NordicWolf        #
#============================#

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

dbconn(false);
loggedinonly();
set_time_limit(0);
$interval = 1200; // Rescrape torrents every 2 hours
$ts = gmtime() - $interval;
$res = SQL_Query_exec("SELECT id, name, info_hash FROM torrents WHERE external = 'yes' ORDER BY last_action ASC LIMIT 1");
$count = get_row_count("torrents", "WHERE external = 'yes' ");

while ($row = mysql_fetch_array($res))
{
$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$row[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;
echo "<link href='themes/ExYu-Subs/css/ttce.css' rel='stylesheet'> ";
   //stdhead();
//begin_frame("Mega Scrape");
echo "<div class='torrent-category-detail clearfix'>
<table width='90%' align='center' border='0' class='account'><td class='css'>Torrent ID:</td><td class='css'  colspan='4' align='center'><font color='#00ff00'> $row[id] </font></td> <td class='css-right'><font color=#708090> $row[name]</font></td></tr>
<tr><td class='css' colspan='3'>Info Hash:</td> <td class='css-right' colspan='3'><font color=#00ff00> $row[info_hash]</font></td></tr>";
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)
{
//echo "<tr><td class='css' colspan='3'>$ann :</td><td class='css-right' colspan='3'><font color=#00fff0> Scrape not supported.</font></td></tr>";
continue;
}

// TPB's tracker is dead. Use openbittorrent instead
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://([^:/]*)(?::([0-9]*))?(?:/)?%si', $tracker))
{
$udp=true;
try
{
$timeout = 3;
$udp= new udptscraper($timeout);
$stats=$udp->scrape($tracker,$row["info_hash"]);
foreach ($stats as $id=>$scrape)
{
$seeders += $scrape['seeders'];
$leechers += $scrape['leechers'];
$downloaded += $scrape['completed'];
}
}
catch(ScraperException $e)
{
//echo('<tr><td class=css colspan=3>Error:</td><td class=css-right colspan=3><font color=#0000ff> ' . $e->getMessage() . "</font></td></tr>\n");
//echo('<tr><td class=css colspan=3>Connection error:</td><td class=css-right colspan=3><font color=#0000ff> ' . ($e->isConnectionError() ? 'yes' : 'no') . "</font></td></tr>\n");
}
}
else
{
$stats = torrent_scrape_url($tracker, $row["info_hash"]);
}

if ($stats['seeds'] !== null)
{
$seeders += $stats['seeds'];
$leechers += $stats['peers'];
$downloaded += $stats['downloaded'];
echo "<br><b>$ann</b><br>";
echo "<tr><td class='css' colspan='3'>Seeders:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['seeders']:$stats["seeds"])."</td></tr>";
echo "<tr><td class='css' colspan='3'>Leechers:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['leechers']:$stats["peers"])."</td></tr>";
echo "<tr><td class='css' colspan='3'>Downloaded:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['completed']:$stats["downloaded"])."</td></tr></table>";
SQL_Query_exec("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 "<tr><td class='css' colspan='3'> $ann :</td> <td class='css-right' colspan='3'><font color=#ff0000>Tracker timed out.</font></td></tr>";
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
}
}

if ($seeders !== null)
{
echo "<tr><td class='css-right' colspan='6'>Totals:</td></tr>";
echo "<tr><td class='css' colspan='3'>Seeders:</td> <td class='css-right' colspan='3'><font color='#006699'> $seeders </font></td></tr>";
echo"<tr><td class='css' colspan='3'>Leechers:</td> <td class='css-right' colspan='3'><font color='#00ff00'>  $leechers </font></td></tr>";
echo "<tr><td class='css' colspan='3'>Completed:</td> <td class='css-right' colspan='3'><font color='#FF9900'>  $downloaded </font></td></tr>";
SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$row['id']."'");
}
else
{
echo "<br><b><font color=red>All trackers are timed out.</font></b><br>";
echo "</div>";
//end_frame();
//stdfoot();
SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id = '".$row['id']."'");
}
}
?>

<script language="JavaScript">
//configure refresh interval (in seconds)
<?php if ($count)
echo "var countDownInterval = 1;";
else
echo "var countDownInterval = 1800;"; // No torrents to scrape, refresh in 30 minutes
?>
//configure width of displayed text, in px (applicable only in NS4)
var c_reloadwidth=500
</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('<tr><td class="css" colspan="3">Next <a href="java script:window.location.reload()">refresh</a> in</td><td class="css-right" colspan="3"> <b id="countDownText">'+countDownTime+' </b> seconds </td></tr>')
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('<tr><td class="css" colspan="3">Next <a href="java script:window.location.reload()">   refresh   </a> in</td><td class="css-right" colspan="3"> <b id="countDownText">'+countDownTime+' </b> &nbsp; seconds </td></tr>')
countDown()
}

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




www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-12-03 15:44:36
:unsure  because `times_completed`=WHERE  is the error i can only assume $stats[downloaded] is NULL.
that would be the array from the function torrent_scrape_url - also it is https

so adding default to 0's should change error to `times_completed`=0WHERE or remove error. if error please post new error there might be small change that is hard to see

i add // edit  so you can search file to see

<?php
#============================#
#  TorrentTrader v2.08       #
#  http://torrenttrader.org  #
#----------------------------#
#  Modified by NordicWolf        #
#============================#

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

dbconn(false);
loggedinonly();
set_time_limit(0);
$interval = 1200; // Rescrape torrents every 2 hours
$ts = gmtime() - $interval;
$res = SQL_Query_exec("SELECT id, name, info_hash FROM torrents WHERE external = 'yes' ORDER BY last_action ASC LIMIT 1");
$count = get_row_count("torrents", "WHERE external = 'yes' ");

while ($row = mysql_fetch_array($res))
{
$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$row[id].torrent");
$ann = $TorrentInfo[0];
$annlist = array();

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

// edit
$seeders = $leechers = $downloaded = 0;
// $seeders = $leechers = $downloaded = null;


echo "<link href='themes/ExYu-Subs/css/ttce.css' rel='stylesheet'> ";
  //stdhead();
//begin_frame("Mega Scrape");
echo "<div class='torrent-category-detail clearfix'>
<table width='90%' align='center' border='0' class='account'><td class='css'>Torrent ID:</td><td class='css'  colspan='4' align='center'><font color='#00ff00'> $row[id] </font></td> <td class='css-right'><font color=#708090> $row[name]</font></td></tr>
<tr><td class='css' colspan='3'>Info Hash:</td> <td class='css-right' colspan='3'><font color=#00ff00> $row[info_hash]</font></td></tr>";
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)
{
//echo "<tr><td class='css' colspan='3'>$ann :</td><td class='css-right' colspan='3'><font color=#00fff0> Scrape not supported.</font></td></tr>";
continue;
}

// TPB's tracker is dead. Use openbittorrent instead
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://([^:/]*)(?::([0-9]*))?(?:/)?%si', $tracker))
{
$udp=true;
try
{
$timeout = 3;
$udp= new udptscraper($timeout);
$stats=$udp->scrape($tracker,$row["info_hash"]);
foreach ($stats as $id=>$scrape)
{
$seeders += $scrape['seeders'];
$leechers += $scrape['leechers'];
$downloaded += $scrape['completed'];
}
}
catch(ScraperException $e)
{
//echo('<tr><td class=css colspan=3>Error:</td><td class=css-right colspan=3><font color=#0000ff> ' . $e->getMessage() . "</font></td></tr>\n");
//echo('<tr><td class=css colspan=3>Connection error:</td><td class=css-right colspan=3><font color=#0000ff> ' . ($e->isConnectionError() ? 'yes' : 'no') . "</font></td></tr>\n");
}
}
else
{
$stats = torrent_scrape_url($tracker, $row["info_hash"]);
}

// edit
if ($stats['seeds'] !== 0)
//if ($stats['seeds'] !== null)

{
$seeders += $stats['seeds'];
$leechers += $stats['peers'];
$downloaded += $stats['downloaded'];
echo "<br><b>$ann</b><br>";
echo "<tr><td class='css' colspan='3'>Seeders:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['seeders']:$stats["seeds"])."</td></tr>";
echo "<tr><td class='css' colspan='3'>Leechers:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['leechers']:$stats["peers"])."</td></tr>";
echo "<tr><td class='css' colspan='3'>Downloaded:</td> <td class='css-right' colspan='3'> ".($udp?$scrape['completed']:$stats["downloaded"])."</td></tr></table>";

// edit
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $seeders, `leechers` = $leechers, `times_completed` = $downloaded WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
// SQL_Query_exec("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 "<tr><td class='css' colspan='3'> $ann :</td> <td class='css-right' colspan='3'><font color=#ff0000>Tracker timed out.</font></td></tr>";
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
}
}

// edit
if ($seeders !== 0)
//if ($seeders !== null)


{
echo "<tr><td class='css-right' colspan='6'>Totals:</td></tr>";
echo "<tr><td class='css' colspan='3'>Seeders:</td> <td class='css-right' colspan='3'><font color='#006699'> $seeders </font></td></tr>";
echo"<tr><td class='css' colspan='3'>Leechers:</td> <td class='css-right' colspan='3'><font color='#00ff00'>  $leechers </font></td></tr>";
echo "<tr><td class='css' colspan='3'>Completed:</td> <td class='css-right' colspan='3'><font color='#FF9900'>  $downloaded </font></td></tr>";
SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$row['id']."'");
}
else
{
echo "<br><b><font color=red>All trackers are timed out.</font></b><br>";
echo "</div>";
//end_frame();
//stdfoot();
SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id = '".$row['id']."'");
}
}
?>

<script language="JavaScript">
//configure refresh interval (in seconds)
<?php if ($count)
echo "var countDownInterval = 1;";
else
echo "var countDownInterval = 1800;"; // No torrents to scrape, refresh in 30 minutes
?>
//configure width of displayed text, in px (applicable only in NS4)
var c_reloadwidth=500
</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('<tr><td class="css" colspan="3">Next <a href="java script:window.location.reload()">refresh</a> in</td><td class="css-right" colspan="3"> <b id="countDownText">'+countDownTime+' </b> seconds </td></tr>')
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('<tr><td class="css" colspan="3">Next <a href="java script:window.location.reload()">   refresh   </a> in</td><td class="css-right" colspan="3"> <b id="countDownText">'+countDownTime+' </b>   seconds </td></tr>')
countDown()
}

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


if error please try on edited file
replace
$seeders = $leechers = $downloaded = 0;


for - sometimes we return -1 we just want to see number this will just add 2 to each figure
$seeders = $leechers = $downloaded = 2;
Last edited by M-jay warn on 2021-12-03 15:49:43
2021-12-03 20:46:16
Yes mate, thanks it works if I sett $seeders = $leechers = $downloaded = 1;
but honestly, it's cheating in a way
we are pumping up torrents that are dead but there is a solution to the problem and that was the goal in the post

thanks mate   :giggle


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2021-12-03 21:09:40
I don't use torrent_scrape_url function to test properly I just try to read code, but it looks like that returns negative number

if ($ret['seeds'] === null) {
$ret['seeds'] = -1;
$ret['peers'] = -1;
$ret['downloaded'] = -1;
}


Try old code with them -1 changed for 0 in the torrent_scrape_url function
2021-12-17 18:55:10
just use https://github.com/medariox/scrapeer

this is an example of how i did it on xbtit.
check out: https://www.bvlist.com/showthread.php?t=12302

i already made it for my script.

remember to enable sockets in php ini


follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2021-12-17 19:29:27
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