mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-13 01:47:19 +08:00
[twentymin] Removed default values in regular expression search and avoided code duplication for video formats.
This commit is contained in:
parent
b14da99b3c
commit
7b2fd0f5b2
@ -91,28 +91,29 @@ class TwentyMinutenIE(InfoExtractor):
|
||||
if not video_id:
|
||||
params = self._html_search_regex(
|
||||
r'<iframe[^>]+src="(?:https?:)?//www\.20min\.ch/videoplayer/videoplayer\.html\?params=(.+?[^"])"',
|
||||
webpage, '20min embed URL', default='')
|
||||
webpage, '20min embed URL')
|
||||
video_id = self._search_regex(
|
||||
r'.*videoId@(\d+)',
|
||||
params, 'Video Id', default='')
|
||||
params, 'Video Id')
|
||||
|
||||
description = self._html_search_meta(
|
||||
'description', webpage, 'description')
|
||||
thumbnail = self._og_search_thumbnail(webpage)
|
||||
|
||||
formats = []
|
||||
format_preferences = [('sd', ''), ('hd', 'h')]
|
||||
for format_id, url_extension in format_preferences:
|
||||
format_url = 'http://podcast.20min-tv.ch/podcast/20min/%s%s.mp4' % (video_id, url_extension)
|
||||
formats.append({
|
||||
'format_id': format_id,
|
||||
'url': format_url,
|
||||
})
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'display_id': display_id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'thumbnail': thumbnail,
|
||||
'formats': [{
|
||||
'format_id': 'sd',
|
||||
'url': 'http://podcast.20min-tv.ch/podcast/20min/%s.mp4' % video_id,
|
||||
'preference': -2
|
||||
}, {
|
||||
'format_id': 'hd',
|
||||
'url': 'http://podcast.20min-tv.ch/podcast/20min/%sh.mp4' % video_id,
|
||||
'preference': -1
|
||||
}]
|
||||
'formats': formats,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user