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