mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-26 18:34:32 +01:00
[democracynow] Improve extraction
This commit is contained in:
parent
a134426d61
commit
18da24634c
@ -38,17 +38,32 @@ class DemocracynowIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
description = self._og_search_description(webpage, default=None)
|
|
||||||
|
|
||||||
json_data = self._parse_json(self._search_regex(
|
json_data = self._parse_json(self._search_regex(
|
||||||
r'<script[^>]+type="text/json"[^>]*>\s*({[^>]+})', webpage, 'json'),
|
r'<script[^>]+type="text/json"[^>]*>\s*({[^>]+})', webpage, 'json'),
|
||||||
display_id)
|
display_id)
|
||||||
video_id = None
|
|
||||||
|
title = json_data['title']
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
default_lang = 'en'
|
video_id = None
|
||||||
|
|
||||||
|
for key in ('file', 'audio', 'video', 'high_res_video'):
|
||||||
|
media_url = json_data.get(key, '')
|
||||||
|
if not media_url:
|
||||||
|
continue
|
||||||
|
media_url = re.sub(r'\?.*', '', compat_urlparse.urljoin(url, media_url))
|
||||||
|
video_id = video_id or remove_start(os.path.splitext(url_basename(media_url))[0], 'dn')
|
||||||
|
formats.append({
|
||||||
|
'url': media_url,
|
||||||
|
'vcodec': 'none' if key == 'audio' else None,
|
||||||
|
})
|
||||||
|
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
default_lang = 'en'
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
|
|
||||||
def add_subtitle_item(lang, info_dict):
|
def add_subtitle_item(lang, info_dict):
|
||||||
@ -68,22 +83,13 @@ class DemocracynowIE(InfoExtractor):
|
|||||||
'url': compat_urlparse.urljoin(url, subtitle_item['url']),
|
'url': compat_urlparse.urljoin(url, subtitle_item['url']),
|
||||||
})
|
})
|
||||||
|
|
||||||
for key in ('file', 'audio', 'video'):
|
description = self._og_search_description(webpage, default=None)
|
||||||
media_url = json_data.get(key, '')
|
|
||||||
if not media_url:
|
|
||||||
continue
|
|
||||||
media_url = re.sub(r'\?.*', '', compat_urlparse.urljoin(url, media_url))
|
|
||||||
video_id = video_id or remove_start(os.path.splitext(url_basename(media_url))[0], 'dn')
|
|
||||||
formats.append({
|
|
||||||
'url': media_url,
|
|
||||||
})
|
|
||||||
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id or display_id,
|
'id': video_id or display_id,
|
||||||
'title': json_data['title'],
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
|
'thumbnail': json_data.get('image'),
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user