| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import re | 
					
						
							|  |  |  | import base64 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2014-06-26 07:35:47 +02:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     unified_strdate, | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class VideoTtIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2016-01-11 21:58:32 +06:00
										 |  |  |     _WORKING = False | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  |     ID_NAME = 'video.tt' | 
					
						
							|  |  |  |     IE_DESC = 'video.tt - Your True Tube' | 
					
						
							| 
									
										
										
										
											2016-03-21 21:36:32 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?video\.tt/(?:(?:video|embed)/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})' | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-24 16:11:40 +06:00
										 |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  |         'url': 'http://www.video.tt/watch_video.php?v=amd5YujV8', | 
					
						
							|  |  |  |         'md5': 'b13aa9e2f267effb5d1094443dff65ba', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': 'amd5YujV8', | 
					
						
							|  |  |  |             'ext': 'flv', | 
					
						
							|  |  |  |             'title': 'Motivational video Change your mind in just 2.50 mins', | 
					
						
							|  |  |  |             'description': '', | 
					
						
							|  |  |  |             'upload_date': '20130827', | 
					
						
							|  |  |  |             'uploader': 'joseph313', | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-24 16:11:40 +06:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://video.tt/embed/amd5YujV8', | 
					
						
							|  |  |  |         'only_matching': True, | 
					
						
							|  |  |  |     }] | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         mobj = re.match(self._VALID_URL, url) | 
					
						
							|  |  |  |         video_id = mobj.group('id') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         settings = self._download_json( | 
					
						
							|  |  |  |             'http://www.video.tt/player_control/settings.php?v=%s' % video_id, video_id, | 
					
						
							|  |  |  |             'Downloading video JSON')['settings'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         video = settings['video_details']['video'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         formats = [ | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2015-05-21 23:58:46 +06:00
										 |  |  |                 'url': base64.b64decode(res['u'].encode('utf-8')).decode('utf-8'), | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  |                 'ext': 'flv', | 
					
						
							|  |  |  |                 'format_id': res['l'], | 
					
						
							|  |  |  |             } for res in settings['res'] if res['u'] | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'title': video['title'], | 
					
						
							|  |  |  |             'description': video['description'], | 
					
						
							|  |  |  |             'thumbnail': settings['config']['thumbnail'], | 
					
						
							|  |  |  |             'upload_date': unified_strdate(video['added']), | 
					
						
							|  |  |  |             'uploader': video['owner'], | 
					
						
							| 
									
										
										
										
											2014-06-26 07:35:47 +02:00
										 |  |  |             'view_count': int_or_none(video['view_count']), | 
					
						
							|  |  |  |             'comment_count': None if video.get('comment_count') == '--' else int_or_none(video['comment_count']), | 
					
						
							|  |  |  |             'like_count': int_or_none(video['liked']), | 
					
						
							|  |  |  |             'dislike_count': int_or_none(video['disliked']), | 
					
						
							| 
									
										
										
										
											2014-05-12 20:23:08 +07:00
										 |  |  |             'formats': formats, | 
					
						
							| 
									
										
										
										
											2014-11-23 20:41:03 +01:00
										 |  |  |         } |