X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=youtube_dl%2Fextractor%2Fultimedia.py;h=96c809eaf7155290210e0f8b18d3a2c7c948ba97;hb=fec2d97ca2f1aa8b64c24b28d8c63cab052e9db4;hp=97e4445d45efeee351062875c1ec2210d44c16be;hpb=3073a6d5e9036b0b613f57bc08099862a2af87f8;p=youtube-dl diff --git a/youtube_dl/extractor/ultimedia.py b/youtube_dl/extractor/ultimedia.py index 97e4445d4..96c809eaf 100644 --- a/youtube_dl/extractor/ultimedia.py +++ b/youtube_dl/extractor/ultimedia.py @@ -1,8 +1,11 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..utils import ( + ExtractorError, qualities, unified_strdate, clean_html, @@ -39,7 +42,6 @@ class UltimediaIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) deliver_url = self._search_regex( @@ -49,18 +51,28 @@ class UltimediaIE(InfoExtractor): deliver_page = self._download_webpage( deliver_url, video_id, 'Downloading iframe page') + if '>This video is currently not available' in deliver_page: + raise ExtractorError( + 'Video %s is currently not available' % video_id, expected=True) + player = self._parse_json( self._search_regex( r"jwplayer\('player(?:_temp)?'\)\.setup\(({.+?})\)\.on", deliver_page, 'player'), video_id) quality = qualities(['flash', 'html5']) - - formats = [{ - 'url': mode['config']['file'], - 'format_id': mode.get('type'), - 'quality': quality(mode.get('type')), - } for mode in player['modes']] + formats = [] + for mode in player['modes']: + video_url = mode.get('config', {}).get('file') + if not video_url: + continue + if re.match(r'https?://www\.youtube\.com/.+?', video_url): + return self.url_result(video_url, 'Youtube') + formats.append({ + 'url': video_url, + 'format_id': mode.get('type'), + 'quality': quality(mode.get('type')), + }) self._sort_formats(formats) thumbnail = player.get('image') @@ -68,8 +80,8 @@ class UltimediaIE(InfoExtractor): title = clean_html(( self._html_search_regex( r'(?s)