- u'rating information', default='').strip()
- RATINGS = {
- 'G': 0,
- 'PG': 10,
- 'PG-13': 13,
- 'R': 16,
- 'NC': 18,
- }
- age_limit = RATINGS.get(rating_str)
+ 'rating information', default='').strip()
+ age_limit = US_RATINGS.get(rating_str)
+
+ req = compat_urllib_request.Request(
+ 'http://www.viki.com/player5_fragment/%s?action=show&controller=videos' % video_id)
+ req.add_header('User-Agent', self._USER_AGENT)
+ info_webpage = self._download_webpage(
+ req, video_id, note='Downloading info page')
+ err_msg = self._html_search_regex(r'<div[^>]+class="video-error[^>]+>(.+)</div>', info_webpage, 'error message', default=None)
+ if err_msg:
+ if 'not available in your region' in err_msg:
+ raise ExtractorError(
+ 'Video %s is blocked from your location.' % video_id,
+ expected=True)
+ else:
+ raise ExtractorError('Viki said: ' + err_msg)
+ mobj = re.search(
+ r'<source[^>]+type="(?P<mime_type>[^"]+)"[^>]+src="(?P<url>[^"]+)"', info_webpage)
+ if not mobj:
+ raise ExtractorError('Unable to find video URL')
+ video_url = unescapeHTML(mobj.group('url'))
+ video_ext = mimetype2ext(mobj.group('mime_type'))