]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videott.py
debian/changelog: Start new release.
[youtubedl] / 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 (
8 unified_strdate,
9 int_or_none,
10 )
11
12
13 class VideoTtIE(InfoExtractor):
14 ID_NAME = 'video.tt'
15 IE_DESC = 'video.tt - Your True Tube'
16 _VALID_URL = r'http://(?:www\.)?video\.tt/(?:video/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})'
17
18 _TEST = {
19 'url': 'http://www.video.tt/watch_video.php?v=amd5YujV8',
20 'md5': 'b13aa9e2f267effb5d1094443dff65ba',
21 'info_dict': {
22 'id': 'amd5YujV8',
23 'ext': 'flv',
24 'title': 'Motivational video Change your mind in just 2.50 mins',
25 'description': '',
26 'upload_date': '20130827',
27 'uploader': 'joseph313',
28 }
29 }
30
31 def _real_extract(self, url):
32 mobj = re.match(self._VALID_URL, url)
33 video_id = mobj.group('id')
34
35 settings = self._download_json(
36 'http://www.video.tt/player_control/settings.php?v=%s' % video_id, video_id,
37 'Downloading video JSON')['settings']
38
39 video = settings['video_details']['video']
40
41 formats = [
42 {
43 'url': base64.b64decode(res['u']).decode('utf-8'),
44 'ext': 'flv',
45 'format_id': res['l'],
46 } for res in settings['res'] if res['u']
47 ]
48
49 return {
50 'id': video_id,
51 'title': video['title'],
52 'description': video['description'],
53 'thumbnail': settings['config']['thumbnail'],
54 'upload_date': unified_strdate(video['added']),
55 'uploader': video['owner'],
56 'view_count': int_or_none(video['view_count']),
57 'comment_count': None if video.get('comment_count') == '--' else int_or_none(video['comment_count']),
58 'like_count': int_or_none(video['liked']),
59 'dislike_count': int_or_none(video['disliked']),
60 'formats': formats,
61 }