]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/videott.py
Merge remote-tracking branch 'hojel/hentaistigma'
[youtube-dl.git] / youtube_dl / extractor / videott.py
1 from __future__ import unicode_literals
2
3 import re
4 import base64
5
6 from .common import InfoExtractor
7 from ..utils import unified_strdate
8
9
10 class VideoTtIE(InfoExtractor):
11     ID_NAME = 'video.tt'
12     IE_DESC = 'video.tt - Your True Tube'
13     _VALID_URL = r'http://(?:www\.)?video\.tt/(?:video/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})'
14
15     _TEST = {
16         'url': 'http://www.video.tt/watch_video.php?v=amd5YujV8',
17         'md5': 'b13aa9e2f267effb5d1094443dff65ba',
18         'info_dict': {
19             'id': 'amd5YujV8',
20             'ext': 'flv',
21             'title': 'Motivational video Change your mind in just 2.50 mins',
22             'description': '',
23             'upload_date': '20130827',
24             'uploader': 'joseph313',
25         }
26     }
27
28     def _real_extract(self, url):
29         mobj = re.match(self._VALID_URL, url)
30         video_id = mobj.group('id')
31
32         settings = self._download_json(
33             'http://www.video.tt/player_control/settings.php?v=%s' % video_id, video_id,
34             'Downloading video JSON')['settings']
35
36         video = settings['video_details']['video']
37
38         formats = [
39             {
40                 'url': base64.b64decode(res['u']).decode('utf-8'),
41                 'ext': 'flv',
42                 'format_id': res['l'],
43             } for res in settings['res'] if res['u']
44         ]
45
46         return {
47             'id': video_id,
48             'title': video['title'],
49             'description': video['description'],
50             'thumbnail': settings['config']['thumbnail'],
51             'upload_date': unified_strdate(video['added']),
52             'uploader': video['owner'],
53             'view_count': int(video['view_count']),
54             'comment_count': int(video['comment_count']),
55             'like_count': int(video['liked']),
56             'dislike_count': int(video['disliked']),
57             'formats': formats,
58         }