【问题标题】:Torrent Seeding is not working (Libtorrent-Python)Torrent 播种不起作用(Libtorrent-Python)
【发布时间】:2017-09-18 08:28:49
【问题描述】:

我正在尝试生成一个 torrent 并使用 python libtorrent 播种它,它会生成 torrent,但不会播种它。我尝试用几个 Bittorrent 客户端打开生成的磁力链接,但无法下载文件。

我在 Ubuntu 16.04 上使用 libtorrent 1.0.7-1build1 和 Python3.5.2。

我的问题与该问题有关: Python Libtorrent doesn't seed

import sys
import time
import libtorrent as lt

videoFile = "/path/to/video/XXX.mp4"
workingPath = "/path/to/video"

tmpPath = "/tmp"
currentDir = "."

fs = lt.file_storage()
lt.add_files(fs, videoFile)
t = lt.create_torrent(fs)
t.add_tracker("udp://tracker.publicbt.com:80")
t.add_tracker("wss://tracker.openwebtorrent.com")
t.add_tracker("wss://tracker.btorrent.xyz")
t.add_tracker("wss://tracker.fastcast.nz")

t.set_creator("My Torrent")
t.set_comment("Test")
lt.set_piece_hashes(t, workingPath)
torrent = t.generate()

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

ps = lt.proxy_settings()
ps.type = lt.proxy_type.http
ps.hostname = "hostname.de"
ps.port = 1003

ses = lt.session()
ses.listen_on(6881, 6891)
ses.set_proxy(ps)
ses.set_web_seed_proxy(ps)

handle = ses.add_torrent({'ti': lt.torrent_info(torrent), 'save_path': currentDir, 'seed_mode': True, 'upload_mode':True, 'super_seeding':True})

print(lt.make_magnet_uri(lt.torrent_info(torrent)))

while handle.is_seed():
    s = handle.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)

【问题讨论】:

    标签: python seeding torrent libtorrent


    【解决方案1】:

    我有两个问题。首先,我在我的网络服务器中对所有对 https 的 http 请求进行了 URL 重写,因此没有到达端口 6881。 其次,我没有从我的媒体文件所在的目录启动我的脚本。所以把“。”因为“save_path”位置不正确,但应该是媒体文件所在的完整路径。现在工作正常。

    旧:

    handle = ses.add_torrent({'ti': lt.torrent_info(torrent), 'save_path': currentDir, 'seed_mode': True, 'upload_mode':True, 'super_seeding':True})
    

    新:

    handle = ses.add_torrent({'ti': lt.torrent_info(torrent), 'save_path': workingPath, 'seed_mode': True, 'upload_mode':True, 'super_seeding':True})
    

    【讨论】:

      猜你喜欢
      • 2015-01-21
      • 1970-01-01
      • 1970-01-01
      • 2020-01-13
      • 1970-01-01
      • 2021-02-11
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      相关资源
      最近更新 更多