def handle_videoinfo(info, index=0): if not args.json: info.print_info(args.format, args.info) else: print( json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return stream_id = args.format or info.stream_types[0] urls = info.streams[stream_id]['src'] if args.output_name: if args.playlist: name = args.output_name + '_' + str(index) else: name = args.output_name else: name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live if args.player: launch_player(args.player, urls) else: download(urls, name, ext, live)
def handle_videoinfo(info, index=0): i = args.format or '0' if i.isdigit(): i = int(i) if i > len(info.stream_types): i = len(info.stream_types) -1 stream_id = info.stream_types[i] else: if not i in info.stream_types: stream_id = info.stream_types[0] else: stream_id = i if not args.json: info.print_info(stream_id, args.info) else: print(json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return urls = info.streams[stream_id]['src'] if args.output_name: if args.playlist: name = args.output_name + '_' + str(index) else: name = args.output_name else: name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live player_args = info.extra player_args['title'] = info.title if args.player: launch_player(args.player, urls, **player_args) else: download(urls, name, ext, live)
def handle_videoinfo(info, index=0): i = args.format or '0' if i.isdigit(): i = int(i) if i > len(info.stream_types): i = len(info.stream_types) - 1 stream_id = info.stream_types[i] else: if not i in info.stream_types: stream_id = info.stream_types[0] else: stream_id = i if not args.json: info.print_info(stream_id, args.info) else: print( json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return urls = info.streams[stream_id]['src'] name = args.output_name if name: if '\\u' in name: name = ast.literal_eval('"{}"'.format(name)) if args.playlist: name = name + '_' + str(index) else: name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live if args.player: player_args = info.extra if player_args['rangefetch']: player_args['rangefetch']['down_rate'] = player_args['rangefetch'][ 'video_rate'].get(stream_id) player_args['rangefetch']['ca_certs'] = args.certs if args.proxy != 'none': player_args['proxy'] = args.proxy if player_args['rangefetch']: player_args['rangefetch']['proxy'] = args.proxy player_args['title'] = info.title player_args['subs'] = args.no_sub or [ sub['src'] for sub in info.subtitles ] launch_player(args.player, urls, ext, **player_args) else: download(urls, name, ext, live) if not args.no_sub: download_subtitles(info.subtitles, name)
def play(): if request.method == 'PUT': url = request.form['url'] m,u = url_to_module(url) try: info = m.parser(u) except AssertionError as e: return str(e) player_args = info.extra player_args['title'] = info.title urls = info.streams[info.stream_types[0]]['src'] launch_player("mpv", urls, **player_args) return "OK" else: return "curl -X put --data-urlencode \"url=<URL>\" http://IP:5000/play"
def handle_videoinfo(info): if not args.json: info.print_info(args.format, args.info) else: print(json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return stream_id = args.format or info.stream_types[0] urls = info.streams[stream_id]['src'] name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live if args.player: launch_player(args.player, urls) else: download(urls, name, ext, live)
def handle_videoinfo(info, index=0): i = args.format or '0' if i.isdigit(): i = int(i) if i > len(info.stream_types): i = len(info.stream_types) -1 stream_id = info.stream_types[i] else: if not i in info.stream_types: stream_id = info.stream_types[0] else: stream_id = i if not args.json: info.print_info(stream_id, args.info) else: print(json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return urls = info.streams[stream_id]['src'] if args.output_name: if args.playlist: name = args.output_name + '_' + str(index) else: name = args.output_name else: name = time.strftime('%y%m%d_%H%M%S')+"-"+info.artist+"-"+info.title #name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live if info.extra['rangefetch']: info.extra['rangefetch']['down_rate'] = info.extra['rangefetch']['video_rate'][stream_id] if args.proxy != 'none': proxy = 'http://' + args.proxy info.extra['proxy'] = proxy if info.extra['rangefetch']: info.extra['rangefetch']['proxy'] = proxy player_args = info.extra player_args['title'] = info.title if args.player: launch_player(args.player, urls, ext, **player_args) else: download(urls, name, ext, live)
def handle_videoinfo(info, index=0): i = args.format or '0' if i.isdigit(): i = int(i) if i > len(info.stream_types): i = len(info.stream_types) -1 stream_id = info.stream_types[i] else: if not i in info.stream_types: stream_id = info.stream_types[0] else: stream_id = i if not args.json: info.print_info(stream_id, args.info) else: print(json.dumps(info.jsonlize(), indent=4, sort_keys=True, ensure_ascii=False)) if args.info or args.json: return urls = info.streams[stream_id]['src'] if args.output_name: if args.playlist: name = args.output_name + '_' + str(index) else: name = args.output_name else: name = info.build_file_name(stream_id) ext = info.streams[stream_id]['container'] live = info.live if info.extra['rangefetch']: info.extra['rangefetch']['down_rate'] = info.extra['rangefetch']['video_rate'][stream_id] if args.proxy != 'none': proxy = 'http://' + args.proxy info.extra['proxy'] = proxy if info.extra['rangefetch']: info.extra['rangefetch']['proxy'] = proxy player_args = info.extra player_args['title'] = info.title if args.player: launch_player(args.player, urls, ext, **player_args) else: download(urls, name, ext, live)
def run(self): while not self.__exit__: if len(self.playlist) == 0: sleep(10) continue o = self.playlist[0] self.playlist.remove(o) obj = json.loads(o) if not 'args' in obj: obj['args'] = { 'ua': '', 'header': '', 'title': '', 'referer': '' } obj['play'] = False self.handle = launch_player(obj['urls'], obj['ext'], **obj['args']) self.handle.wait()