| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  | from ..utils import determine_ext | 
					
						
							| 
									
										
										
										
											2014-02-02 12:03:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  | _translation_table = { | 
					
						
							| 
									
										
										
										
											2014-01-27 12:39:39 +01:00
										 |  |  |     'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n', | 
					
						
							|  |  |  |     'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r', | 
					
						
							|  |  |  |     'y': 'l', 'z': 'i', | 
					
						
							|  |  |  |     '$': ':', '&': '.', '(': '=', '^': '&', '=': '/', | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  | def _decode(s): | 
					
						
							|  |  |  |     return ''.join(_translation_table.get(c, c) for c in s) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | class CliphunterIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  |     IE_NAME = 'cliphunter' | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-27 12:39:39 +01:00
										 |  |  |     _VALID_URL = r'''(?x)http://(?:www\.)?cliphunter\.com/w/
 | 
					
						
							|  |  |  |         (?P<id>[0-9]+)/ | 
					
						
							|  |  |  |         (?P<seo>.+?)(?:$|[#\?]) | 
					
						
							|  |  |  |     '''
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  |         'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo', | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  |         'md5': 'b7c9bbd4eb3a226ab91093714dcaa480', | 
					
						
							| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             'id': '1012420', | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  |             'ext': 'flv', | 
					
						
							| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  |             'title': 'Fun Jynx Maze solo', | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             'thumbnail': 're:^https?://.*\.jpg$', | 
					
						
							|  |  |  |             'age_limit': 18, | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-01-27 07:55:30 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-10-26 23:13:42 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |         video_title = self._search_regex( | 
					
						
							|  |  |  |             r'mediaTitle = "([^"]+)"', webpage, 'title') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  |         fmts = {} | 
					
						
							|  |  |  |         for fmt in ('mp4', 'flv'): | 
					
						
							|  |  |  |             fmt_list = self._parse_json(self._search_regex( | 
					
						
							|  |  |  |                 r'var %sjson\s*=\s*(\[.*?\]);' % fmt, webpage, '%s formats' % fmt), video_id) | 
					
						
							|  |  |  |             for f in fmt_list: | 
					
						
							|  |  |  |                 fmts[f['fname']] = _decode(f['sUrl']) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         qualities = self._parse_json(self._search_regex( | 
					
						
							|  |  |  |             r'var player_btns\s*=\s*(.*?);\n', webpage, 'quality info'), video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         formats = [] | 
					
						
							|  |  |  |         for fname, url in fmts.items(): | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             f = { | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  |                 'url': url, | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  |             if fname in qualities: | 
					
						
							|  |  |  |                 qual = qualities[fname] | 
					
						
							|  |  |  |                 f.update({ | 
					
						
							|  |  |  |                     'format_id': '%s_%sp' % (determine_ext(url), qual['h']), | 
					
						
							|  |  |  |                     'width': qual['w'], | 
					
						
							|  |  |  |                     'height': qual['h'], | 
					
						
							|  |  |  |                     'tbr': qual['br'], | 
					
						
							|  |  |  |                 }) | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             formats.append(f) | 
					
						
							| 
									
										
										
										
											2015-01-23 21:22:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |         self._sort_formats(formats) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         thumbnail = self._search_regex( | 
					
						
							|  |  |  |             r"var\s+mov_thumb\s*=\s*'([^']+)';", | 
					
						
							|  |  |  |             webpage, 'thumbnail', fatal=False) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'title': video_title, | 
					
						
							|  |  |  |             'formats': formats, | 
					
						
							| 
									
										
										
										
											2014-09-04 06:40:15 +02:00
										 |  |  |             'age_limit': self._rta_search(webpage), | 
					
						
							|  |  |  |             'thumbnail': thumbnail, | 
					
						
							| 
									
										
										
										
											2014-01-25 01:46:52 +01:00
										 |  |  |         } |