2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
6 compat_urllib_parse_urlparse
,
16 class AfreecaTVIE(InfoExtractor
):
17 IE_DESC
= 'afreecatv.com'
18 _VALID_URL
= r
'''(?x)^
19 https?://(?:(live|afbbs|www)\.)?afreeca(?:tv)?\.com(?::\d+)?
21 /app/(?:index|read_ucc_bbs)\.cgi|
22 /player/[Pp]layer\.(?:swf|html))
23 \?.*?\bnTitleNo=(?P<id>\d+)'''
25 'url': 'http://live.afreecatv.com:8079/app/index.cgi?szType=read_ucc_bbs&szBjId=dailyapril&nStationNo=16711924&nBbsNo=18605867&nTitleNo=36164052&szSkin=',
26 'md5': 'f72c89fe7ecc14c1b5ce506c4996046e',
30 'title': '데일리 에이프릴 요정들의 시상식!',
31 'thumbnail': 're:^https?://videoimg.afreecatv.com/.*$',
32 'uploader': 'dailyapril',
33 'uploader_id': 'dailyapril',
37 def _real_extract(self
, url
):
38 video_id
= self
._match
_id
(url
)
39 parsed_url
= compat_urllib_parse_urlparse(url
)
40 info_url
= compat_urlparse
.urlunparse(parsed_url
._replace
(
41 netloc
='afbbs.afreecatv.com:8080',
42 path
='/api/video/get_video_info.php'))
43 video_xml
= self
._download
_xml
(info_url
, video_id
)
45 if xpath_text(video_xml
, './track/flag', default
='FAIL') != 'SUCCEED':
46 raise ExtractorError('Specified AfreecaTV video does not exist',
48 title
= xpath_text(video_xml
, './track/title', 'title')
49 uploader
= xpath_text(video_xml
, './track/nickname', 'uploader')
50 uploader_id
= xpath_text(video_xml
, './track/bj_id', 'uploader id')
51 duration
= int_or_none(xpath_text(video_xml
, './track/duration',
53 thumbnail
= xpath_text(video_xml
, './track/titleImage', 'thumbnail')
56 for video_file
in video_xml
.findall('./track/video/file'):
58 'id': video_file
.get('key'),
60 'duration': int_or_none(video_file
.get('duration')),
61 'url': video_file
.text
,
68 'uploader_id': uploader_id
,
70 'thumbnail': thumbnail
,
74 info
['_type'] = 'multi_video'
75 info
['entries'] = entries
76 elif len(entries
) == 1:
77 info
['url'] = entries
[0]['url']
80 'No files found for the specified AfreecaTV video, either'
81 ' the URL is incorrect or the video has been made private.',