本文整理汇总了Python中Tribler.Core.DownloadConfig.DownloadStartupConfig.set_channel_download方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadStartupConfig.set_channel_download方法的具体用法?Python DownloadStartupConfig.set_channel_download怎么用?Python DownloadStartupConfig.set_channel_download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.DownloadConfig.DownloadStartupConfig
的用法示例。
在下文中一共展示了DownloadStartupConfig.set_channel_download方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updated_my_channel
# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_channel_download [as 别名]
def updated_my_channel(self, new_torrent_path):
"""
Notify the core that we updated our channel.
:param new_torrent_path: path to the new torrent file
"""
# Start the new download
tdef = TorrentDef.load(new_torrent_path)
dcfg = DownloadStartupConfig()
dcfg.set_dest_dir(self.mds.channels_dir)
dcfg.set_channel_download(True)
self.add(tdef, dcfg)
示例2: updated_my_channel
# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_channel_download [as 别名]
def updated_my_channel(self, tdef):
"""
Notify the core that we updated our channel.
"""
with db_session:
my_channel = self.session.lm.mds.ChannelMetadata.get_my_channel()
if my_channel and my_channel.status == COMMITTED and not self.session.has_download(str(my_channel.infohash)):
dcfg = DownloadStartupConfig()
dcfg.set_dest_dir(self.session.lm.mds.channels_dir)
dcfg.set_channel_download(True)
self.session.lm.add(tdef, dcfg)
示例3: download_channel
# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_channel_download [as 别名]
def download_channel(self, channel):
"""
Download a channel with a given infohash and title.
:param channel: The channel metadata ORM object.
"""
finished_deferred = Deferred()
dcfg = DownloadStartupConfig()
dcfg.set_dest_dir(self.mds.channels_dir)
dcfg.set_channel_download(True)
tdef = TorrentDefNoMetainfo(infohash=str(channel.infohash), name=channel.title)
download = self.session.start_download_from_tdef(tdef, dcfg)
channel_id = channel.public_key
download.finished_callback = lambda dl: self.on_channel_download_finished(dl, channel_id, finished_deferred)
return download, finished_deferred
示例4: download_channel
# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_channel_download [as 别名]
def download_channel(self, channel):
"""
Download a channel with a given infohash and title.
:param channel: The channel metadata ORM object.
"""
dcfg = DownloadStartupConfig()
dcfg.set_dest_dir(self.session.lm.mds.channels_dir)
dcfg.set_channel_download(True)
tdef = TorrentDefNoMetainfo(infohash=str(channel.infohash), name=channel.dir_name)
download = self.session.start_download_from_tdef(tdef, dcfg)
def on_channel_download_finished(dl):
channel_dirname = os.path.join(self.session.lm.mds.channels_dir, dl.get_def().get_name())
self.session.lm.mds.process_channel_dir(channel_dirname, channel.public_key, external_thread=True)
self.session.lm.mds._db.disconnect()
def _on_failure(failure):
self._logger.error("Error when processing channel dir download: %s", failure)
finished_deferred = download.finished_deferred.addCallback(
lambda dl: deferToThread(on_channel_download_finished, dl))
finished_deferred.addErrback(_on_failure)
return download, finished_deferred