utils.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:libpth 作者: pthcode 项目源码 文件源码
def make_torrent(path, passkey, output_dir=None):
    '''
    Creates a torrent suitable for uploading to PTH.

    - `path`: The directory or file to upload.
    - `passkey`: Your tracker passkey.
    - `output_dir`: The directory where the torrent will be created. If unspecified, {} will be used.
    '''.format(tempfile.tempdir)
    if output_dir is None:
        output_dir = tempfile.tempdir

    torrent_path = tempfile.mktemp(dir=output_dir, suffix='.torrent')
    torrent = metafile.Metafile(torrent_path)
    announce_url = 'https://please.passtheheadphones.me/{}/announce'.format(passkey)
    torrent.create(path, [announce_url], private=True, callback=_add_source)
    return torrent_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号