]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bokecc.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_parse_qs
8 from ..utils
import ExtractorError
11 class BokeCCBaseIE(InfoExtractor
):
12 def _extract_bokecc_formats(self
, webpage
, video_id
, format_id
=None):
13 player_params_str
= self
._html
_search
_regex
(
14 r
'<(?:script|embed)[^>]+src="http://p\.bokecc\.com/player\?([^"]+)',
15 webpage
, 'player params')
17 player_params
= compat_parse_qs(player_params_str
)
19 info_xml
= self
._download
_xml
(
20 'http://p.bokecc.com/servlet/playinfo?uid=%s&vid=%s&m=1' % (
21 player_params
['siteid'][0], player_params
['vid'][0]), video_id
)
24 'format_id': format_id
,
25 'url': quality
.find('./copy').attrib
['playurl'],
26 'preference': int(quality
.attrib
['value']),
27 } for quality
in info_xml
.findall('./video/quality')]
29 self
._sort
_formats
(formats
)
34 class BokeCCIE(BokeCCBaseIE
):
36 _VALID_URL
= r
'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)'
39 'url': 'http://union.bokecc.com/playvideo.bo?vid=E44D40C15E65EA30&uid=CD0C5D3C8614B28B',
41 'id': 'CD0C5D3C8614B28B_E44D40C15E65EA30',
43 'title': 'BokeCC Video',
47 def _real_extract(self
, url
):
48 qs
= compat_parse_qs(re
.match(self
._VALID
_URL
, url
).group('query'))
49 if not qs
.get('vid') or not qs
.get('uid'):
50 raise ExtractorError('Invalid URL', expected
=True)
52 video_id
= '%s_%s' % (qs
['uid'][0], qs
['vid'][0])
54 webpage
= self
._download
_webpage
(url
, video_id
)
58 'title': 'BokeCC Video', # no title provided in the webpage
59 'formats': self
._extract
_bokecc
_formats
(webpage
, video_id
),