From 588b36dff22eb8d1243ee7809c89edc702b94d7e Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 8 Aug 2017 16:21:32 +0300 Subject: [PATCH] Fix media_extractor for some sites (#8887) --- homeassistant/components/media_extractor.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/media_extractor.py b/homeassistant/components/media_extractor.py index 452ffdfa71e..691e11d01eb 100644 --- a/homeassistant/components/media_extractor.py +++ b/homeassistant/components/media_extractor.py @@ -125,24 +125,13 @@ class MediaExtractor: else: selected_media = all_media - try: - media_info = ydl.process_ie_result(selected_media, - download=False) - except (ExtractorError, DownloadError): - # This exception will be logged by youtube-dl itself - raise MEDownloadException() - def stream_selector(query): """Find stream url that matches query.""" try: - format_selector = ydl.build_format_selector(query) - except (SyntaxError, ValueError, AttributeError) as ex: - _LOGGER.error(ex) - raise MEQueryException() - - try: - requested_stream = next(format_selector(media_info)) - except (KeyError, StopIteration): + ydl.params['format'] = query + requested_stream = ydl.process_ie_result(selected_media, + download=False) + except (ExtractorError, DownloadError): _LOGGER.error("Could not extract stream for the query: %s", query) raise MEQueryException()