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

前端 未结 2 949
礼貌的吻别
礼貌的吻别 2021-02-20 07:16

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?

2条回答
  •  攒了一身酷
    2021-02-20 07:35

    You would scrape the tracker by sending an HTTP GET request to it with a URL formed as described at http://wiki.theory.org/BitTorrentSpecification#Tracker_.27scrape.27_Convention -- the scrape URL is derived from the announce URL(s) in the metainfo's "announce" and "announce-list" keys.

    The tracker's response is described in that same wiki.theory.org link. It includes the seeder/leecher counts that you're looking for.

    Note that modern .torrent files typically have several trackers included in their announce-list, so you may want to scrape more than one for better information. However you've got no way of knowing which peers overlap from tracker A to tracker B, so the best you can really do from scraping multiple trackers is to come up with a range of the minimum/maximum number of leechers and seeders in the swarm.

提交回复
热议问题