| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2016-03-26 01:46:57 +06:00
										 |  |  | from ..compat import compat_urllib_parse_urlencode | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MuzuTVIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2013-12-04 20:34:47 +07:00
										 |  |  |     _VALID_URL = r'https?://www\.muzu\.tv/(.+?)/(.+?)/(?P<id>\d+)' | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |     IE_NAME = 'muzu.tv' | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |         'url': 'http://www.muzu.tv/defected/marcashken-featuring-sos-cat-walk-original-mix-music-video/1981454/', | 
					
						
							|  |  |  |         'md5': '98f8b2c7bc50578d6a0364fff2bfb000', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '1981454', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Cat Walk (Original Mix)', | 
					
						
							|  |  |  |             'description': 'md5:90e868994de201b2570e4e5854e19420', | 
					
						
							|  |  |  |             'uploader': 'MarcAshken featuring SOS', | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  |         }, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 01:46:57 +06:00
										 |  |  |         info_data = compat_urllib_parse_urlencode({ | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |             'format': 'json', | 
					
						
							|  |  |  |             'url': url, | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         info = self._download_json( | 
					
						
							|  |  |  |             'http://www.muzu.tv/api/oembed/?%s' % info_data, | 
					
						
							|  |  |  |             video_id, 'Downloading video info') | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |         player_info = self._download_json( | 
					
						
							|  |  |  |             'http://player.muzu.tv/player/playerInit?ai=%s' % video_id, | 
					
						
							|  |  |  |             video_id, 'Downloading player info') | 
					
						
							|  |  |  |         video_info = player_info['videos'][0] | 
					
						
							| 
									
										
										
										
											2014-11-23 20:41:03 +01:00
										 |  |  |         for quality in ['1080', '720', '480', '360']: | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  |             if video_info.get('v%s' % quality): | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 01:46:57 +06:00
										 |  |  |         data = compat_urllib_parse_urlencode({ | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |             'ai': video_id, | 
					
						
							|  |  |  |             # Even if each time you watch a video the hash changes, | 
					
						
							|  |  |  |             # it seems to work for different videos, and it will work | 
					
						
							|  |  |  |             # even if you use any non empty string as a hash | 
					
						
							|  |  |  |             'viewhash': 'VBNff6djeV4HV5TRPW5kOHub2k', | 
					
						
							|  |  |  |             'device': 'web', | 
					
						
							|  |  |  |             'qv': quality, | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         video_url_info = self._download_json( | 
					
						
							|  |  |  |             'http://player.muzu.tv/player/requestVideo?%s' % data, | 
					
						
							|  |  |  |             video_id, 'Downloading video url') | 
					
						
							| 
									
										
										
										
											2013-08-04 11:10:57 +02:00
										 |  |  |         video_url = video_url_info['url'] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-26 12:50:37 +01:00
										 |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'title': info['title'], | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'thumbnail': info['thumbnail_url'], | 
					
						
							|  |  |  |             'description': info['description'], | 
					
						
							|  |  |  |             'uploader': info['author_name'], | 
					
						
							|  |  |  |         } |