2015-06-23 5 views
18

से धार डाउनलोड नहीं कर सकता मैं टोरेंट डाउनलोड करने के लिए पाइथन में libtorrent मॉड्यूल का उपयोग कर रहा हूं। मैं एक निजी ट्रैकर से धार डाउनलोड कर सकता हूं लेकिन सार्वजनिक से नहीं। मैंने विभिन्न टोरेंटों का उपयोग करने की कोशिश की, जिसे मैं "ट्रांसमिशन" का उपयोग करके डाउनलोड कर सकता हूं। मैंने इसे 4 अलग-अलग कनेक्शनों के खिलाफ चेक किया, वही।मैं सार्वजनिक ट्रैकर libtorrent

def downloadTorrent(torrent): 
    """ 
    Download torrent using libtorrent library. 
    Torrent will be stored at the current directory. 
    """ 
    ses = lt.session() 
    ses.listen_on(6881, 6891) 

    info = lt.torrent_info(torrent) 
    h = ses.add_torrent({'ti': info, 'save_path': './'}) 
    ses.start_dht() 
    print 'starting', h.name() 

    while (not 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) 

    print h.name(), 'complete' 

जब मैं कोशिश मुझे मिलता है:

0.00% complete (down: 0.0 kb/s up: 0.0 kB/s peers: 0) downloading 

और यह यहीं समाप्त।

मुझे नहीं पता कि यह मदद करता है, लेकिन निजी ट्रैकर http का उपयोग कर रहा है और udp नहीं है, और यह डीएचटी की अनुमति नहीं देता है।

+3

जब आप कोशिश करते हैं तो क्या होता है? क्या आपको कोई त्रुटि मिलती है जिसमें आप अपने प्रश्न में शामिल हो सकते हैं? – khagler

+0

यह किसी भी सहकर्मी से कनेक्ट नहीं है। – Chaker

+1

क्या ट्रैकर वास्तव में काम करता है ?! यहां सूचीबद्ध सूची में ट्रैकर्स आज़माएं: http://coppersurfer.tk/ पुराने सार्वजनिक ट्रैकर्स में से कई अब और काम नहीं करते हैं। – Encombe

उत्तर

1

आप वास्तव में यह नहीं बताते कि आप अपने downloadTorrent फ़ंक्शन में टोरेंट फ़ाइल कैसे प्रदान करते हैं। आपका फ़ंक्शन काम करता है अगर आपने अपने कंप्यूटर पर पहले से ही टोरेंट फ़ाइल डाउनलोड की है।

import libtorrent as lt 
import urllib2 

public_torrent = 'http://releases.ubuntu.com/14.04.3/ubuntu-14.04.3-desktop-amd64.iso.torrent' 

def downloadTorrent(torrent_url): 
    """ 
    Download torrent using libtorrent library. 
    Torrent will be stored at the current directory. 
    """ 
    ses = lt.session() 
    ses.listen_on(6881, 6891) 

    # read torrent file as bytes 
    torrent = lt.bdecode(urllib2.urlopen(torrent_url, 'rb').read()) 

    info = lt.torrent_info(torrent) 
    h = ses.add_torrent({'ti': info, 'save_path': './'}) 
    ses.start_dht() 
    print 'starting', h.name() 

    while (not 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) 

    print h.name(), 'complete' 

downloadTorrent(public_torrent) 
:

आप इस समारोह के लिए एक तर्क के रूप में एक धार यूआरएल प्रदान करना चाहते हैं, तो आप के रूप में इस torrent = lt.bdecode(urllib2.urlopen(torrent_url, 'rb').read())

तरह बाइट्स यहाँ पूर्ण कोड है कि अजगर 2.7 के साथ काम करता है http प्रतिक्रिया पढ़ने की जरूरत है

संबंधित मुद्दे