A simple BitTorrent tracker scraper — query a tracker for the seeds, peers, and completed counts of one or more torrents, over both UDP and HTTP/HTTPS.
Full documentation lives at modbender.in/tracker-scraper.
pip install tracker-scraperfrom tracker_scraper import scrape
results = scrape(
tracker="udp://exodus.desync.com:6969",
hashes=[
"2d88e693eda7edf3c1fd0c48e8b99b8fd5a820b2",
"8929b29b83736ae650ee8152789559355275bd5c",
],
)
print(results)scrape(tracker, hashes) returns a dict of dicts. The key is each torrent info_hash from the hashes argument, and the value is a dict with seeds, peers, and complete:
{
"2d88e693eda7edf3c1fd0c48e8b99b8fd5a820b2": {
"seeds": 34,
"peers": 189,
"complete": 10
}
}Arguments
tracker(str): the announce URL for a tracker (udp://,http://, orhttps://), usually taken directly from the torrent metadata.hashes(list[str]): a list of torrentinfo_hashvalues to query.
Note: HTTP/HTTPS tracker scraping works from version 1.1 onwards. UDP scrapes are limited to 74 hashes per request.
Installing the package also adds a tracker-scraper command that prints results as JSON:
tracker-scraper udp://exodus.desync.com:6969 2d88e693eda7edf3c1fd0c48e8b99b8fd5a820b2Run tracker-scraper --help for all options.
- Python 3.9+
requests,bencode.py
pip install -e ".[test]"
pytestCode originally adapted from the m2t project by Erin Drummond (erindru). Originally written for Python 2.7; updated to Python 3 and requests.