[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / baidu.py
bloba1ad4240ffd5c625f79bf736d00085856f24421f
1 from .common import InfoExtractor
2 from ..utils import unescapeHTML
5 class BaiduVideoIE(InfoExtractor):
6 IE_DESC = '百度视频'
7 _VALID_URL = r'https?://v\.baidu\.com/(?P<type>[a-z]+)/(?P<id>\d+)\.htm'
8 _TESTS = [{
9 'url': 'http://v.baidu.com/comic/1069.htm?frp=bdbrand&q=%E4%B8%AD%E5%8D%8E%E5%B0%8F%E5%BD%93%E5%AE%B6',
10 'info_dict': {
11 'id': '1069',
12 'title': '中华小当家 TV版国语',
13 'description': 'md5:51be07afe461cf99fa61231421b5397c',
15 'playlist_count': 52,
16 }, {
17 'url': 'http://v.baidu.com/show/11595.htm?frp=bdbrand',
18 'info_dict': {
19 'id': '11595',
20 'title': 're:^奔跑吧兄弟',
21 'description': 'md5:1bf88bad6d850930f542d51547c089b8',
23 'playlist_mincount': 12,
26 def _call_api(self, path, category, playlist_id, note):
27 return self._download_json(
28 f'http://app.video.baidu.com/{path}/?worktype=adnative{category}&id={playlist_id}',
29 playlist_id, note)
31 def _real_extract(self, url):
32 category, playlist_id = self._match_valid_url(url).groups()
33 if category == 'show':
34 category = 'tvshow'
35 if category == 'tv':
36 category = 'tvplay'
38 playlist_detail = self._call_api(
39 'xqinfo', category, playlist_id, 'Download playlist JSON metadata')
41 playlist_title = playlist_detail['title']
42 playlist_description = unescapeHTML(playlist_detail.get('intro'))
44 episodes_detail = self._call_api(
45 'xqsingle', category, playlist_id, 'Download episodes JSON metadata')
47 entries = [self.url_result(
48 episode['url'], video_title=episode['title'],
49 ) for episode in episodes_detail['videos']]
51 return self.playlist_result(
52 entries, playlist_id, playlist_title, playlist_description)