当前位置: 首页>>代码示例>>Python>>正文


Python DownloadStartupConfig.set_channel_download方法代码示例

本文整理汇总了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)
开发者ID:synctext,项目名称:tribler,代码行数:13,代码来源:LaunchManyCore.py

示例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)
开发者ID:Tribler,项目名称:tribler,代码行数:13,代码来源:gigachannel_manager.py

示例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
开发者ID:synctext,项目名称:tribler,代码行数:17,代码来源:LaunchManyCore.py

示例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
开发者ID:Tribler,项目名称:tribler,代码行数:26,代码来源:gigachannel_manager.py


注:本文中的Tribler.Core.DownloadConfig.DownloadStartupConfig.set_channel_download方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。