def resolve_with_youtube_dl(url, parameters, action): youtube_dl_resolver = YoutubeDL(parameters) youtube_dl_resolver.add_default_info_extractors() try: result = youtube_dl_resolver.extract_info(url, download=False) if result is None: result = {} except Exception as e: logger.error(u'Error with YoutubeDL: %s' % e) result = {} logger.info(u'YoutubeDL full result: %s' % result) if 'entries' in result: logger.info(u'Playlist resolved by YoutubeDL: %s items' % len(result['entries'])) item_list = [] for entry in result['entries']: if entry is not None and 'url' in entry: item_list.append(entry) logger.info(u'Media found: %s' % entry['url']) if len(item_list) > 0: utils.play_items(item_list, action) return True else: logger.info(u'No playable urls in the playlist') if 'url' in result: logger.info(u'Url resolved by YoutubeDL: %s' % result['url']) utils.play_url(result['url'], action, result) return True if 'requested_formats' in result: if have_adaptive_plugin: logger.info(u'Adaptive plugin enabled looking for dash content') for entry in result['requested_formats']: if 'container' in entry and 'manifest_url' in entry: if 'dash' in entry['container']: logger.info(u'Url resolved by YoutubeDL: %s' % entry['manifest_url']) utils.play_url(entry['manifest_url'], action, result, True) return True for entry in result['requested_formats']: if 'protocol' in entry and 'manifest_url' in entry: if 'm3u8' in entry['protocol']: logger.info(u'Url resolved by YoutubeDL: %s' % entry['manifest_url']) utils.play_url(entry['manifest_url'], action, result) return True return False
def run(argument): utils.play_items([argument_to_meta_data(argument)], argument['play_action'])