2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urlparse
10 class BaiduVideoIE(InfoExtractor
):
11 _VALID_URL
= r
'http://v\.baidu\.com/(?P<type>[a-z]+)/(?P<id>\d+)\.htm'
13 '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',
16 'title': '中华小当家 TV版 (全52集)',
17 'description': 'md5:395a419e41215e531c857bb037bbaf80',
21 'url': 'http://v.baidu.com/show/11595.htm?frp=bdbrand',
25 'description': 'md5:1bf88bad6d850930f542d51547c089b8',
27 'playlist_mincount': 3,
30 def _real_extract(self
, url
):
31 mobj
= re
.match(self
._VALID
_URL
, url
)
32 playlist_id
= mobj
.group('id')
33 category
= category2
= mobj
.group('type')
34 if category
== 'show':
37 webpage
= self
._download
_webpage
(url
, playlist_id
)
39 playlist_title
= self
._html
_search
_regex
(
40 r
'title\s*:\s*(["\'])(?P
<title
>[^
\']+)\
1', webpage,
41 'playlist title
', group='title
')
42 playlist_description = self._html_search_regex(
43 r'<input[^
>]+class="j-data-intro"[^
>]+value
="([^"]+)"/>', webpage,
44 playlist_id, 'playlist description')
46 site = self._html_search_regex(
47 r'filterSite\s*:\s*["\']([^
"]*)["\']', webpage,
48 'primary provider site
')
49 api_result = self._download_json(
50 'http
://v
.baidu
.com
/%s_intro
/?dtype
=%sPlayUrl
&id=%s&site
=%s' % (
51 category, category2, playlist_id, site),
52 playlist_id, 'Get playlist links
')
55 for episode in api_result[0]['episodes
']:
56 episode_id = '%s_%s' % (playlist_id, episode['episode
'])
58 redirect_page = self._download_webpage(
59 compat_urlparse.urljoin(url, episode['url
']), episode_id,
60 note='Download Baidu redirect page
')
61 real_url = self._html_search_regex(
62 r'location\
.replace\
("([^"]+)"\)', redirect_page, 'real URL')
64 entries.append(self.url_result(
65 real_url, video_title=episode['single_title']))
67 return self.playlist_result(
68 entries, playlist_id, playlist_title, playlist_description)