2017-04-21 20 views
0

토런트를 생성하고 파이썬 libtorrent로 시드하려고 시도하지만 토런트를 생성하지만 시드하지 않습니다. 여러 BitTorrent 클라이언트에서 생성 된 자기 링크를 열려고했지만 파일을 다운로드 할 수 없습니다.토런트 시드가 작동하지 않습니다 (Libtorrent-Python)

저는 libntorrent 1.0.7-1build1을 Python3.5.2와 함께 Ubuntu 16.04에서 사용하고 있습니다.

내 질문은 그 문제와 관련되어 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

나는 두 가지 문제가 있었다. 첫째, 웹 서버에서 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})