]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/cctv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
15 class CCTVIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:[^/]+)\.(?:cntv|cctv)\.(?:com|cn)/(?:[^/]+/)*?(?P<id>[^/?#&]+?)(?:/index)?(?:\.s?html|[?#&]|$)'
19 'url': 'http://sports.cntv.cn/2016/02/12/ARTIaBRxv4rTT1yWf1frW2wi160212.shtml',
20 'md5': 'd61ec00a493e09da810bf406a078f691',
22 'id': '5ecdbeab623f4973b40ff25f18b174e8',
24 'title': '[NBA]二少联手砍下46分 雷霆主场击败鹈鹕(快讯)',
25 'description': 'md5:7e14a5328dc5eb3d1cd6afbbe0574e95',
27 'uploader': 'songjunjie',
28 'timestamp': 1455279956,
29 'upload_date': '20160212',
32 'url': 'http://tv.cctv.com/2016/02/05/VIDEUS7apq3lKrHG9Dncm03B160205.shtml',
34 'id': 'efc5d49e5b3b4ab2b34f3a502b73d3ae',
36 'title': '[赛车]“车王”舒马赫恢复情况成谜(快讯)',
37 'description': '2月4日,蒙特泽莫罗透露了关于“车王”舒马赫恢复情况,但情况是否属实遭到了质疑。',
40 'timestamp': 1454677291,
41 'upload_date': '20160205',
44 'skip_download': True,
47 'url': 'http://english.cntv.cn/special/four_comprehensives/index.shtml',
49 'id': '4bb9bb4db7a6471ba85fdeda5af0381e',
51 'title': 'NHnews008 ANNUAL POLITICAL SEASON',
52 'description': 'Four Comprehensives',
54 'uploader': 'zhangyunlei',
55 'timestamp': 1425385521,
56 'upload_date': '20150303',
59 'skip_download': True,
62 'url': 'http://cctv.cntv.cn/lm/tvseries_russian/yilugesanghua/index.shtml',
64 'id': 'b15f009ff45c43968b9af583fc2e04b2',
66 'title': 'Путь,усыпанный космеями Серия 1',
67 'description': 'Путь, усыпанный космеями',
70 'timestamp': 1477479241,
71 'upload_date': '20161026',
74 'skip_download': True,
77 'url': 'http://ent.cntv.cn/2016/01/18/ARTIjprSSJH8DryTVr5Bx8Wb160118.shtml',
78 'only_matching': True,
80 'url': 'http://tv.cntv.cn/video/C39296/e0210d949f113ddfb38d31f00a4e5c44',
81 'only_matching': True,
83 'url': 'http://english.cntv.cn/2016/09/03/VIDEhnkB5y9AgHyIEVphCEz1160903.shtml',
84 'only_matching': True,
86 'url': 'http://tv.cctv.com/2016/09/07/VIDE5C1FnlX5bUywlrjhxXOV160907.shtml',
87 'only_matching': True,
89 'url': 'http://tv.cntv.cn/video/C39296/95cfac44cabd3ddc4a9438780a4e5c44',
93 def _real_extract(self
, url
):
94 video_id
= self
._match
_id
(url
)
95 webpage
= self
._download
_webpage
(url
, video_id
)
97 video_id
= self
._search
_regex
(
98 [r
'var\s+guid\s*=\s*["\']([\da
-fA
-F
]+)',
99 r'videoCenterId
["\']\s*,\s*["\']([\da
-fA
-F
]+)',
100 r'"changePlayer\s*\(\s*["\']([\da
-fA
-F
]+)',
101 r'"load[Vv]ideo\s*\(\s*["\']([\da
-fA
-F
]+)'],
104 data = self._download_json(
105 'http
://vdn
.apps
.cntv
.cn
/api
/getHttpVideoInfo
.do
', video_id,
114 title = data['title
']
118 video = data.get('video
')
119 if isinstance(video, dict):
120 for quality, chapters_key in enumerate(('lowChapters
', 'chapters
')):
122 video, lambda x: x[chapters_key][0]['url
'], compat_str)
131 hls_url = try_get(data, lambda x: x['hls_url
'], compat_str)
133 hls_url = re.sub(r'maxbr
=\d
+&?
', '', hls_url)
134 formats.extend(self._extract_m3u8_formats(
135 hls_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
136 m3u8_id='hls
', fatal=False))
138 self._sort_formats(formats)
140 uploader = data.get('editer_name
')
141 description = self._html_search_meta('description
', webpage)
142 timestamp = unified_timestamp(data.get('f_pgmtime
'))
143 duration = float_or_none(try_get(video, lambda x: x['totalLength
']))
148 'description
': description,
149 'uploader
': uploader,
150 'timestamp
': timestamp,
151 'duration
': duration,