View Single Post
  #1  
Old 25th October 2020, 21:45
JohnHasher JohnHasher is offline
Coder
 
Join Date: Apr 2020
P2P
Posts: 62
Post New Scrape System for XbtitFM
Hey guys , i actually made this for my modified XbtitFM but i think i need to publish it to get feedbacks.

the scrape system in XbtitFM is not that great. it will try to fetch only one tracker at a time and if that particular tracker is offline / under heavy load , the script will either show error or return zero peers.
The auto external update system or torrent peer auto update system in xbtitFM will not update peers if nobody visit the site or slow down the user who visit the site (To Update Peers Live)

Now i will explain my script.

Uses Scrapeer PHP library to fetch peers , know more at https://github.com/medariox/scrapeer

No need to visit the site to perform auto updates , the cronjobs will do it.
To make Auto scrape work will require root access.


How to use it?

1. Copy the fp_mscrape.php , fp_ascrape.php , afscrape.php , scraper.php files to include folder in xbtitFM.

2. Edit details.php and make the following changes (find and replace the code.) :

Code:
if (isset($_GET["act"]) && $_GET["act"]=="update")
   {

        require_once(__DIR__ .'/include/fp_mscrape.php');
       	$torrent = get_result("SELECT `announces` FROM `{$TABLE_PREFIX}files` WHERE `info_hash`='".mysqli_real_escape_string($GLOBALS['conn'],$id)."'", true, $btit_settings["cache_duration"]);
		    $urls=@unserialize($torrent[0]["announces"])?unserialize($torrent[0]["announces"]):array();
		    $keys=array_keys($urls);
		    scrape($keys, $id);

       redirect($btit_settings["url"]."/".(($btit_settings["fmhack_SEO_panel"]=="enabled" && $res_seo["activated"]=="true")?strtr($_GET["name"], $res_seo["str"], $res_seo["strto"])."-".$torrent_id.".html":"index.php?page=torrent-details&id=".$id));       //
       exit();
   }

3. Replace the function updatedata codes in functions.php (in include folder) to :

Code:
//FP - Auto Update Info Hash
function updatedata()
{
global $CURRENTPATH, $TABLE_PREFIX, $btit_settings;

    require_once $CURRENTPATH.'/fp_ascrape.php';

    global $update_interval;

    if($update_interval == 0) {
      return;
    }

    $now = time();

    $res = get_result("SELECT last_time as lt FROM {$TABLE_PREFIX}tasks WHERE task='update'", true, $btit_settings['cache_duration']);
    $row = $res[0];
    if(!$row)
    {
        do_sqlquery("INSERT INTO {$TABLE_PREFIX}tasks (task, last_time) VALUES ('update',$now)");
        return;
    }

    $ts = $row['lt'];

    if($ts + $update_interval > $now) {
      return;
    }

    do_sqlquery("UPDATE {$TABLE_PREFIX}tasks SET last_time=$now WHERE task='update' AND last_time = $ts");
    if(!mysqli_affected_rows($GLOBALS['conn'])){
      return;
    }

//Your trackers to include on auto update

$std_uscr = array( 'udp://tracker.coppersurfer.tk:6969/announce', 'udp://tracker.opentrackr.org:1337/announce', 'udp://tracker.leechers-paradise.org:6969/announce', 'udp://tracker.torrent.eu.org:451/announce', 'udp://tracker.fileparadise.in:1337/announce', 'udp://9.rarbg.com:2710/announce', 'udp://9.rarbg.to:2710/announce', 'udp://tracker.cyberia.is:6969/announce', 'udp://ipv4.tracker.harry.lu:80/announce', 'udp://exodus.desync.com:6969/announce', 'udp://opentracker.i2p.rocks:6969/announce' );
// uses 8 torrent at a time (try to getting multiscrape).
    $resurl = get_result("SELECT info_hash FROM {$TABLE_PREFIX}files ORDER BY lastupdate ASC LIMIT 8", true, $btit_settings['cache_duration']);

    if(!$resurl || count($resurl) == 0) {
        return $combinedinfohash = array();
    }

    foreach($resurl as $id => $rhash) {
        $combinedinfohash[] = $rhash['info_hash'];
  }
    //scrape($row["announce_url"],$row["info_hash"]);
    aupdscrape($std_uscr, $combinedinfohash);
}
4. to setup auto update open crontab and add job (below is an example command , make changes to make it work)

Code:
*/6 * * * * /usr/bin/php7.2 /home/public_html/include/afscrape.php

Example command explained :
*/6 * * * * means every 6 minute the auto scrape script will run (you can change it to any interval you want to auto update)
/usr/bin/php7.2 is the location of php7.2
/home/public_html/include/afscrape.php - location of the auto scrape trigger file (you can also rename this script file name to anything to avoid execution from browsers)

5. Check the site logs in admin panel to check the system

Like : Guest SUCCESS auto update of torrent infohash: 0000000000000000000000 with s:0 and l:0

reply here if you face any problem.

Bump: post your comments here about the bug / any problem you are facing to use this new system
Attached Files
File Type: zip new_scrape_system_for_xbtitfm_by_johnhasher.zip (8.5 KB, 32 views)

Last edited by JohnHasher; 25th October 2020 at 22:12. Reason: reminding things
Reply With Quote