1 from __future__ import unicode_literals
3 from .common import InfoExtractor
10 class TestTubeIE(InfoExtractor):
11 _VALID_URL = r'https?://testtube\.com/[^/?#]+/(?P<id>[^/?#]+)'
13 'url': 'https://testtube.com/dnews/5-weird-ways-plants-can-eat-animals?utm_source=FB&utm_medium=DNews&utm_campaign=DNewsSocial',
16 'display_id': '5-weird-ways-plants-can-eat-animals',
19 'title': '5 Weird Ways Plants Can Eat Animals',
20 'description': 'Why have some plants evolved to eat meat?',
21 'thumbnail': 're:^https?://.*\.jpg$',
23 'uploader_id': 'dnews',
27 def _real_extract(self, url):
28 display_id = self._match_id(url)
30 webpage = self._download_webpage(url, display_id)
31 video_id = self._search_regex(
32 r"player\.loadRevision3Item\('video_id',\s*([0-9]+)\);",
35 all_info = self._download_json(
36 'https://testtube.com/api/getPlaylist.json?api_key=ba9c741bce1b9d8e3defcc22193f3651b8867e62&codecs=h264,vp8,theora&video_id=%s' % video_id,
38 info = all_info['items'][0]
41 for vcodec, fdatas in info['media'].items():
42 for name, fdata in fdatas.items():
44 'format_id': '%s-%s' % (vcodec, name),
47 'tbr': fdata.get('bitrate'),
49 self._sort_formats(formats)
51 duration = int_or_none(info.get('duration'))
52 images = info.get('images')
54 preference = qualities(['mini', 'small', 'medium', 'large'])
59 'preference': preference(thumbnail_id)
60 } for thumbnail_id, img_url in images.items()]
64 'display_id': display_id,
65 'title': info['title'],
66 'description': info.get('summary'),
67 'thumbnails': thumbnails,
68 'uploader': info.get('show', {}).get('name'),
69 'uploader_id': info.get('show', {}).get('slug'),