2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
8 compat_urllib_parse_urlparse
,
20 class AfreecaTVIE(InfoExtractor
):
21 IE_DESC
= 'afreecatv.com'
25 (?:(?:live|afbbs|www)\.)?afreeca(?:tv)?\.com(?::\d+)?
27 /app/(?:index|read_ucc_bbs)\.cgi|
28 /player/[Pp]layer\.(?:swf|html)
30 vod\.afreecatv\.com/PLAYER/STATION/
35 'url': 'http://live.afreecatv.com:8079/app/index.cgi?szType=read_ucc_bbs&szBjId=dailyapril&nStationNo=16711924&nBbsNo=18605867&nTitleNo=36164052&szSkin=',
36 'md5': 'f72c89fe7ecc14c1b5ce506c4996046e',
40 'title': '데일리 에이프릴 요정들의 시상식!',
41 'thumbnail': 're:^https?://(?:video|st)img.afreecatv.com/.*$',
42 'uploader': 'dailyapril',
43 'uploader_id': 'dailyapril',
44 'upload_date': '20160503',
47 'url': 'http://afbbs.afreecatv.com:8080/app/read_ucc_bbs.cgi?nStationNo=16711924&nTitleNo=36153164&szBjId=dailyapril&nBbsNo=18605867',
50 'title': "BJ유트루와 함께하는 '팅커벨 메이크업!'",
51 'thumbnail': 're:^https?://(?:video|st)img.afreecatv.com/.*$',
52 'uploader': 'dailyapril',
53 'uploader_id': 'dailyapril',
57 'md5': 'd8b7c174568da61d774ef0203159bf97',
61 'title': "BJ유트루와 함께하는 '팅커벨 메이크업!'",
62 'upload_date': '20160502',
65 'md5': '58f2ce7f6044e34439ab2d50612ab02b',
69 'title': "BJ유트루와 함께하는 '팅커벨 메이크업!'",
70 'upload_date': '20160502',
74 'url': 'http://www.afreecatv.com/player/Player.swf?szType=szBjId=djleegoon&nStationNo=11273158&nBbsNo=13161095&nTitleNo=36327652',
75 'only_matching': True,
77 'url': 'http://vod.afreecatv.com/PLAYER/STATION/15055030',
78 'only_matching': True,
82 def parse_video_key(key
):
84 m
= re
.match(r
'^(?P<upload_date>\d{8})_\w+_(?P<part>\d+)$', key
)
86 video_key
['upload_date'] = m
.group('upload_date')
87 video_key
['part'] = m
.group('part')
90 def _real_extract(self
, url
):
91 video_id
= self
._match
_id
(url
)
92 parsed_url
= compat_urllib_parse_urlparse(url
)
93 info_url
= compat_urlparse
.urlunparse(parsed_url
._replace
(
94 netloc
='afbbs.afreecatv.com:8080',
95 path
='/api/video/get_video_info.php'))
97 video_xml
= self
._download
_xml
(
98 update_url_query(info_url
, {'nTitleNo': video_id
}), video_id
)
100 if xpath_element(video_xml
, './track/video/file') is None:
101 raise ExtractorError('Specified AfreecaTV video does not exist',
104 title
= xpath_text(video_xml
, './track/title', 'title')
105 uploader
= xpath_text(video_xml
, './track/nickname', 'uploader')
106 uploader_id
= xpath_text(video_xml
, './track/bj_id', 'uploader id')
107 duration
= int_or_none(xpath_text(video_xml
, './track/duration',
109 thumbnail
= xpath_text(video_xml
, './track/titleImage', 'thumbnail')
112 for i
, video_file
in enumerate(video_xml
.findall('./track/video/file')):
113 video_key
= self
.parse_video_key(video_file
.get('key', ''))
117 'id': '%s_%s' % (video_id
, video_key
.get('part', i
+ 1)),
119 'upload_date': video_key
.get('upload_date'),
120 'duration': int_or_none(video_file
.get('duration')),
121 'url': video_file
.text
,
127 'uploader': uploader
,
128 'uploader_id': uploader_id
,
129 'duration': duration
,
130 'thumbnail': thumbnail
,
134 info
['_type'] = 'multi_video'
135 info
['entries'] = entries
136 elif len(entries
) == 1:
137 info
['url'] = entries
[0]['url']
138 info
['upload_date'] = entries
[0].get('upload_date')
140 raise ExtractorError(
141 'No files found for the specified AfreecaTV video, either'
142 ' the URL is incorrect or the video has been made private.',