def magnet2torrent(id, info_hash):
info_hash_id=id
磁铁="磁铁:?xt=urn:btih:"+info_hash
ses = lt.session()
参数 = {
'save_path': './',
'duplicate_is_error':是的,
'storage_mode': lt.storage_mode_t(2),
“暂停”:错误,
'auto_managed':是的,
'duplicate_is_error':真
}
句柄 = lt.add_magnet_uri(ses, 磁铁, 参数)
print("正在下载元数据(这可能需要一段时间)")
我 = 0;
而(不是handle.has_metadata()):
# i = i+1
如果我 > 300 :
返回
睡觉(1)
ses.pause()
打印(“完成”)
torinfo = handle.get_torrent_info()
con = db.get_conncetion()
cur = con.cursor()
对于 torinfo 中的 f:
cur.execute("INSERT INTO file_list (info_hash_id, name, size) VALUES (\""+str(info_hash_id)+"\", \""+str(f.path)+"\", "+str(f .size)+");")
print("INSERT INTO file_list (info_hash_id, name, size) VALUES (\""+str(info_hash_id)+"\", \""+str(f.path)+"\", "+str(f.size )+");")
con.commit()
cur.close()
con.close()
我想如果我可以从 info_hash 中获取 torrent 文件,那么我可以从 torrent 文件中获取文件列表。
但是当我运行我的代码时
而(不是handle.has_metadata()):没有结束。但是像http://magnet2torrent.com这样的网页会立即给我种子
如何从 info_hash 中获取文件列表?