[testtube] Remove Extractor
This commit is contained in:
parent
054479754c
commit
8af2804a5d
|
@ -9,6 +9,7 @@ from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
qualities,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,12 +20,15 @@ class Revision3IE(InfoExtractor):
|
||||||
'md5': 'd94a72d85d0a829766de4deb8daaf7df',
|
'md5': 'd94a72d85d0a829766de4deb8daaf7df',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '73034',
|
'id': '73034',
|
||||||
|
'display_id': 'technobuffalo/5-google-predictions-for-2016',
|
||||||
'ext': 'webm',
|
'ext': 'webm',
|
||||||
'title': '5 Google Predictions for 2016',
|
'title': '5 Google Predictions for 2016',
|
||||||
'description': 'Google had a great 2015, but it\'s already time to look ahead. Here are our five predictions for 2016.',
|
'description': 'Google had a great 2015, but it\'s already time to look ahead. Here are our five predictions for 2016.',
|
||||||
'upload_date': '20151228',
|
'upload_date': '20151228',
|
||||||
'timestamp': 1451325600,
|
'timestamp': 1451325600,
|
||||||
'duration': 187,
|
'duration': 187,
|
||||||
|
'uploader': 'TechnoBuffalo',
|
||||||
|
'uploader_id': 'technobuffalo',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://testtube.com/brainstuff',
|
'url': 'http://testtube.com/brainstuff',
|
||||||
|
@ -34,6 +38,20 @@ class Revision3IE(InfoExtractor):
|
||||||
'description': 'Whether the topic is popcorn or particle physics, you can count on the HowStuffWorks team to explore-and explain-the everyday science in the world around us on BrainStuff.',
|
'description': 'Whether the topic is popcorn or particle physics, you can count on the HowStuffWorks team to explore-and explain-the everyday science in the world around us on BrainStuff.',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 93,
|
'playlist_mincount': 93,
|
||||||
|
}, {
|
||||||
|
'url': 'https://testtube.com/dnews/5-weird-ways-plants-can-eat-animals?utm_source=FB&utm_medium=DNews&utm_campaign=DNewsSocial',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '60163',
|
||||||
|
'display_id': 'dnews/5-weird-ways-plants-can-eat-animals',
|
||||||
|
'duration': 275,
|
||||||
|
'ext': 'webm',
|
||||||
|
'title': '5 Weird Ways Plants Can Eat Animals',
|
||||||
|
'description': 'Why have some plants evolved to eat meat?',
|
||||||
|
'upload_date': '20150120',
|
||||||
|
'timestamp': 1421763300,
|
||||||
|
'uploader': 'DNews',
|
||||||
|
'uploader_id': 'dnews',
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
_PAGE_DATA_TEMPLATE = 'http://www.%s/apiProxy/ddn/%s?domain=%s'
|
_PAGE_DATA_TEMPLATE = 'http://www.%s/apiProxy/ddn/%s?domain=%s'
|
||||||
_API_KEY = 'ba9c741bce1b9d8e3defcc22193f3651b8867e62'
|
_API_KEY = 'ba9c741bce1b9d8e3defcc22193f3651b8867e62'
|
||||||
|
@ -51,7 +69,7 @@ class Revision3IE(InfoExtractor):
|
||||||
video_id)['items'][0]
|
video_id)['items'][0]
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for media_type, media in video_data['media'].items():
|
for vcodec, media in video_data['media'].items():
|
||||||
for quality_id, quality in media.items():
|
for quality_id, quality in media.items():
|
||||||
if quality_id == 'hls':
|
if quality_id == 'hls':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
@ -60,22 +78,28 @@ class Revision3IE(InfoExtractor):
|
||||||
else:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': quality['url'],
|
'url': quality['url'],
|
||||||
'format_id': '%s-%s' % (media_type, quality_id),
|
'format_id': '%s-%s' % (vcodec, quality_id),
|
||||||
'tbr': int_or_none(quality.get('bitrate')),
|
'tbr': int_or_none(quality.get('bitrate')),
|
||||||
|
'vcodec': vcodec,
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
preference = qualities(['mini', 'small', 'medium', 'large'])
|
||||||
thumbnails = [{
|
thumbnails = [{
|
||||||
'url': image_url,
|
'url': image_url,
|
||||||
'id': image_id,
|
'id': image_id,
|
||||||
|
'preference': preference(image_id)
|
||||||
} for image_id, image_url in video_data.get('images', {}).items()]
|
} for image_id, image_url in video_data.get('images', {}).items()]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
'display_id': display_id,
|
||||||
'title': unescapeHTML(video_data['title']),
|
'title': unescapeHTML(video_data['title']),
|
||||||
'description': unescapeHTML(video_data.get('summary')),
|
'description': unescapeHTML(video_data.get('summary')),
|
||||||
'timestamp': parse_iso8601(episode_data.get('publishTime'), ' '),
|
'timestamp': parse_iso8601(episode_data.get('publishTime'), ' '),
|
||||||
'author': episode_data.get('author'),
|
'author': episode_data.get('author'),
|
||||||
|
'uploader': video_data.get('show', {}).get('name'),
|
||||||
|
'uploader_id': video_data.get('show', {}).get('slug'),
|
||||||
'duration': int_or_none(video_data.get('duration')),
|
'duration': int_or_none(video_data.get('duration')),
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
@ -89,7 +113,7 @@ class Revision3IE(InfoExtractor):
|
||||||
page_num = 1
|
page_num = 1
|
||||||
while True:
|
while True:
|
||||||
entries.extend([self.url_result(
|
entries.extend([self.url_result(
|
||||||
url + '/%s' % episode['slug']) for episode in episodes_data])
|
'http://%s/%s/%s' % (domain, display_id, episode['slug'])) for episode in episodes_data])
|
||||||
processed_episodes += len(episodes_data)
|
processed_episodes += len(episodes_data)
|
||||||
if processed_episodes == num_episodes:
|
if processed_episodes == num_episodes:
|
||||||
break
|
break
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
|
||||||
from ..utils import (
|
|
||||||
int_or_none,
|
|
||||||
qualities,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestTubeIE(InfoExtractor):
|
|
||||||
_VALID_URL = r'https?://testtube\.com/[^/?#]+/(?P<id>[^/?#]+)'
|
|
||||||
_TESTS = [{
|
|
||||||
'url': 'https://testtube.com/dnews/5-weird-ways-plants-can-eat-animals?utm_source=FB&utm_medium=DNews&utm_campaign=DNewsSocial',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '60163',
|
|
||||||
'display_id': '5-weird-ways-plants-can-eat-animals',
|
|
||||||
'duration': 275,
|
|
||||||
'ext': 'webm',
|
|
||||||
'title': '5 Weird Ways Plants Can Eat Animals',
|
|
||||||
'description': 'Why have some plants evolved to eat meat?',
|
|
||||||
'thumbnail': 're:^https?://.*\.jpg$',
|
|
||||||
'uploader': 'DNews',
|
|
||||||
'uploader_id': 'dnews',
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
'url': 'https://testtube.com/iflscience/insane-jet-ski-flipping',
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'fAGfJ4YjVus',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Flipping Jet-Ski Skills | Outrageous Acts of Science',
|
|
||||||
'uploader': 'Science Channel',
|
|
||||||
'uploader_id': 'ScienceChannel',
|
|
||||||
'upload_date': '20150203',
|
|
||||||
'description': 'md5:e61374030015bae1d2e22f096d4769d6',
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
|
||||||
display_id = self._match_id(url)
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, display_id)
|
|
||||||
|
|
||||||
youtube_url = self._html_search_regex(
|
|
||||||
r'<iframe[^>]+src="((?:https?:)?//www.youtube.com/embed/[^"]+)"',
|
|
||||||
webpage, 'youtube iframe', default=None)
|
|
||||||
if youtube_url:
|
|
||||||
return self.url_result(youtube_url, 'Youtube', video_id=display_id)
|
|
||||||
|
|
||||||
video_id = self._search_regex(
|
|
||||||
r"player\.loadRevision3Item\('video_id',\s*([0-9]+)\);",
|
|
||||||
webpage, 'video ID')
|
|
||||||
|
|
||||||
all_info = self._download_json(
|
|
||||||
'https://testtube.com/api/getPlaylist.json?api_key=ba9c741bce1b9d8e3defcc22193f3651b8867e62&codecs=h264,vp8,theora&video_id=%s' % video_id,
|
|
||||||
video_id)
|
|
||||||
info = all_info['items'][0]
|
|
||||||
|
|
||||||
formats = []
|
|
||||||
for vcodec, fdatas in info['media'].items():
|
|
||||||
for name, fdata in fdatas.items():
|
|
||||||
formats.append({
|
|
||||||
'format_id': '%s-%s' % (vcodec, name),
|
|
||||||
'url': fdata['url'],
|
|
||||||
'vcodec': vcodec,
|
|
||||||
'tbr': fdata.get('bitrate'),
|
|
||||||
})
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
duration = int_or_none(info.get('duration'))
|
|
||||||
images = info.get('images')
|
|
||||||
thumbnails = None
|
|
||||||
preference = qualities(['mini', 'small', 'medium', 'large'])
|
|
||||||
if images:
|
|
||||||
thumbnails = [{
|
|
||||||
'id': thumbnail_id,
|
|
||||||
'url': img_url,
|
|
||||||
'preference': preference(thumbnail_id)
|
|
||||||
} for thumbnail_id, img_url in images.items()]
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': video_id,
|
|
||||||
'display_id': display_id,
|
|
||||||
'title': info['title'],
|
|
||||||
'description': info.get('summary'),
|
|
||||||
'thumbnails': thumbnails,
|
|
||||||
'uploader': info.get('show', {}).get('name'),
|
|
||||||
'uploader_id': info.get('show', {}).get('slug'),
|
|
||||||
'duration': duration,
|
|
||||||
'formats': formats,
|
|
||||||
}
|
|
Loading…
Reference in New Issue