Skip to content

Commit

Permalink
Fix media_extractor for some sites (home-assistant#8887)
Browse files Browse the repository at this point in the history
  • Loading branch information
spirit-x authored and pvizeli committed Aug 8, 2017
1 parent cc5893e commit 588b36d
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions homeassistant/components/media_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,13 @@ def get_stream_selector(self):
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()
Expand Down

0 comments on commit 588b36d

Please sign in to comment.