本文整理汇总了Python中BaseLib.Core.TorrentDef.TorrentDef.get_tracker方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDef.get_tracker方法的具体用法?Python TorrentDef.get_tracker怎么用?Python TorrentDef.get_tracker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseLib.Core.TorrentDef.TorrentDef
的用法示例。
在下文中一共展示了TorrentDef.get_tracker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_torrent
# 需要导入模块: from BaseLib.Core.TorrentDef import TorrentDef [as 别名]
# 或者: from BaseLib.Core.TorrentDef.TorrentDef import get_tracker [as 别名]
def create_torrent(file, port, try_vod = True):
'''
Creates a torrent for the given file. Returns a string representing the
path to the torrent file.
If try_vod is True try to add the playtime to the torrent making it "streamable".
'''
# generate torrent
tdef = TorrentDef()
url = "http://localhost:%s/announce/" % port
tdef.set_tracker(url)
#tdef.set_create_merkle_torrent(True)
#tdef.set_piece_length(self._pieceSize)
if try_vod:
torrent_name = FileUtils.get_relative_filename(file) + constants.TORRENT_VOD_EXT
# set playtime
playtime = videostats_via_ffmpeg(file)['playtime']
print "playtime", playtime
else:
torrent_name = FileUtils.get_relative_filename(file) + constants.TORRENT_DOWNLOAD_EXT
playtime = None
print "Create a non-streamable torrent"
tdef.add_content(file, playtime=playtime)
tdef.finalize()
torrent_dir = os.getcwd()
torrent = os.path.join(torrent_dir, torrent_name)
tdef.save(torrent)
print "created torrent file: %s" % torrent
print "Tracker uses the announce URL: %s" % tdef.get_tracker()
return tdef