def find_task_by_url_or_path(tasks, url): if is_url(url): return find_task_by_url(tasks, url) elif is_local_bt(url): return find_task_by_url(tasks, 'bt://' + lixian_hash_bt.info_hash(url)) else: raise NotImplementedError()
def __init__(self, base, x): super(LocalBtQuery, self).__init__(base) self.path = x self.hash = lixian_hash_bt.info_hash(self.path) self.task = self.base.find_task_by_hash(self.hash) with open(self.path, 'rb') as stream: self.torrent = stream.read()
def __init__(self, base, x): super(LocalBtQuery, self).__init__(base) self.path = x self.hash = lixian_hash_bt.info_hash(self.path) self.task = self.base.find_task_by_hash(self.hash) with open(self.path, "rb") as stream: self.torrent = stream.read()