當前位置: 首頁>>代碼示例>>Python>>正文


Python TorrentDef.get_tracker方法代碼示例

本文整理匯總了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
開發者ID:gvsurenderreddy,項目名稱:smoothit-client,代碼行數:37,代碼來源:create_torrent.py


注:本文中的BaseLib.Core.TorrentDef.TorrentDef.get_tracker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。