]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/videott.py
Add support for https for all extractors as preventive and future-proof measure
[yt-dlp.git] / youtube_dl / extractor / videott.py
CommitLineData
55b36e37
S
1from __future__ import unicode_literals
2
3import re
4import base64
5
6from .common import InfoExtractor
d410fee9
PP
7from ..utils import (
8 unified_strdate,
9 int_or_none,
10)
55b36e37
S
11
12
13class VideoTtIE(InfoExtractor):
b924bfad 14 _WORKING = False
55b36e37
S
15 ID_NAME = 'video.tt'
16 IE_DESC = 'video.tt - Your True Tube'
5886b38d 17 _VALID_URL = r'https?://(?:www\.)?video\.tt/(?:(?:video|embed)/|watch_video\.php\?v=)(?P<id>[\da-zA-Z]{9})'
55b36e37 18
fc2d6abf 19 _TESTS = [{
55b36e37
S
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 }
fc2d6abf
S
30 }, {
31 'url': 'http://video.tt/embed/amd5YujV8',
32 'only_matching': True,
33 }]
55b36e37
S
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 {
5cd47a5e 47 'url': base64.b64decode(res['u'].encode('utf-8')).decode('utf-8'),
55b36e37
S
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'],
d410fee9
PP
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']),
55b36e37 64 'formats': formats,
5f6a1245 65 }