[estream] Add new extractor

This commit is contained in:
alrii 2018-03-08 01:45:13 -05:00
parent 5cb31f9970
commit 1ad6a502be

View File

@ -10,6 +10,7 @@ from ..utils import (
ExtractorError, ExtractorError,
) )
class EstreamIE(InfoExtractor): class EstreamIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?estream\.to(?:/embed\-|/)(?P<id>\w+)\.html' _VALID_URL = r'https?://(?:www\.)?estream\.to(?:/embed\-|/)(?P<id>\w+)\.html'
_TESTS = [{ _TESTS = [{
@ -20,6 +21,7 @@ class EstreamIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Watch giphy mp4', 'title': 'Watch giphy mp4',
}, },
}, {
'url': 'https://estream.to/embed-0vorujhi39p7.html', 'url': 'https://estream.to/embed-0vorujhi39p7.html',
'md5': '47580f5a1f265d1ad6ce8b4775efa702', 'md5': '47580f5a1f265d1ad6ce8b4775efa702',
'info_dict': { 'info_dict': {
@ -27,8 +29,8 @@ class EstreamIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Looking up at Palm Trees (Free to Use HD Stock Video Footage) DHNqqSlSs8A', 'title': 'Looking up at Palm Trees (Free to Use HD Stock Video Footage) DHNqqSlSs8A',
}, },
},] }, ]
@staticmethod @staticmethod
def _extract_dim(res): def _extract_dim(res):
@ -42,35 +44,35 @@ class EstreamIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
if re.search(r'<title>', webpage): if re.search(r'<title>', webpage):
title = self._html_search_regex(r'<title>(.+?)</title>',webpage, 'title') title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
else: else:
title = self._html_search_regex(r'<video.+\=\"(.+)\"\s>',webpage, 'title') title = self._html_search_regex(r'<video.+\=\"(.+)\"\s>', webpage, 'title')
width, height = None, None width, height = None, None
formats = [] formats = []
for format_ in re.findall(r'<source\s(.*)/>', webpage): for format_ in re.findall(r'<source\s(.*)/>', webpage):
source = re.search(r'''src\=\"(?P<src>.+)\"\stype\='(?P<type>.+?)\'''',format_) source = re.search(r'''src\=\"(?P<src>.+)\"\stype\='(?P<type>.+?)\'''', format_)
ext = determine_ext(source.group('src'), default_ext=None) ext = determine_ext(source.group('src'), default_ext=None)
res = re.search(r'''res\=\'(?P<res>.+)\'''',format_) res = re.search(r'''res\=\'(?P<res>.+)\'''', format_)
if res is not None: if res is not None:
width, height = self._extract_dim(res.group('res')) width, height = self._extract_dim(res.group('res'))
formats.append({ formats.append({
'url': source.group('src'), 'url': source.group('src'),
'ext': ext or 'mp4', 'ext': ext or 'mp4',
'width': int_or_none(width), 'width': int_or_none(width),
'height': int_or_none(height), 'height': int_or_none(height),
}) })
if not formats: if not formats:
if 'File not found' in webpage or 'deleted' in webpage: if 'File not found' in webpage or 'deleted' in webpage:
raise ExtractorError('File not found', expected=True, video_id=video_id) raise ExtractorError('File not found', expected=True, video_id=video_id)
self._sort_formats(formats) self._sort_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'formats': formats, 'formats': formats,
} }