]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/democracynow.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..compat
import compat_urlparse
15 class DemocracynowIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?democracynow.org/(?P<id>[^\?]*)'
17 IE_NAME
= 'democracynow'
19 'url': 'http://www.democracynow.org/shows/2015/7/3',
20 'md5': '3757c182d3d84da68f5c8f506c18c196',
22 'id': '2015-0703-001',
24 'title': 'Daily Show',
27 'url': 'http://www.democracynow.org/2015/7/3/this_flag_comes_down_today_bree',
29 'id': '2015-0703-001',
31 'title': '"This Flag Comes Down Today": Bree Newsome Scales SC Capitol Flagpole, Takes Down Confederate Flag',
32 'description': 'md5:4d2bc4f0d29f5553c2210a4bc7761a21',
35 'skip_download': True,
39 def _real_extract(self
, url
):
40 display_id
= self
._match
_id
(url
)
42 webpage
= self
._download
_webpage
(url
, display_id
)
44 json_data
= self
._parse
_json
(self
._search
_regex
(
45 r
'<script[^>]+type="text/json"[^>]*>\s*({[^>]+})', webpage
, 'json'),
48 title
= json_data
['title']
53 for key
in ('file', 'audio', 'video', 'high_res_video'):
54 media_url
= json_data
.get(key
, '')
57 media_url
= re
.sub(r
'\?.*', '', compat_urlparse
.urljoin(url
, media_url
))
58 video_id
= video_id
or remove_start(os
.path
.splitext(url_basename(media_url
))[0], 'dn')
61 'vcodec': 'none' if key
== 'audio' else None,
64 self
._sort
_formats
(formats
)
69 def add_subtitle_item(lang
, info_dict
):
70 if lang
not in subtitles
:
72 subtitles
[lang
].append(info_dict
)
74 # chapter_file are not subtitles
75 if 'caption_file' in json_data
:
76 add_subtitle_item(default_lang
, {
77 'url': compat_urlparse
.urljoin(url
, json_data
['caption_file']),
80 for subtitle_item
in json_data
.get('captions', []):
81 lang
= subtitle_item
.get('language', '').lower() or default_lang
82 add_subtitle_item(lang
, {
83 'url': compat_urlparse
.urljoin(url
, subtitle_item
['url']),
86 description
= self
._og
_search
_description
(webpage
, default
=None)
89 'id': video_id
or display_id
,
91 'description': description
,
92 'thumbnail': json_data
.get('image'),
93 'subtitles': subtitles
,