1 from __future__ import unicode_literals
5 from .common import InfoExtractor
8 compat_urllib_parse_urlencode,
9 compat_urllib_parse_urlparse,
19 class FiveMinIE(InfoExtractor):
21 _VALID_URL = r'(?:5min:(?P<id>\d+)(?::(?P<sid>\d+))?|https?://[^/]*?5min\.com/Scripts/PlayerSeed\.js\?(?P<query>.*))'
25 # From http://www.engadget.com/2013/11/15/ipad-mini-retina-display-review/
26 'url': 'http://pshared.5min.com/Scripts/PlayerSeed.js?sid=281&width=560&height=345&playList=518013791',
27 'md5': '4f7b0b79bf1a470e5004f7112385941d',
31 'title': 'iPad Mini with Retina Display Review',
36 # From http://on.aol.com/video/how-to-make-a-next-level-fruit-salad-518086247
37 'url': '5min:518086247',
38 'md5': 'e539a9dd682c288ef5a498898009f69e',
42 'title': 'How to Make a Next-Level Fruit Salad',
45 'skip': 'no longer available',
49 'ErrorVideoNotExist': 'We\'re sorry, but the video you are trying to watch does not exist.',
50 'ErrorVideoNoLongerAvailable': 'We\'re sorry, but the video you are trying to watch is no longer available.',
51 'ErrorVideoRejected': 'We\'re sorry, but the video you are trying to watch has been removed.',
52 'ErrorVideoUserNotGeo': 'We\'re sorry, but the video you are trying to watch cannot be viewed from your current location.',
53 'ErrorVideoLibraryRestriction': 'We\'re sorry, but the video you are trying to watch is currently unavailable for viewing at this domain.',
54 'ErrorExposurePermission': 'We\'re sorry, but the video you are trying to watch is currently unavailable for viewing at this domain.',
91 def _real_extract(self, url):
92 mobj = re.match(self._VALID_URL, url)
93 video_id = mobj.group('id')
94 sid = mobj.group('sid')
96 if mobj.group('query'):
97 qs = compat_parse_qs(mobj.group('query'))
98 if not qs.get('playList'):
99 raise ExtractorError('Invalid URL', expected=True)
100 video_id = qs['playList'][0]
104 embed_url = 'https://embed.5min.com/playerseed/?playList=%s' % video_id
106 embed_page = self._download_webpage(embed_url, video_id,
107 'Downloading embed page')
108 sid = self._search_regex(r'sid=(\d+)', embed_page, 'sid')
110 response = self._download_json(
111 'https://syn.5min.com/handlers/SenseHandler.ashx?' +
112 compat_urllib_parse_urlencode({
113 'func': 'GetResults',
114 'playlist': video_id,
116 'isPlayerSeed': 'true',
120 if not response['success']:
121 raise ExtractorError(
124 self._ERRORS.get(response['errorMessage'], response['errorMessage'])),
126 info = response['binding'][0]
129 parsed_video_url = compat_urllib_parse_urlparse(compat_parse_qs(
130 compat_urllib_parse_urlparse(info['EmbededURL']).query)['videoUrl'][0])
131 for rendition in info['Renditions']:
132 if rendition['RenditionType'] == 'aac' or rendition['RenditionType'] == 'm3u8':
135 rendition_url = compat_urlparse.urlunparse(parsed_video_url._replace(path=replace_extension(parsed_video_url.path.replace('//', '/%s/' % rendition['ID']), rendition['RenditionType'])))
136 quality = self._QUALITIES.get(rendition['ID'], {})
138 'format_id': '%s-%d' % (rendition['RenditionType'], rendition['ID']),
139 'url': rendition_url,
140 'width': quality.get('width'),
141 'height': quality.get('height'),
143 self._sort_formats(formats)
147 'title': info['Title'],
148 'thumbnail': info.get('ThumbURL'),
149 'duration': parse_duration(info.get('Duration')),