]>
Commit | Line | Data |
---|---|---|
add96eb9 | 1 | import urllib.parse |
2 | ||
4435c6e9 | 3 | from .common import InfoExtractor |
4435c6e9 YCH |
4 | from ..utils import ExtractorError |
5 | ||
6 | ||
7 | class BokeCCBaseIE(InfoExtractor): | |
8 | def _extract_bokecc_formats(self, webpage, video_id, format_id=None): | |
9 | player_params_str = self._html_search_regex( | |
2af01c02 RA |
10 | r'<(?:script|embed)[^>]+src=(?P<q>["\'])(?:https?:)?//p\.bokecc\.com/(?:player|flash/player\.swf)\?(?P<query>.+?)(?P=q)', |
11 | webpage, 'player params', group='query') | |
4435c6e9 | 12 | |
add96eb9 | 13 | player_params = urllib.parse.parse_qs(player_params_str) |
4435c6e9 YCH |
14 | |
15 | info_xml = self._download_xml( | |
add96eb9 | 16 | 'http://p.bokecc.com/servlet/playinfo?uid={}&vid={}&m=1'.format( |
4435c6e9 YCH |
17 | player_params['siteid'][0], player_params['vid'][0]), video_id) |
18 | ||
add96eb9 | 19 | return [{ |
4435c6e9 YCH |
20 | 'format_id': format_id, |
21 | 'url': quality.find('./copy').attrib['playurl'], | |
f983b875 | 22 | 'quality': int(quality.attrib['value']), |
4435c6e9 YCH |
23 | } for quality in info_xml.findall('./video/quality')] |
24 | ||
4435c6e9 YCH |
25 | |
26 | class BokeCCIE(BokeCCBaseIE): | |
27 | _IE_DESC = 'CC视频' | |
5886b38d | 28 | _VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)' |
4435c6e9 YCH |
29 | |
30 | _TESTS = [{ | |
2af01c02 | 31 | 'url': 'http://union.bokecc.com/playvideo.bo?vid=E0ABAE9D4F509B189C33DC5901307461&uid=FE644790DE9D154A', |
4435c6e9 | 32 | 'info_dict': { |
2af01c02 | 33 | 'id': 'FE644790DE9D154A_E0ABAE9D4F509B189C33DC5901307461', |
4435c6e9 YCH |
34 | 'ext': 'flv', |
35 | 'title': 'BokeCC Video', | |
36 | }, | |
37 | }] | |
38 | ||
39 | def _real_extract(self, url): | |
add96eb9 | 40 | qs = urllib.parse.parse_qs(self._match_valid_url(url).group('query')) |
4435c6e9 YCH |
41 | if not qs.get('vid') or not qs.get('uid'): |
42 | raise ExtractorError('Invalid URL', expected=True) | |
43 | ||
add96eb9 | 44 | video_id = '{}_{}'.format(qs['uid'][0], qs['vid'][0]) |
4435c6e9 YCH |
45 | |
46 | webpage = self._download_webpage(url, video_id) | |
47 | ||
48 | return { | |
49 | 'id': video_id, | |
50 | 'title': 'BokeCC Video', # no title provided in the webpage | |
51 | 'formats': self._extract_bokecc_formats(webpage, video_id), | |
52 | } |