From a0e59904a61fad03dd6cd1de471ac31f8bed8089 Mon Sep 17 00:00:00 2001 From: SpiderRider067 Date: Tue, 12 Jan 2021 05:11:31 -0500 Subject: [PATCH 1/4] [Youvi] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/youvi.py | 54 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 youtube_dl/extractor/youvi.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 57d4d319cd7..4532ca529ff 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1567,6 +1567,7 @@ YoutubeYtUserIE, YoutubeWatchLaterIE, ) +from .youvi import YouviIE from .zapiks import ZapiksIE from .zattoo import ( BBVTVIE, diff --git a/youtube_dl/extractor/youvi.py b/youtube_dl/extractor/youvi.py new file mode 100644 index 00000000000..27ed2e4d42b --- /dev/null +++ b/youtube_dl/extractor/youvi.py @@ -0,0 +1,54 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class YouviIE(InfoExtractor): + _VALID_URL = r'https://youvi.ru/post/(?P.*)' + _TEST = { + 'url': 'https://youvi.ru/post/Ni2BmFhUwUt', + 'md5': '510062b5b3f32f6ba2f6888607d7a434', + 'info_dict': { + 'id': 'Ni2BmFhUwUt', + 'ext': 'mp4', + 'title': 'TikTok показал собственный спецэффект для IPhone 12 Pro, использующий датчик LiDAR.', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + title = self._search_regex( + r'title:"(?P[^"]+)"', webpage, 'title') + + formats = [] + for url_type in ('url', 'hls'): + url = self._search_regex( + r'source_file:[^}]+(?:%s):"(?P<url>[^"]+?)"' % url_type, + webpage, 'youvi-hosted-url', fatal=False) + if url: + url = url.replace(r'\u002F', r'/') + format_entry = {'url': url} + formats.append(format_entry) + self._sort_formats(formats) + + if formats: + return { + 'id': video_id, + 'title': title, + 'formats': formats, + } + + else: + external_embed = self._search_regex( + r'service_type:"(?P<embed>[^"]+?)"', webpage, 'external-embed') + external_id = self._search_regex( + r'external_id:"(?P<id>[^"]+?)"', webpage, 'external-id') + + if external_embed == 'youtube': + return self.url_result(external_id, 'Youtube') + + elif external_embed == 'vimeo': + return self.url_result( + 'https://vimeo.com/' + external_id, 'Vimeo') From 6eea4f795a6afcd6a0348f55d7e7f43ac287da2d Mon Sep 17 00:00:00 2001 From: SpiderRider067 <36859584+SpiderRider067@users.noreply.github.com> Date: Tue, 12 Jan 2021 05:18:45 -0500 Subject: [PATCH 2/4] Update youvi.py --- youtube_dl/extractor/youvi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/youvi.py b/youtube_dl/extractor/youvi.py index 27ed2e4d42b..fbb9ccd2a5a 100644 --- a/youtube_dl/extractor/youvi.py +++ b/youtube_dl/extractor/youvi.py @@ -31,9 +31,10 @@ def _real_extract(self, url): url = url.replace(r'\u002F', r'/') format_entry = {'url': url} formats.append(format_entry) - self._sort_formats(formats) + if formats: + self._sort_formats(formats) return { 'id': video_id, 'title': title, From 33d53730207456ba64eb0f5ee097844ae07efef9 Mon Sep 17 00:00:00 2001 From: SpiderRider067 <36859584+SpiderRider067@users.noreply.github.com> Date: Tue, 12 Jan 2021 05:24:38 -0500 Subject: [PATCH 3/4] Update youvi.py --- youtube_dl/extractor/youvi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/youvi.py b/youtube_dl/extractor/youvi.py index fbb9ccd2a5a..e4e112fa1ba 100644 --- a/youtube_dl/extractor/youvi.py +++ b/youtube_dl/extractor/youvi.py @@ -32,7 +32,6 @@ def _real_extract(self, url): format_entry = {'url': url} formats.append(format_entry) - if formats: self._sort_formats(formats) return { From c3992b42c5c3a34bf55a388e4c84fd32e5a5a63a Mon Sep 17 00:00:00 2001 From: SpiderRider067 <36859584+SpiderRider067@users.noreply.github.com> Date: Tue, 12 Jan 2021 05:25:38 -0500 Subject: [PATCH 4/4] Update youvi.py --- youtube_dl/extractor/youvi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/youvi.py b/youtube_dl/extractor/youvi.py index e4e112fa1ba..1f2b5b91b15 100644 --- a/youtube_dl/extractor/youvi.py +++ b/youtube_dl/extractor/youvi.py @@ -39,7 +39,6 @@ def _real_extract(self, url): 'title': title, 'formats': formats, } - else: external_embed = self._search_regex( r'service_type:"(?P<embed>[^"]+?)"', webpage, 'external-embed')