Skip to main content

A module for decoding and encoding magnet URIs.

Project description

Magnet Parser

A Python library for parsing magnet links and extracting their components, designed to simplify interactions with torrent files.

Table of Contents

Introduction

The Magnet Parser library allows users to decode magnet links, extracting essential metadata such as the info hash, name, and tracker URLs. This functionality is particularly useful for applications that manage or interact with torrent files, enabling seamless integration with torrent clients.

Installation

To install the magnet_parser library, you can use pip:

pip install magnet-parser
from magnet_parser import *

# Example magnet link
magnet_link = "magnet:?xt=urn:btih:93014BF4D458EC39A16C7D3615E3CFBAE42144CC&dn=Winged+Migration+%282001%29+720p+BluRay&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2F47.ip-51-68-199.eu%3A6969%2Fannounce"

# Decode the magnet link
decoded = magnet_decode(magnet_link)

# Access the decoded information
print(decoded.__dict__)

Output expected

{
    'xt': 'urn:btih:93014BF4D458EC39A16C7D3615E3CFBAE42144CC',
    'info_hash': '93014bf4d458ec39a16c7d3615e3cfbae42144cc',
    'name': 'Winged Migration (2001) 720p BluRay',
    'tr': [
        'http://p4p.arenabg.com:1337/announce',
        'udp://47.ip-51-68-199.eu:6969/announce',
        'udp://9.rarbg.me:2780/announce',
        ...
    ],
    ...
}

Examples

Example 1: Basic Magnet Link

magnet_link = "magnet:?xt=urn:btih:ABC1234567890&dn=Example+File"
decoded = magnet_decode(magnet_link)
print(decoded.name)  # Output: Example File

Example 2: Magnet Link with Multiple Trackers

magnet_link = "magnet:?xt=urn:btih:DEF9876543210&dn=Another+Example&tr=udp://tracker.example.com:80/announce&tr=http://tracker.example.org:80/announce"
decoded = magnet_decode(magnet_link)
print(decoded.tr)  # Output: ['udp://tracker.example.com:80/announce', 'http://tracker.example.org:80/announce']

just for you to know,

this readme.md file generated with AI chatbot helps, with a few Adjustments from me, for you to getting started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magnet_parser-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

magnet_parser-0.1.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file magnet_parser-0.1.1.tar.gz.

File metadata

  • Download URL: magnet_parser-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for magnet_parser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc3f1d39b8bdd24119f6d4dccb50f9dad7b1dd527b79ecfac1c13fae110bca68
MD5 12e52174e3d711f3efc636bca04b3ad1
BLAKE2b-256 b9511bf542bbbcc36732ec916a5ad9d59827edc5154c761aed510f7f2db56a4e

See more details on using hashes here.

File details

Details for the file magnet_parser-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for magnet_parser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ed878312d39e69cc8981512484da51e457d80d054fc0f80be331057aa4c24b
MD5 d28529b7d60d4e98d0a234ccfc25486b
BLAKE2b-256 e5c77fa4418e2754e1c508320ab051d2530a643c8f0da197ed3687d7df6baa32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page