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

You are in: Forum / Forum / General / General Chat

2022-01-15 12:25:20
i want to build a file tree similar like kickass



if you got any idea please share
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-15 16:34:47
So the only files that need updated are the parse?
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)
2022-01-15 17:14:10
total file size is not available too

but i found a way to calculate it


follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-15 17:38:52
2022-01-15 17:44:52
making a file tree for v2 torrents is easy



still can't figure out how to build for v1 torrents
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-16 07:05:11
noticed the files were not insert into database correctly because there if a difference between the return file/filetree array so now i make a array for v2 but in the old v1 way, if this can be improved please help out.

For those on v3 all i have done is edit the backend/parse.php we still need to check announce but this takes care of uploading v2 torrents to the site
my codes different i use it in a class but its pretty easy to walk through the difference

in the parse function i changed $torrentinfo[?] to have named keys to make it easier to read, if you do this you would need to change the same in import.php & upload.php or leave as numbers which ever.

    public function Parse($filename = "")
   {
       $torrentInfo = array();
       $array = array();

       //check file type is a torrents
       $torrent = explode(".", $filename);
       // $fileend = end($torrent);
       $fileend = strtolower(end($torrent));

       if ($fileend == "torrent") {
           $parse = file_get_contents("$filename");
        // If Parse Lets Read It
        if (!isset($parse)) {
           Redirect::autolink(URLROOT, Lang::T("Error Getting Torrent file"));
       } else {
           // Decode File Array
           $array = Bencode::decode($parse);
           // If Array Lets Read It
           if ($array === false) {
               Redirect::autolink(URLROOT, Lang::T("Unable to decode file."));
           } else {
               if (array_key_exists("info", $array) === false) {
                   Redirect::autolink(URLROOT . "/index", Lang::T("Error opening torrent.<br>"));
               } else {
                   //Get Announce URL
                   $torrentInfo['announce'] = $array["announce"];
                   //Get Announce List Array
                   if (isset($array["announce-list"])) {
                       $torrentInfo["announce-list"] = $array["announce-list"];
                   }
                   // Calculates date from UNIX Epoch
                   $torrentInfo["creation date"] = date('r', $array["creation date"]);
                   //Get torrents comment
                   if (isset($array['comment'])) {
                       $torrentInfo['comment'] = $array['comment'];
                   }
                   // Read info - files
                   $info = $array["info"];
                   // The name of the torrents is different to the file name
                   $torrentInfo['name'] = $info['name'];
                   // Calculate Size/Count
                   $filecount = 0;
                   $torrentsize = 0;
                   // Get file list
                   if (isset($info["files"]) && is_array($info["files"])) {
                       // Calculates SHA1 Hash
                       $torrentInfo['hash'] = hash('sha1', Bencode::encode($info));
                       // Return Marker To identify as v1
                       $torrentInfo['type'] = '1';
                       //Get files here
                       $torrentInfo['files'] = $info["files"];

                       foreach ($info["files"] as $file) {
                           $filecount = ++$filecount;
                           $torrentsize += $file['length'];
                       }
                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } elseif (isset($info["file tree"]) && is_array($info["file tree"])) {
                       // Calculates SHA256 Hash
                       $torrentInfo['hash'] = hash('sha256', Bencode::encode($info));
                       // Return Marker To identify as v2
                       $torrentInfo['type'] = '2';
                       //Get files here
                       $torrentInfo['files'] = $info["file tree"];
                       //$torrentInfo['files'] = array("path"=>$info["file tree"], "length"=>$info["file tree"][$torrentInfo['name']][$torrentInfo['length']]);

                       foreach ($info["file tree"] as  $key => $value) {
                           $test = array_flatten($torrentInfo['files']);
                           $filecount = ++$filecount;
                           $torrentsize += $test['length'];
                           $newfiles[] = [
                               'path' => array($key),
                               'length' => $test['length']
                           ];
                       }
                       // Replace File Stucture
                       $torrentInfo['files'] = $newfiles;

                       $torrentInfo['length'] = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;

                   } else {
                       // Single File Torrent
                       $torrentInfo['name'] = $info['name'];
                       $torrentInfo['length'] = $info['length'];
                       $torrentInfo['ttfilecount'] = 1;
                   }

               }
           }
           
       }
       }
       return $torrentInfo;
       //var_dump($torrentInfo);
   }


i also used this function so add above parse function on parse.php
//convert multi to single array
function array_flatten($array) {
   if (!is_array($array)) {
     return FALSE;
   }
   $result = array();
   foreach ($array as $key => $value) {
     if (is_array($value)) {
       $result = array_merge($result, array_flatten($value));
     }
     else {
       $result[$key] = $value;
     }
   }
   return $result;
}
Last edited by M-jay warn on 2022-01-16 07:10:10
2022-01-16 07:23:31
does the file count and total file length works for v2?

and files well i am developing a new way to do it, lets hope it works
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-16 07:25:23
2022-01-16 07:44:47
On local host every thing is fine, just going to take a look at hybrid torrents then I'll do live test and look at announce

With hybrid you can connect to v1 & v2 swarms
2022-01-16 08:02:04
does the scrape lib support v2 hashes and hybrids?
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-16 08:02:33
2022-01-16 09:41:25
Not sure yet, with v1 we have 20byte sha1 and with v2 it says (possibly truncated) SHA-256 hash so if that v2 hash that's sha256 at 64 characters is cut to 20 should be fine - should lol still needs further testing

To explain why if you look at scrape.php page the old original internal one all we do with scrape is select torrent by hash then we count seeders peers and return. By that same logic if external we just use hash as like a $_GET to identify the torrent so site can return seeds and leech

This is just theory it depends how each person saves in database if everyone cuts length of sha256 to 20 it would make sense but without some v2 from piratebay, kickass etc I don't know the common way same with magnets

2022-01-16 10:09:49
you know how to calculate v2 infohash?
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-16 10:11:17

//Read info, store as (infovariable)
$infovariable = $array["info"];

// Calculates SHA1 Hash
$infohash = sha1(BEncode($infovariable));
$TorrentInfo[1] = $infohash ;


for v1 the infohashes where calculated using above code

does this work?

$torrentInfo['hash'] = hash('sha256', Bencode::encode($info));

follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
Last edited by JohnHasher on 2022-01-16 10:12:33
2022-01-16 10:17:50
this is what im testing at minute
                        $hash = hash('sha256', Bencode::encode($info));
                       $torrentInfo['hash'] = mb_substr($hash, 0, 40);$hash;
2022-01-16 10:40:24
well the scraper only supports v1
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
2022-01-16 11:00:43
how do you know ?  its just the hash so how did you test

here is improvement to looking through info array and getting file array
                        //Get files here
                       $torrentInfo['files'] = $info["file tree"];
                     
                       foreach ($info["file tree"] as  $key => $value) {

                           $path = $key;
                           foreach($value as $detail){
                               $filecount = ++$filecount;
                               $torrentsize += $detail['length'];
                               $newfiles[] = [
                                   'path' => $path, // key is important
                                   'length' => $detail['length']
                               ];
                           }
                       }
                       // Replace File Stucture
                       $torrentInfo['files'] = $newfiles;

2022-01-16 12:19:52

$hashe = hash('sha256', Bencode::encode($data['info']));
$tracker = ["http://tracker.trackerfix.com:80/announce","udp://9.rarbg.to:2830/announce"];
print $hashe;
require_once (__DIR__ ."/backend/class.scraper.php");
     $scraper = new Scrapeer\Scraper();
     $rat = $scraper->scrape($hashe, $tracker);
print_r($rat);


returns empty array
follow the thread for updates
checkout my project: https://bvlist.com/showthread.php?t=12349
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: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728