From 1ad6a502be3704971434e4e3883653ffc9a6250d Mon Sep 17 00:00:00 2001 From: alrii Date: Thu, 8 Mar 2018 01:45:13 -0500 Subject: [PATCH] [estream] Add new extractor --- youtube_dl/extractor/estream.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/youtube_dl/extractor/estream.py b/youtube_dl/extractor/estream.py index 439c2cd44..fea0affaf 100644 --- a/youtube_dl/extractor/estream.py +++ b/youtube_dl/extractor/estream.py @@ -10,6 +10,7 @@ from ..utils import ( ExtractorError, ) + class EstreamIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?estream\.to(?:/embed\-|/)(?P\w+)\.html' _TESTS = [{ @@ -20,6 +21,7 @@ class EstreamIE(InfoExtractor): 'ext': 'mp4', 'title': 'Watch giphy mp4', }, + }, { 'url': 'https://estream.to/embed-0vorujhi39p7.html', 'md5': '47580f5a1f265d1ad6ce8b4775efa702', 'info_dict': { @@ -27,8 +29,8 @@ class EstreamIE(InfoExtractor): 'ext': 'mp4', 'title': 'Looking up at Palm Trees (Free to Use HD Stock Video Footage) DHNqqSlSs8A', }, - - },] + + }, ] @staticmethod def _extract_dim(res): @@ -42,35 +44,35 @@ class EstreamIE(InfoExtractor): webpage = self._download_webpage(url, video_id) if re.search(r'', webpage): - title = self._html_search_regex(r'<title>(.+?)',webpage, 'title') + title = self._html_search_regex(r'(.+?)', webpage, 'title') else: - title = self._html_search_regex(r'',webpage, 'title') + title = self._html_search_regex(r'', webpage, 'title') width, height = None, None formats = [] for format_ in re.findall(r'', webpage): - source = re.search(r'''src\=\"(?P.+)\"\stype\='(?P.+?)\'''',format_) - + source = re.search(r'''src\=\"(?P.+)\"\stype\='(?P.+?)\'''', format_) + ext = determine_ext(source.group('src'), default_ext=None) - res = re.search(r'''res\=\'(?P.+)\'''',format_) + res = re.search(r'''res\=\'(?P.+)\'''', format_) if res is not None: width, height = self._extract_dim(res.group('res')) - + formats.append({ - 'url': source.group('src'), - 'ext': ext or 'mp4', - 'width': int_or_none(width), - 'height': int_or_none(height), - }) + 'url': source.group('src'), + 'ext': ext or 'mp4', + 'width': int_or_none(width), + 'height': int_or_none(height), + }) if not formats: if 'File not found' in webpage or 'deleted' in webpage: raise ExtractorError('File not found', expected=True, video_id=video_id) - + self._sort_formats(formats) return { 'id': video_id, 'title': title, 'formats': formats, - } \ No newline at end of file + }