


Friends who often watch movies must be familiar with BT seeds, but BT seed files are inconvenient to store compared to magnet links, and storing BT files on a website can easily cause copyright disputes, while magnet links are relatively less risky.
Converting BT seeds to magnet links that take up less space and are more convenient for sharing has great benefits.
Today we will take a look at how to convert seeds into magnet links. The solution is to use python’s bencode module, which is relatively simple to use.
First of all, you need to install this module. The installation command is:
pip install bencode
If you have not installed pip, please Move to "Detailed explanation of pip installation of python package manager"
Practical code
After the installation is completed, let's take a look at the code:
System environment: Linux
Python environment: Python2.7
Please pay attention to the python version
bt2url.py #! /usr/local/bin/python # @desc python通过BT种子生成磁力链接 # @date 2015/11/10 # @author pythontab.com import bencode import sys import hashlib import base64 import urllib #获取参数 torrentName = sys.argv[1] #读取种子文件 torrent = open(torrentName, 'rb').read() #计算meta数据 metadata = bencode.bdecode(torrent) hashcontents = bencode.bencode(metadata['info']) digest = hashlib.sha1(hashcontents).digest() b32hash = base64.b32encode(digest) #打印 print 'magnet:?xt=urn:btih:%s' % b32hash
How to use?
Command:
python bt2url.py test.torrent
Result:
magnet:?xt=urn:btih:MWXFHXOGE2UMR7WBFZYEJPM3LF2VIHNH

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
