]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/udn.py
c08428acfab446dff6157035ef032ae326199ebf
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
10 from ..compat
import compat_urlparse
13 class UDNEmbedIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://video\.udn\.com/(?:embed|play)/news/(?P<id>\d+)'
16 'url': 'http://video.udn.com/embed/news/300040',
17 'md5': 'de06b4c90b042c128395a88f0384817e',
21 'title': '生物老師男變女 全校挺"做自己"',
22 'thumbnail': 're:^https?://.*\.jpg$',
25 'url': 'https://video.udn.com/embed/news/300040',
26 'only_matching': True,
28 # From https://video.udn.com/news/303776
29 'url': 'https://video.udn.com/play/news/303776',
30 'only_matching': True,
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
36 page
= self
._download
_webpage
(url
, video_id
)
38 options
= json
.loads(js_to_json(self
._html
_search
_regex
(
39 r
'var options\s*=\s*([^;]+);', page
, 'video urls dictionary')))
41 video_urls
= options
['video']
43 if video_urls
.get('youtube'):
44 return self
.url_result(video_urls
.get('youtube'), 'Youtube')
47 del video_urls
['youtube']
52 'url': self
._download
_webpage
(
53 compat_urlparse
.urljoin(url
, api_url
), video_id
,
54 'retrieve url for %s video' % video_type
),
55 'format_id': video_type
,
56 'preference': 0 if video_type
== 'mp4' else -1,
57 } for video_type
, api_url
in video_urls
.items() if api_url
]
60 raise ExtractorError('No videos found', expected
=True)
62 self
._sort
_formats
(formats
)
66 if options
.get('gallery') and len(options
['gallery']):
67 thumbnail
= options
['gallery'][0].get('original')
72 'title': options
['title'],
73 'thumbnail': thumbnail