本文整理匯總了Python中tracker.Tracker.download_torrent方法的典型用法代碼示例。如果您正苦於以下問題:Python Tracker.download_torrent方法的具體用法?Python Tracker.download_torrent怎麽用?Python Tracker.download_torrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.download_torrent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Cloud
# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import download_torrent [as 別名]
#.........這裏部分代碼省略.........
return True
else:
return False
def get_files(self, torr_hash_l):
"""
Download our files, given a torrent's info hash (string) or a list of torrent info hashes (strings). Used by the get() function to pull down data
files from the cloud.
Parameters
torr_hash_l: string, or list of strings
"""
self.session.serve_torrent_by_hash(torr_hash_l, self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, self.ext)
def serve_torrents(self):
"""
Serve up all torrents in our torr directory. Does not take any parameters, simply checks for all torrents
in our torrent meta data directory, and serves them.
"""
self.session.serve_all_torrents(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, self.ext)
def get_torrents(self, torr_hash_l):
"""
Pull a torrent down from the tracker by ID.
Parameter
torr_hash_l: list or string of info hashes of torrents to download from the tracker.
"""
flag = 0
if hasattr(torr_hash_l, '__iter__'):
for t in torr_hash_l:
torr_loc = self.my_tracker.download_torrent(t, self.torr_dir)
if not torr_loc:
log.debug("Multiple Torr ID's: unable to get torrent location.")
flag = 1
else:
torr_loc = self.my_tracker.download_torrent(torr_hash_l, self.torr_dir)
if not torr_loc:
log.debug("Single ID: unable to get torrent location.")
flag = 1
if flag:
return False
else:
return True
# Mark for removal ?
def get_files_by_torr_name(self, torr_name_l):
"""
Download files given a torrent file name. This function will likely be going away as it's not part of our workflow at the moment.
Parameters
torr_name_l: string or list of torrent info hashes
"""
# setup our TorrentMetaInfo object and create a torrent
if hasattr(torr_name_l, '__iter__'):
for t in torr_name_l:
ti = TorrentMetaInfo(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, torr_file=t)
self.session.serve(ti)
else:
ti = TorrentMetaInfo(self.torr_dir, self.data_dir, self.my_tracker.tracker_ip, torr_file=torr_name_l)
self.session.serve(ti)