Skip to main content

PyAsyncTracker

PyAsyncTracker is an asynchronous library for scraping torrent tracker data. It provides tools to fetch and analyze torrent seeders, leechers, and completed downloads across multiple trackers efficiently using modern asynchronous techniques.

Features

  • Support UDP and HTTP Trackers: Scrapes torrent data from both UDP and HTTP trackers.
  • Asynchronous Operations: Leveraging Python's asyncio for non-blocking I/O.
  • Batch Processing: Supports scraping multiple info hashes across multiple trackers efficiently.
  • Data Analysis Function: Includes utility functions to analyze and summarize scraped data.

Installation

Install PyAsyncTracker using pip:

pip install pyasynctracker

Usage

Scrape Info Hashes

Scrape torrent data asynchronously from multiple trackers for given info hashes.

from pyasynctracker import scrape_info_hashes

async def main():
    info_hashes = ["2b66980093bc11806fab50cb3cb41835b95a0362", "706440a3f8fdac91591d6007c4314f3274317f85"]
    trackers = [
        "http://bttracker.debian.org:6969/announce",
        "udp://tracker.openbittorrent.com:80/announce",
        "udp://tracker.opentrackr.org:1337/announce",
    ]

    results = await scrape_info_hashes(info_hashes, trackers)
    print(results)
    # {
    #   '706440a3f8fdac91591d6007c4314f3274317f85': [
    #       {'tracker_url': 'http://bttracker.debian.org:6969/announce', 'seeders': 168, 'peers': 1, 'complete': 769}, 
    #       {'tracker_url': 'udp://tracker.opentrackr.org:1337/announce', 'seeders': 5, 'peers': 0, 'complete': 20}
    #    ],
    #   '2b66980093bc11806fab50cb3cb41835b95a0362': [
    #       {'tracker_url': 'http://bttracker.debian.org:6969/announce', 'seeders': 1022, 'peers': 2, 'complete': 14920}, 
    #       {'tracker_url': 'udp://tracker.opentrackr.org:1337/announce', 'seeders': 25, 'peers': 0, 'complete': 184}
    #    ]
    # }


# Run the async main function using asyncio
if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Batch Scrape Info Hashes

Batch scrape info hashes based on a structured input of info hashes and their respective trackers. This function groups info hashes by their associated trackers and performs scraping in batches.

from pyasynctracker import batch_scrape_info_hashes

async def main():
    data_list = [
        ("2b66980093bc11806fab50cb3cb41835b95a0362", ["http://bttracker.debian.org:6969/announce"]),
        ("706440a3f8fdac91591d6007c4314f3274317f85", ["udp://tracker.opentrackr.org:1337/announce"])
    ]

    results = await batch_scrape_info_hashes(data_list)
    print(results)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Find Maximum Seeders

Analyze the results from scraping functions to find the maximum number of seeders for each info hash.

from pyasynctracker import find_max_seeders

# Assuming 'results' is populated from the scrape_info_hashes or batch_scrape_info_hashes functions
max_seeders = find_max_seeders(results)
print(max_seeders)

# {'2b66980093bc11806fab50cb3cb41835b95a0362': 1022, '706440a3f8fdac91591d6007c4314f3274317f85': 168}

Contributing

Contributions to PyAsyncTracker are welcome! Please fork the repository and submit pull requests with your proposed changes. Ensure to follow coding standards and write tests for new features.

License

PyAsyncTracker is released under the MIT License. See the LICENSE file for more details.

Metadata

Release files for PyAsyncTracker 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyAsyncTracker 0.3.1
File Size Uploaded
pyasynctracker-0.3.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyAsyncTracker 0.3.1
File Interpreter ABI Platform
pyasynctracker-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / pyasynctracker-0.3.1.tar.gz

Download URL pyasynctracker-0.3.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
48be7dfc37385c97843dd6670ee74cd1f4881d2c27045567aefa803b34291c33
BLAKE2b-256 checksum
How to use checksums
1a3be8073d3a03b507ade52f66d91562a20e03d4148a8074ec34d91c69f4580c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / pyasynctracker-0.3.1-py3-none-any.whl

Download URL pyasynctracker-0.3.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60fa329d1c56c20f7fd7e11b388af3d8ab0e1e183d55c917618c76f70bafcad4
BLAKE2b-256 checksum
How to use checksums
e1da7dfb4b784cd0e7efbb21616a35330e6804e8018d48f80fde22b3e4b63fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page