2015-05-02 18:51:24 +02:00
|
|
|
from .common import InfoExtractor
|
2016-01-02 14:36:35 +01:00
|
|
|
from ..utils import unescapeHTML
|
2015-05-02 18:51:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BaiduVideoIE(InfoExtractor):
|
2015-07-10 18:49:59 +02:00
|
|
|
IE_DESC = '百度视频'
|
2016-03-21 16:36:32 +01:00
|
|
|
_VALID_URL = r'https?://v\.baidu\.com/(?P<type>[a-z]+)/(?P<id>\d+)\.htm'
|
2015-05-02 18:51:24 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'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',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1069',
|
2015-10-30 13:56:21 +01:00
|
|
|
'title': '中华小当家 TV版国语',
|
2016-01-02 14:36:35 +01:00
|
|
|
'description': 'md5:51be07afe461cf99fa61231421b5397c',
|
2015-05-02 18:51:24 +02:00
|
|
|
},
|
|
|
|
'playlist_count': 52,
|
|
|
|
}, {
|
|
|
|
'url': 'http://v.baidu.com/show/11595.htm?frp=bdbrand',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '11595',
|
|
|
|
'title': 're:^奔跑吧兄弟',
|
|
|
|
'description': 'md5:1bf88bad6d850930f542d51547c089b8',
|
|
|
|
},
|
2015-10-30 13:56:21 +01:00
|
|
|
'playlist_mincount': 12,
|
2015-05-02 18:51:24 +02:00
|
|
|
}]
|
|
|
|
|
2016-01-02 14:44:49 +01:00
|
|
|
def _call_api(self, path, category, playlist_id, note):
|
2024-06-12 01:09:58 +02:00
|
|
|
return self._download_json(
|
|
|
|
f'http://app.video.baidu.com/{path}/?worktype=adnative{category}&id={playlist_id}',
|
|
|
|
playlist_id, note)
|
2015-10-30 13:56:21 +01:00
|
|
|
|
2015-05-02 18:51:24 +02:00
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
category, playlist_id = self._match_valid_url(url).groups()
|
2015-05-02 18:51:24 +02:00
|
|
|
if category == 'show':
|
2015-10-30 13:56:21 +01:00
|
|
|
category = 'tvshow'
|
|
|
|
if category == 'tv':
|
|
|
|
category = 'tvplay'
|
2015-05-02 18:51:24 +02:00
|
|
|
|
2016-01-02 14:44:49 +01:00
|
|
|
playlist_detail = self._call_api(
|
|
|
|
'xqinfo', category, playlist_id, 'Download playlist JSON metadata')
|
2015-05-02 18:51:24 +02:00
|
|
|
|
2015-10-30 13:56:21 +01:00
|
|
|
playlist_title = playlist_detail['title']
|
2016-01-02 14:36:35 +01:00
|
|
|
playlist_description = unescapeHTML(playlist_detail.get('intro'))
|
2015-05-02 18:51:24 +02:00
|
|
|
|
2016-01-02 14:44:49 +01:00
|
|
|
episodes_detail = self._call_api(
|
|
|
|
'xqsingle', category, playlist_id, 'Download episodes JSON metadata')
|
2015-05-02 18:51:24 +02:00
|
|
|
|
2016-01-02 14:46:40 +01:00
|
|
|
entries = [self.url_result(
|
2024-06-12 01:09:58 +02:00
|
|
|
episode['url'], video_title=episode['title'],
|
2016-01-02 14:46:40 +01:00
|
|
|
) for episode in episodes_detail['videos']]
|
2015-05-02 18:51:24 +02:00
|
|
|
|
|
|
|
return self.playlist_result(
|
|
|
|
entries, playlist_id, playlist_title, playlist_description)
|