首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python Libtorrent不是种子

Python Libtorrent不是种子
EN

Stack Overflow用户
提问于 2014-11-23 23:14:20
回答 1查看 812关注 0票数 1

我正在尝试生成一个torrent,并用python libtorrent对其进行播种,它会生成torrent,但不会播种。

我在Ubuntu 14.04上使用libtorrent-0.16.18和Python3.4

代码语言:javascript
复制
import sys
import time
import libtorrent as lt

fs = lt.file_storage()
lt.add_files(fs, "./test.txt")
t = lt.create_torrent(fs)
t.add_tracker("udp://tracker.publicbt.com:80")
t.set_creator("My Torrent")
t.set_comment("Test")
lt.set_piece_hashes(t, ".")
torrent = t.generate()

f = open("mytorrent.torrent", "wb")
f.write(lt.bencode(torrent))
f.close()

ses = lt.session()
ses.listen_on(6881, 6891)
h = ses.add_torrent({'ti': lt.torrent_info(torrent), 'save_path': '/tmp', 'seed_mode': True})

while h.is_seed():
    s = h.status()
    state_str = ['queued', 'checking', 'downloading metadata', \
      'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']

    print('\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
      (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, state_str[s.state]))
    sys.stdout.flush()

    time.sleep(1)
EN

回答 1

Stack Overflow用户

发布于 2014-11-24 15:48:01

可能是因为您从当前工作目录(".")中的文件创建了torrent,但是当您将torrent添加到会话中时,您将/tmp指定为下载目录。/tmp中大概不存在test.txt。如果您将save_path设置为“。相反,它可能会播下种子。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27090466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档