2024-06-11 23:09:58 +00:00
|
|
|
import urllib.parse
|
|
|
|
|
2016-02-26 18:54:43 +00:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import ExtractorError
|
|
|
|
|
|
|
|
|
|
|
|
class BokeCCBaseIE(InfoExtractor):
|
|
|
|
def _extract_bokecc_formats(self, webpage, video_id, format_id=None):
|
|
|
|
player_params_str = self._html_search_regex(
|
2019-10-15 14:18:51 +00:00
|
|
|
r'<(?:script|embed)[^>]+src=(?P<q>["\'])(?:https?:)?//p\.bokecc\.com/(?:player|flash/player\.swf)\?(?P<query>.+?)(?P=q)',
|
|
|
|
webpage, 'player params', group='query')
|
2016-02-26 18:54:43 +00:00
|
|
|
|
2024-06-11 23:09:58 +00:00
|
|
|
player_params = urllib.parse.parse_qs(player_params_str)
|
2016-02-26 18:54:43 +00:00
|
|
|
|
|
|
|
info_xml = self._download_xml(
|
2024-06-11 23:09:58 +00:00
|
|
|
'http://p.bokecc.com/servlet/playinfo?uid={}&vid={}&m=1'.format(
|
2016-02-26 18:54:43 +00:00
|
|
|
player_params['siteid'][0], player_params['vid'][0]), video_id)
|
|
|
|
|
2024-06-11 23:09:58 +00:00
|
|
|
return [{
|
2016-02-26 18:54:43 +00:00
|
|
|
'format_id': format_id,
|
|
|
|
'url': quality.find('./copy').attrib['playurl'],
|
2021-02-18 22:03:16 +00:00
|
|
|
'quality': int(quality.attrib['value']),
|
2016-02-26 18:54:43 +00:00
|
|
|
} for quality in info_xml.findall('./video/quality')]
|
|
|
|
|
|
|
|
|
|
|
|
class BokeCCIE(BokeCCBaseIE):
|
|
|
|
_IE_DESC = 'CC视频'
|
2016-03-21 15:36:32 +00:00
|
|
|
_VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)'
|
2016-02-26 18:54:43 +00:00
|
|
|
|
|
|
|
_TESTS = [{
|
2019-10-15 14:18:51 +00:00
|
|
|
'url': 'http://union.bokecc.com/playvideo.bo?vid=E0ABAE9D4F509B189C33DC5901307461&uid=FE644790DE9D154A',
|
2016-02-26 18:54:43 +00:00
|
|
|
'info_dict': {
|
2019-10-15 14:18:51 +00:00
|
|
|
'id': 'FE644790DE9D154A_E0ABAE9D4F509B189C33DC5901307461',
|
2016-02-26 18:54:43 +00:00
|
|
|
'ext': 'flv',
|
|
|
|
'title': 'BokeCC Video',
|
|
|
|
},
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2024-06-11 23:09:58 +00:00
|
|
|
qs = urllib.parse.parse_qs(self._match_valid_url(url).group('query'))
|
2016-02-26 18:54:43 +00:00
|
|
|
if not qs.get('vid') or not qs.get('uid'):
|
|
|
|
raise ExtractorError('Invalid URL', expected=True)
|
|
|
|
|
2024-06-11 23:09:58 +00:00
|
|
|
video_id = '{}_{}'.format(qs['uid'][0], qs['vid'][0])
|
2016-02-26 18:54:43 +00:00
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': 'BokeCC Video', # no title provided in the webpage
|
|
|
|
'formats': self._extract_bokecc_formats(webpage, video_id),
|
|
|
|
}
|