How to know the number of seeds/peers for a torrent in PHP

kasrsf picture kasrsf · May 19, 2010 · Viewed 12.8k times · Source

When you place a .torrent file for download in your website, how can you get the number of Seeds & Peers for that Torrent and inform the user of them?

Answer

baloo picture baloo · May 19, 2010

You have to contact the tracker(s) that is shown in the torrentfile. If the tracker support "scraping" that is probably the request you want. Otherwise its up to the tracker to decide how many peers it wants to return to you, and you have no idea if those peers is a seed or leech before contacting them.

The torrentfile is in bencoded format, look for the bdecode php library to easily parse the info.

Provide the infohash you get from the pieces information in the metadata and the tracker will respond if you follow the protocol, read http://en.wikipedia.org/wiki/BitTorrent_%28protocol%29 for more information