diff options
author | Filippo Valsorda <[email protected]> | 2018-01-07 15:03:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2018-01-07 15:03:28 +0100 |
commit | 97bc05116e15df3cf1b7b7216c60fad7ee0acc9f (patch) | |
tree | 453059413184d22a44241d251a82196c5d2461eb /youtube_dl/extractor/udn.py | |
parent | 7608a91ee7b40c74a35c30b44731606382702592 (diff) | |
parent | 0a5b1295b7c1aa6395b65ee137087c540b37b32b (diff) | |
download | youtube-dl-97bc05116e15df3cf1b7b7216c60fad7ee0acc9f.tar.gz youtube-dl-97bc05116e15df3cf1b7b7216c60fad7ee0acc9f.zip |
Merge branch 'master' into totalwebcastingtotalwebcasting
Diffstat (limited to 'youtube_dl/extractor/udn.py')
-rw-r--r-- | youtube_dl/extractor/udn.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/youtube_dl/extractor/udn.py b/youtube_dl/extractor/udn.py index daf45d0b4..2c8e5c7b4 100644 --- a/youtube_dl/extractor/udn.py +++ b/youtube_dl/extractor/udn.py @@ -1,7 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -import json import re from .common import InfoExtractor @@ -29,6 +28,7 @@ class UDNEmbedIE(InfoExtractor): # m3u8 download 'skip_download': True, }, + 'expected_warnings': ['Failed to parse JSON Expecting value'], }, { 'url': 'https://video.udn.com/embed/news/300040', 'only_matching': True, @@ -43,10 +43,21 @@ class UDNEmbedIE(InfoExtractor): page = self._download_webpage(url, video_id) - options = json.loads(js_to_json(self._html_search_regex( - r'var\s+options\s*=\s*([^;]+);', page, 'video urls dictionary'))) - - video_urls = options['video'] + options_str = self._html_search_regex( + r'var\s+options\s*=\s*([^;]+);', page, 'options') + trans_options_str = js_to_json(options_str) + options = self._parse_json(trans_options_str, 'options', fatal=False) or {} + if options: + video_urls = options['video'] + title = options['title'] + poster = options.get('poster') + else: + video_urls = self._parse_json(self._html_search_regex( + r'"video"\s*:\s*({.+?})\s*,', trans_options_str, 'video urls'), 'video urls') + title = self._html_search_regex( + r"title\s*:\s*'(.+?)'\s*,", options_str, 'title') + poster = self._html_search_regex( + r"poster\s*:\s*'(.+?)'\s*,", options_str, 'poster', default=None) if video_urls.get('youtube'): return self.url_result(video_urls.get('youtube'), 'Youtube') @@ -68,7 +79,7 @@ class UDNEmbedIE(InfoExtractor): formats.extend(self._extract_f4m_formats( video_url, video_id, f4m_id='hds')) else: - mobj = re.search(r'_(?P<height>\d+)p_(?P<tbr>\d+).mp4', video_url) + mobj = re.search(r'_(?P<height>\d+)p_(?P<tbr>\d+)\.mp4', video_url) a_format = { 'url': video_url, # video_type may be 'mp4', which confuses YoutubeDL @@ -83,14 +94,9 @@ class UDNEmbedIE(InfoExtractor): self._sort_formats(formats) - thumbnails = [{ - 'url': img_url, - 'id': img_type, - } for img_type, img_url in options.get('gallery', [{}])[0].items() if img_url] - return { 'id': video_id, 'formats': formats, - 'title': options['title'], - 'thumbnails': thumbnails, + 'title': title, + 'thumbnail': poster, } |