diff options
| author | Sergey M․ <dstftw@gmail.com> | 2016-04-08 22:27:27 +0600 | 
|---|---|---|
| committer | Sergey M․ <dstftw@gmail.com> | 2016-04-08 22:27:27 +0600 | 
| commit | 18da24634c38ff6af4deaf606badfcbb9e6c3d68 (patch) | |
| tree | 64b4527987e155c4679bae1f32a87d7bdb1eed3f | |
| parent | a134426d619ac711f6adc24242b1e7d66d0b346a (diff) | |
[democracynow] Improve extraction
| -rw-r--r-- | youtube_dl/extractor/democracynow.py | 36 | 
1 files changed, 21 insertions, 15 deletions
| diff --git a/youtube_dl/extractor/democracynow.py b/youtube_dl/extractor/democracynow.py index 188f890ce..65a98d789 100644 --- a/youtube_dl/extractor/democracynow.py +++ b/youtube_dl/extractor/democracynow.py @@ -38,17 +38,32 @@ class DemocracynowIE(InfoExtractor):      def _real_extract(self, url):          display_id = self._match_id(url) +          webpage = self._download_webpage(url, display_id) -        description = self._og_search_description(webpage, default=None)          json_data = self._parse_json(self._search_regex(              r'<script[^>]+type="text/json"[^>]*>\s*({[^>]+})', webpage, 'json'),              display_id) -        video_id = None + +        title = json_data['title']          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 = {}          def add_subtitle_item(lang, info_dict): @@ -68,22 +83,13 @@ class DemocracynowIE(InfoExtractor):                  'url': compat_urlparse.urljoin(url, subtitle_item['url']),              }) -        for key in ('file', 'audio', '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, -            }) - -        self._sort_formats(formats) +        description = self._og_search_description(webpage, default=None)          return {              'id': video_id or display_id, -            'title': json_data['title'], +            'title': title,              'description': description, +            'thumbnail': json_data.get('image'),              'subtitles': subtitles,              'formats': formats,          } | 
