本文整理汇总了Python中libtorrent.version方法的典型用法代码示例。如果您正苦于以下问题:Python libtorrent.version方法的具体用法?Python libtorrent.version怎么用?Python libtorrent.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libtorrent
的用法示例。
在下文中一共展示了libtorrent.version方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_torrent
# 需要导入模块: import libtorrent [as 别名]
# 或者: from libtorrent import version [as 别名]
def generate_torrent(incl_file: pathlib.Path, resource_hash: str) -> dict:
"""Generate torrent file for a given file and write it to disk
:param pathlib.Path incl_file: file to include in torrent
:param str resource_hash: resource hash
:rtype: tuple
:return: (torrent file as pathlib, torrent file data sha1 hash)
"""
fs = libtorrent.file_storage()
libtorrent.add_files(fs, str(incl_file))
tor = libtorrent.create_torrent(fs)
tor.set_creator('libtorrent {}'.format(libtorrent.version))
libtorrent.set_piece_hashes(tor, str(incl_file.parent))
torrent = tor.generate()
torrent_data = libtorrent.bencode(torrent)
fp = _TORRENT_DIR / '{}.torrent'.format(resource_hash)
with fp.open('wb') as f:
f.write(torrent_data)
return fp, hashlib.sha1(torrent_data).hexdigest()
示例2: make_torrent
# 需要导入模块: import libtorrent [as 别名]
# 或者: from libtorrent import version [as 别名]
def make_torrent(path, save):
fs = lt.file_storage()
lt.add_files(fs, path)
if fs.num_files() == 0:
print 'no files added'
sys.exit(1)
input = os.path.abspath(path)
basename = os.path.basename(path)
t = lt.create_torrent(fs, 0, 4 * 1024 * 1024)
t.add_tracker("http://10.0.1.5:8760/announce")
t.set_creator('libtorrent %s' % lt.version)
lt.set_piece_hashes(t, os.path.split(input)[0], lambda x: sys.stderr.write('.'))
sys.stderr.write('\n')
save = os.path.dirname(input)
save = "%s/%s.torrent" % (save, basename)
f=open(save, "wb")
f.write(lt.bencode(t.generate()))
f.close()
print "the bt torrent file is store at %s" % save
示例3: main
# 需要导入模块: import libtorrent [as 别名]
# 或者: from libtorrent import version [as 别名]
def main():
parser = argparse.ArgumentParser(
description="Command line tool to watch torrents")
parser.add_argument("name", help="The name of the series or movie")
parser.add_argument("season_number", default=None, nargs="?", type=int,
help="Season number")
parser.add_argument("episode_number", default=None, nargs="?", type=int,
help="Episode number")
parser.add_argument("--sub", nargs='?', default=None,
help="Subtitle language")
parser.add_argument("--serve", action="store_true",
help="Do not run VLC")
parser.add_argument("--quality", nargs='?', default=None,
help="quality of the video [normal|hd|fullhd]")
parser.add_argument("--daemon", action="store_true",
help="Daemonize the process"),
parser.add_argument("--port", "-p", default="8888",
help="The port where the stream will be served")
parser.add_argument("--verbose", action="store_true", default=None,
help="Show _all_ the logs")
parser.add_argument("--player", default='vlc',
help="Player to use. vlc|omxplayer|chromecast")
parser.add_argument("--nocache", action="store_false", default=True,
help="Search for the torrent again"),
args = parser.parse_args()
log_set_up(args.verbose)
log.info("Starting touchandgo")
log.debug("Running Python %s on %r", sys.version_info, sys.platform)
log.debug("Libtorrent version: %s", libtorrent_version)
try:
if args.sub is not None:
Language(args.sub)
touchandgo = SearchAndStream(args.name, season=args.season_number,
episode=args.episode_number,
sub_lang=args.sub, serve=args.serve,
quality=args.quality, port=args.port,
player=args.player, use_cache=args.nocache)
if args.daemon:
def callback():
touchandgo.serve = True
touchandgo.watch()
daemonize(args, callback)
else:
term = Terminal()
#with term.fullscreen():
touchandgo.watch()
except ValueError as e:
print(e)