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
评论列表
文章目录