本文整理汇总了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
示例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
示例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
示例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
示例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)