将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的遗传算法确定最优交易行为   java改型2.0无法解析Json嵌套对象   java在数组中查找最大额定值(数字),我们不能跳过数组中的一个或多个连续数字   java在spring boot中从命令行设置活动概要文件和配置位置   JavaAxis2:传输错误:404错误:未找到帮助理解其真正含义   java使用Play2WAR和Play2.2.1   java理解函数运算符:Lambda   在代理java后面读取https网页数据   java应用程序。Android单元测试中的类mock   java为什么onClick布局XML引用的方法需要是公共的?   从SMTLIB2文件解析的java显示声明   java重写给定的类以使用组合而不是继承   HTMLUnit和Java:NoSuchMethodException:createDefaultSSLContext()   java如何使用Spring和ThymeLeaf从前端正确更新后端中的对象?   来自init()Java的方法调用   使用cellrendering从数据库向JTable动态添加数据后,java无法使用JTable执行排序操作   java Android Studio 1.5.1。渲染错误(浮动操作按钮)   web服务如何使用UsenameToken和PasswordDigest为JAVA中的SOAP客户端附加wsse安全头   java为什么要在局部变量和myApplicationClass中同时删除“ArrayList.remove”?