【发布时间】:2015-11-25 02:34:19
【问题描述】:
也许我误解了 .torrent 文件的工作原理,但是在 python 中是否有办法下载实际引用的 content .torrent 文件指向的文件将使用 torrent 客户端下载,例如作为 utorrent,但从 shell/命令行使用 python?
以下内容仅用于下载 .torrent 文件并确保我可以打开 torrent 客户端以及下载 .torrent,但我宁愿在命令行中简化流程。似乎在网上找不到太多关于这样做的信息...
torrent = torrentutils.parse_magnet(magnet)
infohash = torrent['infoHash']
session = requests.Session()
session.headers.update({'User-Agent': 'Mozilla/5.0'})
url = "http://torcache.net/torrent/" + infohash + ".torrent"
answer = session.get(url)
torrent_data = answer.content
buffer = BytesIO(torrent_data)
gz = gzip.GzipFile(fileobj = buffer)
output = open(torrent['name'], "wb")
output.write(torrent_data)
据我所知,我不能在 64 位 Windows 操作系统上使用 libtorrent for python3。
【问题讨论】:
-
然后使用 32 位 python - python3 win32 有官方构建的 libtorrent 包。是的,x64-package 没有维护者,但您可以尝试自己构建它。
标签: python python-3.x bittorrent libtorrent