本文整理汇总了Python中Tribler.Core.DownloadConfig.DownloadStartupConfig.set_user_stopped方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadStartupConfig.set_user_stopped方法的具体用法?Python DownloadStartupConfig.set_user_stopped怎么用?Python DownloadStartupConfig.set_user_stopped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.DownloadConfig.DownloadStartupConfig
的用法示例。
在下文中一共展示了DownloadStartupConfig.set_user_stopped方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_torrent_insert
# 需要导入模块: from Tribler.Core.DownloadConfig import DownloadStartupConfig [as 别名]
# 或者: from Tribler.Core.DownloadConfig.DownloadStartupConfig import set_user_stopped [as 别名]
def on_torrent_insert(self, source_str, infohash, name):
"""
Callback function called by the source when a new torrent is discovered
"""
self._logger.debug('Received torrent %s from %s', infohash, source_str)
if source_str not in self.sources:
self._logger.debug('Skipping torrent %s (unknown source %s)', infohash, source_str)
return
# Did we already get this torrent from another source?
if infohash in self.torrents:
self.torrents[infohash].sources.add(source_str)
self._logger.debug('Skipping torrent %s (already known)', infohash)
return
# If a download already exists or already has a checkpoint, skip this torrent
if self.session.get_download(unhexlify(infohash)) or \
os.path.exists(os.path.join(self.session.get_downloads_pstate_dir(), infohash + '.state')):
self._logger.debug('Skipping torrent %s (download already running or scheduled to run)', infohash)
return
if len(self.torrents) >= self.settings.max_torrents_listed:
self._logger.debug('Skipping torrent %s (limit reached)', infohash)
return
self.torrents[infohash] = CreditMiningTorrent(infohash, name)
self.torrents[infohash].sources.add(source_str)
self._logger.info('Starting torrent %s', infohash)
magnet = u'magnet:?xt=urn:btih:%s&dn=%s' % (infohash, name)
dl_config = DownloadStartupConfig()
dl_config.set_hops(self.settings.hops)
dl_config.set_dest_dir(self.settings.save_path)
dl_config.set_credit_mining(True)
dl_config.set_user_stopped(True)
self.session.lm.add(TorrentDefNoMetainfo(unhexlify(infohash), name, magnet), dl_config, hidden=True)