将bittorrent磁铁链接转换为.torrent文件。

magnet2torrent的Python项目详细描述


Magnet2Torrent公司

纯python项目,将磁铁链接转换为.torrent文件。 我们的目标是尽快完成。在

入门

安装

pip install magnet2torrent

用法

下载ubuntu iso torrent。在

^{pr2}$

作为HTTP服务器运行。在

magnet2torrent serve

将其作为启用了许多功能的HTTP服务器运行。在

magnet2torrent --use-dht --dht-state-file dht.state --torrent-cache-folder torcache serve --apikey secretkey

从python使用

importasynciofrommagnet2torrentimportMagnet2Torrent,FailedToFetchExceptionasyncdeffetch_that_torrent():m2t=Magnet2Torrent("magnet:?xt=urn:btih:e2467cbf021192c241367b892230dc1e05c0580e&dn=ubuntu-19.10-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")try:filename,torrent_data=awaitm2t.retrieve_torrent()exceptFailedToFetchException:print("Failed")asyncio.run(fetch_that_torrent())

如果要使用DHT进行检索,则必须引导并运行它。在

importasyncioimportosfrommagnet2torrentimportMagnet2Torrent,FailedToFetchException,settingsDHT_STATE_FILE="/tmp/dht.state"asyncdefstart_dht():ifos.path.exists(DHT_STATE_FILE):dht_server=DHTServer.load_state(DHT_STATE_FILE)awaitdht_server.listen(settings.DHT_PORT)else:dht_server=DHTServer()awaitdht_server.listen(settings.DHT_PORT)awaitdht_server.bootstrap(settings.DHT_BOOTSTRAP_NODES)returndht_serverasyncdeffetch_that_torrent(dht_server):m2t=Magnet2Torrent("magnet:?xt=urn:btih:e2467cbf021192c241367b892230dc1e05c0580e&dn=ubuntu-19.10-desktop-amd64.iso",dht_server=dht_server)try:filename,torrent_data=awaitm2t.retrieve_torrent()exceptFailedToFetchException:print("Failed")dht_server=asyncio.run(start_dht())asyncio.run(fetch_that_torrent(dht_server))dht_server.save_state(DHT_STATE_FILE)

许可证

这个项目是在麻省理工学院许可下授权的-有关详细信息,请参阅LICENSE.md文件

DHT部分从bmueller/kademlia派生-它的许可证可以是 在dht文件夹或原始项目中找到。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
加密如何在Java中使用Skipjack(skip32)将数据库中的顺序整数随机化   java Android在两个活动之间传递数据获取NullPointerException   在构造函数中传递的java上下文显示错误   java将密钥添加到选定的密钥集   javascript为什么带有特殊字符的字符串在GET和POST方法中的行为不同?   java将反射。方法创建一个函数接口   设置Javasocket的端口   java通过一次按键调用MenuItem   java和引擎加载图形:为什么我的背景纹理很小,而且是颠倒的   如何将UV纹理从blender加载到opengl 安卓 java   跨Java虚拟机实现的jvm Java toString表示?   spring在Java服务器页面的上下文中这叫什么?