]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/baidu.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import unescapeHTML
10 class BaiduVideoIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://v\.baidu\.com/(?P<type>[a-z]+)/(?P<id>\d+)\.htm'
14 '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',
17 'title': '中华小当家 TV版国语',
18 'description': 'md5:51be07afe461cf99fa61231421b5397c',
22 'url': 'http://v.baidu.com/show/11595.htm?frp=bdbrand',
26 'description': 'md5:1bf88bad6d850930f542d51547c089b8',
28 'playlist_mincount': 12,
31 def _call_api(self
, path
, category
, playlist_id
, note
):
32 return self
._download
_json
('http://app.video.baidu.com/%s/?worktype=adnative%s&id=%s' % (
33 path
, category
, playlist_id
), playlist_id
, note
)
35 def _real_extract(self
, url
):
36 category
, playlist_id
= re
.match(self
._VALID
_URL
, url
).groups()
37 if category
== 'show':
42 playlist_detail
= self
._call
_api
(
43 'xqinfo', category
, playlist_id
, 'Download playlist JSON metadata')
45 playlist_title
= playlist_detail
['title']
46 playlist_description
= unescapeHTML(playlist_detail
.get('intro'))
48 episodes_detail
= self
._call
_api
(
49 'xqsingle', category
, playlist_id
, 'Download episodes JSON metadata')
51 entries
= [self
.url_result(
52 episode
['url'], video_title
=episode
['title']
53 ) for episode
in episodes_detail
['videos']]
55 return self
.playlist_result(
56 entries
, playlist_id
, playlist_title
, playlist_description
)