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