本文整理匯總了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))