Jump to content

Extracting Data From A Torrent File (HELP!!)


jj20051

Recommended Posts

Alright for the fun of it I decided to make a bet with a friend that I could make a clone of mininova (a torrent site). Now I realized right off the bat that I'd have to figure out how to read a torrent file to extract the title, seeds, leachers and the size of the file to be downloaded. I'm pretty sure this can be done with PHP but I'm just not sure how. Can anyone help me?  :confused:

 

I'm posting this before I get to far into the project to ensure I can have this ready to go before I'm finished with the rest of the site.

Link to comment
Share on other sites

You would look at preg_match or substr to accomplish extracting data, assuming it's plaintext. You can apply it like this:

$torrent_file = file_get_contents('./torrents/example.torrent');
preg_match("/seeds/", $torrent_file); //Just an example

If there are delimiters you can use explode which may be easier as it'll put it into an array..

Link to comment
Share on other sites

While that didn't extract what I wanted it to it seems that in order to extract the seeds and leechers the PHP file would have to connect to the tracker and ask the tracker for the data. The problem is I'm not sure how i'd pull that off correctly. I realize i'd have to use cURL. Aside from that I'm lost.

Link to comment
Share on other sites

A torrent file is not plain text, it's in a special format. I think there is a PHP class to parse them but I can't remember the name of it.

 

Also, just a quick FYI, seeders and leachers are not listed in the torrent file. It simply holds a session hash that the torrent client sends to the tracker. The tracker is what responds to the torrent client with the seeders and leachers list.

Link to comment
Share on other sites

Also, just a quick FYI, seeders and leachers are not listed in the torrent file. It simply holds a session hash that the torrent client sends to the tracker. The tracker is what responds to the torrent client with the seeders and leachers list.

 

Meant to mention that, thanks...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.