Upgrade youtube_dl to 2017.8.18 (#9079)
This commit is contained in:
parent
da2cb8e97e
commit
4a3be6d514
2 changed files with 15 additions and 16 deletions
|
@ -15,7 +15,7 @@ from homeassistant.components.media_player import (
|
||||||
from homeassistant.config import load_yaml_config_file
|
from homeassistant.config import load_yaml_config_file
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['youtube_dl==2017.8.6']
|
REQUIREMENTS = ['youtube_dl==2017.8.18']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def setup(hass, config):
|
||||||
'media_player', 'services.yaml'))
|
'media_player', 'services.yaml'))
|
||||||
|
|
||||||
def play_media(call):
|
def play_media(call):
|
||||||
"""Get stream URL and send it to the media_player.play_media."""
|
"""Get stream URL and send it to the play_media service."""
|
||||||
MediaExtractor(hass, config[DOMAIN], call.data).extract_and_send()
|
MediaExtractor(hass, config[DOMAIN], call.data).extract_and_send()
|
||||||
|
|
||||||
hass.services.register(DOMAIN,
|
hass.services.register(DOMAIN,
|
||||||
|
@ -66,7 +66,7 @@ class MEQueryException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MediaExtractor:
|
class MediaExtractor(object):
|
||||||
"""Class which encapsulates all extraction logic."""
|
"""Class which encapsulates all extraction logic."""
|
||||||
|
|
||||||
def __init__(self, hass, component_config, call_data):
|
def __init__(self, hass, component_config, call_data):
|
||||||
|
@ -107,15 +107,14 @@ class MediaExtractor:
|
||||||
ydl = YoutubeDL({'quiet': True, 'logger': _LOGGER})
|
ydl = YoutubeDL({'quiet': True, 'logger': _LOGGER})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_media = ydl.extract_info(self.get_media_url(),
|
all_media = ydl.extract_info(self.get_media_url(), process=False)
|
||||||
process=False)
|
|
||||||
except DownloadError:
|
except DownloadError:
|
||||||
# This exception will be logged by youtube-dl itself
|
# This exception will be logged by youtube-dl itself
|
||||||
raise MEDownloadException()
|
raise MEDownloadException()
|
||||||
|
|
||||||
if 'entries' in all_media:
|
if 'entries' in all_media:
|
||||||
_LOGGER.warning("Playlists are not supported, "
|
_LOGGER.warning(
|
||||||
"looking for the first video")
|
"Playlists are not supported, looking for the first video")
|
||||||
entries = list(all_media['entries'])
|
entries = list(all_media['entries'])
|
||||||
if len(entries) > 0:
|
if len(entries) > 0:
|
||||||
selected_media = entries[0]
|
selected_media = entries[0]
|
||||||
|
@ -126,14 +125,14 @@ class MediaExtractor:
|
||||||
selected_media = all_media
|
selected_media = all_media
|
||||||
|
|
||||||
def stream_selector(query):
|
def stream_selector(query):
|
||||||
"""Find stream url that matches query."""
|
"""Find stream URL that matches query."""
|
||||||
try:
|
try:
|
||||||
ydl.params['format'] = query
|
ydl.params['format'] = query
|
||||||
requested_stream = ydl.process_ie_result(selected_media,
|
requested_stream = ydl.process_ie_result(
|
||||||
download=False)
|
selected_media, download=False)
|
||||||
except (ExtractorError, DownloadError):
|
except (ExtractorError, DownloadError):
|
||||||
_LOGGER.error("Could not extract stream for the query: %s",
|
_LOGGER.error(
|
||||||
query)
|
"Could not extract stream for the query: %s", query)
|
||||||
raise MEQueryException()
|
raise MEQueryException()
|
||||||
|
|
||||||
return requested_stream['url']
|
return requested_stream['url']
|
||||||
|
@ -141,7 +140,7 @@ class MediaExtractor:
|
||||||
return stream_selector
|
return stream_selector
|
||||||
|
|
||||||
def call_media_player_service(self, stream_selector, entity_id):
|
def call_media_player_service(self, stream_selector, entity_id):
|
||||||
"""Call media_player.play_media service."""
|
"""Call Media player play_media service."""
|
||||||
stream_query = self.get_stream_query_for_entity(entity_id)
|
stream_query = self.get_stream_query_for_entity(entity_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -164,8 +163,8 @@ class MediaExtractor:
|
||||||
|
|
||||||
def get_stream_query_for_entity(self, entity_id):
|
def get_stream_query_for_entity(self, entity_id):
|
||||||
"""Get stream format query for entity."""
|
"""Get stream format query for entity."""
|
||||||
default_stream_query = self.config.get(CONF_DEFAULT_STREAM_QUERY,
|
default_stream_query = self.config.get(
|
||||||
DEFAULT_STREAM_QUERY)
|
CONF_DEFAULT_STREAM_QUERY, DEFAULT_STREAM_QUERY)
|
||||||
|
|
||||||
if entity_id:
|
if entity_id:
|
||||||
media_content_type = self.call_data.get(ATTR_MEDIA_CONTENT_TYPE)
|
media_content_type = self.call_data.get(ATTR_MEDIA_CONTENT_TYPE)
|
||||||
|
|
|
@ -1013,7 +1013,7 @@ yeelight==0.3.2
|
||||||
yeelightsunflower==0.0.8
|
yeelightsunflower==0.0.8
|
||||||
|
|
||||||
# homeassistant.components.media_extractor
|
# homeassistant.components.media_extractor
|
||||||
youtube_dl==2017.8.6
|
youtube_dl==2017.8.18
|
||||||
|
|
||||||
# homeassistant.components.light.zengge
|
# homeassistant.components.light.zengge
|
||||||
zengge==0.2
|
zengge==0.2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue