]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videott.py
debian/control: Add recommends on aria2 | wget | curl to use external downloaders.
[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|embed)/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})'
17
18 _TESTS = [{
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 'url': 'http://video.tt/embed/amd5YujV8',
31 'only_matching': True,
32 }]
33
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
36 video_id = mobj.group('id')
37
38 settings = self._download_json(
39 'http://www.video.tt/player_control/settings.php?v=%s' % video_id, video_id,
40 'Downloading video JSON')['settings']
41
42 video = settings['video_details']['video']
43
44 formats = [
45 {
46 'url': base64.b64decode(res['u']).decode('utf-8'),
47 'ext': 'flv',
48 'format_id': res['l'],
49 } for res in settings['res'] if res['u']
50 ]
51
52 return {
53 'id': video_id,
54 'title': video['title'],
55 'description': video['description'],
56 'thumbnail': settings['config']['thumbnail'],
57 'upload_date': unified_strdate(video['added']),
58 'uploader': video['owner'],
59 'view_count': int_or_none(video['view_count']),
60 'comment_count': None if video.get('comment_count') == '--' else int_or_none(video['comment_count']),
61 'like_count': int_or_none(video['liked']),
62 'dislike_count': int_or_none(video['disliked']),
63 'formats': formats,
64 }