2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class MgoonIE(InfoExtractor):
15 _VALID_URL = r'''(?x)https?://(?:www\.)?
16 (?:(:?m\.)?mgoon\.com/(?:ch/(?:.+)/v|play/view)|
17 video\.mgoon\.com)/(?P<id>[0-9]+)'''
18 _API_URL = 'http://mpos.mgoon.com/player/video?id={0:}'
21 'url': 'http://m.mgoon.com/ch/hi6618/v/5582148',
22 'md5': 'dd46bb66ab35cf6d51cc812fd82da79d',
25 'uploader_id': 'hi6618',
27 'upload_date': '20131220',
29 'title': 'md5:543aa4c27a4931d371c3f433e8cebebc',
30 'thumbnail': 're:^https?://.*\.jpg$',
34 'url': 'http://www.mgoon.com/play/view/5582148',
35 'only_matching': True,
38 'url': 'http://video.mgoon.com/5582148',
39 'only_matching': True,
43 def _real_extract(self, url):
44 mobj = re.match(self._VALID_URL, url)
45 video_id = mobj.group('id')
47 data = self._download_json(self._API_URL.format(video_id), video_id)
49 if data.get('errorInfo', {}).get('code') != 'NONE':
50 raise ExtractorError('%s encountered an error: %s' % (
51 self.IE_NAME, data['errorInfo']['message']), expected=True)
53 v_info = data['videoInfo']
54 title = v_info.get('v_title')
55 thumbnail = v_info.get('v_thumbnail')
56 duration = v_info.get('v_duration')
57 upload_date = unified_strdate(v_info.get('v_reg_date'))
58 uploader_id = data.get('userInfo', {}).get('u_alias')
63 if data.get('accessInfo', {}).get('code') == 'VIDEO_STATUS_ADULT':
67 get_quality = qualities(['360p', '480p', '720p', '1080p'])
68 for fmt in data['videoFiles']:
70 'format_id': fmt['label'],
71 'quality': get_quality(fmt['label']),
76 self._sort_formats(formats)
82 'thumbnail': thumbnail,
84 'upload_date': upload_date,
85 'uploader_id': uploader_id,
86 'age_limit': age_limit,