本文整理汇总了Python中BaseLib.Core.TorrentDef.TorrentDef.set_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDef.set_metadata方法的具体用法?Python TorrentDef.set_metadata怎么用?Python TorrentDef.set_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseLib.Core.TorrentDef.TorrentDef
的用法示例。
在下文中一共展示了TorrentDef.set_metadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testECreateRichTorrents
# 需要导入模块: from BaseLib.Core.TorrentDef import TorrentDef [as 别名]
# 或者: from BaseLib.Core.TorrentDef.TorrentDef import set_metadata [as 别名]
def testECreateRichTorrents(self):
_log.info("Create rich metadata torrents ------------")
if not TestMetaGenerator.run_test:
_log.debug("Test avoided.")
return
data = None
self.assertTrue(TestMetaGenerator.data != None, "Test E depends on data gathered in test D, set testD attribute to True")
if TestMetaGenerator.data != None:
data = TestMetaGenerator.data
else:
return
rmg = RichMetadataGenerator.getInstance()
torrents = []
for k, v in data.items():
if v.content_base != None:
# Choose only a small subset of content to download
if v.content_base == "http://www.rtvslo.si/podcasts/gori_doli_naokoli.xml":
mm_file = tempfile.NamedTemporaryFile()
try:
urllib.urlretrieve(v.id, mm_file.name)
torrent_def = TorrentDef()
torrent_def.add_content(mm_file.name)
torrent_def.set_tracker("http://wanabe.a.tracker.com:8080")
torrent_def.set_metadata(k)
torrent_def.finalize()
torrent_def.save(mm_file.name + ".torrent")
torrents.append(mm_file.name + ".torrent")
except Exception, e:
_log.error("Failed to generate torrent file, reason: " + str(e))