當前位置: 首頁>>代碼示例>>Python>>正文


Python libtorrent.add_magnet_uri方法代碼示例

本文整理匯總了Python中libtorrent.add_magnet_uri方法的典型用法代碼示例。如果您正苦於以下問題:Python libtorrent.add_magnet_uri方法的具體用法?Python libtorrent.add_magnet_uri怎麽用?Python libtorrent.add_magnet_uri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在libtorrent的用法示例。


在下文中一共展示了libtorrent.add_magnet_uri方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _add_magnet_link_to_downloads

# 需要導入模塊: import libtorrent [as 別名]
# 或者: from libtorrent import add_magnet_uri [as 別名]
def _add_magnet_link_to_downloads(self, magnet_link):
        magnet_hash = get_hash(magnet_link)
        h = libtorrent.add_magnet_uri(
            self.session,
            magnet_link,
            dict(save_path=os.path.join(self.download_dir, magnet_hash)),
        )
        files = get_torrent_info(h).files()
        prioritize_files(h, [0] * len(files))
        self.torrents[magnet_hash] = h
        return h 
開發者ID:hauxir,項目名稱:rapidbay,代碼行數:13,代碼來源:torrent.py

示例2: get_torrent_info_magnet

# 需要導入模塊: import libtorrent [as 別名]
# 或者: from libtorrent import add_magnet_uri [as 別名]
def get_torrent_info_magnet(v1, v3, u, p_bar, tmp_dir):
    global handle, ses, info, count, count_limit, file_name, ui, progress, tmp_dir_folder
    ui = u
    progress = p_bar
    tmp_dir_folder = tmp_dir
    progress.setValue(0)
    progress.show()
    sett = lt.session_settings()
    sett.user_agent = 'qBittorrent v3.3.5'
    sett.always_send_user_agent = True
    fingerprint = lt.fingerprint('qB', 3, 3, 5, 0)
    ses = lt.session(fingerprint)

    ses.listen_on(40000, 50000)
    ses.set_settings(sett)

    handle = lt.add_magnet_uri(ses, v1, {'save_path':v3})
    i = 0
    while (not handle.has_metadata()):
        time.sleep(1)
        i = i+1
        print('finding metadata {0}'.format(i))
        if i > 300:
            print('No Metadata Available: {0}s'.format(i))
            break
    info = handle.get_torrent_info()

    handle.set_sequential_download(True)
    print(handle.trackers())

    return handle, ses, info 
開發者ID:kanishka-linux,項目名稱:kawaii-player,代碼行數:33,代碼來源:stream.py

示例3: downloadtorrent

# 需要導入模塊: import libtorrent [as 別名]
# 或者: from libtorrent import add_magnet_uri [as 別名]
def downloadtorrent(link):
    try:
        params = {
            'save_path' : savePath,
            'storage_mode': lt.storage_mode_t(2),
            'paused': False,
            'auto_managed': True,
            'duplicate_is_error': True
        }

        #Inicia o Download
        ses = lt.session()
        ses.listen_on(6881, 6891)
        handle = lt.add_magnet_uri(ses, link, params)
        ses.start_dht()

        
        while (not handle.has_metadata()):
            time.sleep(1)
        
        while (handle.status().state != lt.torrent_status.seeding):
            s = handle.status()
            

            time.sleep(5)
            
    except:
        pass 
開發者ID:msfidelis,項目名稱:TorrentRSSDownloader,代碼行數:30,代碼來源:Torrent-Downloader.py

示例4: fetch_torrent

# 需要導入模塊: import libtorrent [as 別名]
# 或者: from libtorrent import add_magnet_uri [as 別名]
def fetch_torrent(session, ih, timeout):
    name = ih.upper()
    url = 'magnet:?xt=urn:btih:%s' % (name,)
    params = {
        'save_path': '/tmp/downloads/',
        'storage_mode': lt.storage_mode_t(2),
        'paused': False,
        'auto_managed': False,
        'duplicate_is_error': True}
    try:
        handle = lt.add_magnet_uri(session, url, params)
    except Exception:
        return None
    handle.set_sequential_download(1)
    meta = None
    down_path = None
    for i in range(0, timeout):
        if handle.has_metadata():
            info = handle.get_torrent_info()
            down_path = '/tmp/downloads/%s' % info.name()
            meta = info.metadata()
            break
        time.sleep(1)
    if down_path and os.path.exists(down_path):
        os.system('rm -rf "%s"' % down_path)
    session.remove_torrent(handle)
    return meta 
開發者ID:xgfone,項目名稱:snippet,代碼行數:29,代碼來源:ItMetadata.py

示例5: init_handle

# 需要導入模塊: import libtorrent [as 別名]
# 或者: from libtorrent import add_magnet_uri [as 別名]
def init_handle(self):
        params = {
            "save_path": self.settings.save_path,
            "allocation": storage_mode_t.storage_mode_sparse,
            }
        self.session = session()
        self.handle = add_magnet_uri(self.session, str(self.magnet), params)

        up_limit = self.settings.limits.upload
        if up_limit:
            self.handle.set_upload_limit(up_limit)
        down_limit = self.settings.limits.download
        if down_limit:
            self.handle.set_download_limit(down_limit) 
開發者ID:touchandgo-devs,項目名稱:touchandgo,代碼行數:16,代碼來源:__init__.py


注:本文中的libtorrent.add_magnet_uri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。