]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/xinpianchang.py
1 from .common
import InfoExtractor
11 class XinpianchangIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://www\.xinpianchang\.com/(?P<id>[^/]+?)(?:\D|$)'
14 IE_NAME
= 'xinpianchang'
15 IE_DESC
= 'xinpianchang.com'
17 'url': 'https://www.xinpianchang.com/a11766551',
21 'title': '北京2022冬奥会闭幕式再见短片-冰墩墩下班了',
22 'description': 'md5:4a730c10639a82190fabe921c0fa4b87',
24 'thumbnail': r
're:^https?://oss-xpc0\.xpccdn\.com.+/assets/',
26 'uploader_id': '10357277',
27 'categories': ['宣传片', '国家城市', '广告', '其他'],
28 'tags': ['北京冬奥会', '冰墩墩', '再见', '告别', '冰墩墩哭了', '感动', '闭幕式', '熄火']
31 'url': 'https://www.xinpianchang.com/a11762904',
35 'title': '冬奥会决胜时刻《法国派出三只鸡?》',
36 'description': 'md5:55cb139ef8f48f0c877932d1f196df8b',
38 'thumbnail': r
're:^https?://oss-xpc0\.xpccdn\.com.+/assets/',
40 'uploader_id': '10858927',
41 'categories': ['动画', '三维CG'],
42 'tags': ['France Télévisions', '法国3台', '蠢萌', '冬奥会']
45 'url': 'https://www.xinpianchang.com/a11779743?from=IndexPick&part=%E7%BC%96%E8%BE%91%E7%B2%BE%E9%80%89&index=2',
46 'only_matching': True,
49 def _real_extract(self
, url
):
50 video_id
= self
._match
_id
(url
)
51 webpage
= self
._download
_webpage
(url
, video_id
=video_id
)
52 domain
= self
.find_value_with_regex(var
='requireNewDomain', webpage
=webpage
)
53 vid
= self
.find_value_with_regex(var
='vid', webpage
=webpage
)
54 app_key
= self
.find_value_with_regex(var
='modeServerAppKey', webpage
=webpage
)
55 api
= update_url_query(f
'{domain}/mod/api/v2/media/{vid}', {'appKey': app_key}
)
56 data
= self
._download
_json
(api
, video_id
=video_id
)['data']
57 formats
, subtitles
= [], {}
58 for k
, v
in data
.get('resource').items():
59 if k
in ('dash', 'hls'):
64 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(v_url
, video_id
=video_id
)
66 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(v_url
, video_id
=video_id
)
68 subtitles
= self
._merge
_subtitles
(subtitles
, subs
)
69 elif k
== 'progressive':
71 'url': url_or_none(prog
.get('url')),
72 'width': int_or_none(prog
.get('width')),
73 'height': int_or_none(prog
.get('height')),
75 } for prog
in v
if prog
.get('url') or []])
79 'title': data
.get('title'),
80 'description': data
.get('description'),
81 'duration': int_or_none(data
.get('duration')),
82 'categories': data
.get('categories'),
83 'tags': data
.get('keywords'),
84 'thumbnail': data
.get('cover'),
85 'uploader': try_get(data
, lambda x
: x
['owner']['username']),
86 'uploader_id': str_or_none(try_get(data
, lambda x
: x
['owner']['id'])),
88 'subtitles': subtitles
,
91 def find_value_with_regex(self
, var
, webpage
):
92 return self
._search
_regex
(rf
'var\s{var}\s=\s\"(?P<vid>[^\"]+)\"', webpage
, name
=var
)