2017-04-21 1 views
0

私はトレントを生成し、それをパイソンlibtorrentでシードしようとしていますが、それはトレントを生成しますが、シードしません。私はいくつかのBittorrentクライアントで生成された磁気リンクを開こうとしましたが、ファイルをダウンロードすることはできません。トレントシードがうまくいかない(Libtorrent-Python)

私はUbuntu 16.04でPython3.5.2でlibtorrent 1.0.7-1build1を使用しています。

私の質問は、その問題に関連している: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) 

答えて

0

は、私は2つの問題がありました。まず、私のウェブサーバでhttpsへのすべてのhttpリクエストに対してURLの書き換えが行われたので、ポート6881に到達しませんでした。 2番目に、自分のメディアファイルがあるディレクトリからスクリプトを開始しませんでした。だから "。" '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}) 
関連する問題