From 3e5b6a254234fafa2bf52900bb63e63ce74acf05 Mon Sep 17 00:00:00 2001 From: MaximZ21 Date: Thu, 12 Mar 2020 09:33:13 +0600 Subject: [PATCH] [Vlaretv] Add new extractor --- youtube_dl/extractor/extractors.py | 5 ++ youtube_dl/extractor/vlaretv.py | 87 ++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 youtube_dl/extractor/vlaretv.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 64d1fa251..fb2672543 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1341,6 +1341,11 @@ from .vk import ( VKUserVideosIE, VKWallPostIE, ) +from .vlaretv import ( + VlaretvIE, + VlaretvPlaylistIE +) + from .vlive import ( VLiveIE, VLiveChannelIE, diff --git a/youtube_dl/extractor/vlaretv.py b/youtube_dl/extractor/vlaretv.py new file mode 100644 index 000000000..a118120e7 --- /dev/null +++ b/youtube_dl/extractor/vlaretv.py @@ -0,0 +1,87 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +import re + + +class VlaretvIE(InfoExtractor): + _VALID_URL = r'https?:\/\/vlare.tv\/v\/(?P[0-9a-zA-Z]+)' + IE_NAME = 'vlare.tv' + _TESTS = [ + { + 'url': 'https://vlare.tv/v/cTQKAh0z', + 'info_dict': { + 'id': 'cTQKAh0z', + 'ext': 'mp4', + 'title': 'Interspecies Reviewers Abridged | One Shot (Parody)', + } + }, + { + 'url': 'https://vlare.tv/v/HSzfUoye', + 'info_dict': { + 'id': 'HSzfUoye', + 'ext': 'mp4', + 'title': 'Quake II (1997) - Gameplay AMD K6-III+ and 3dfx Voodoo Banshee', + } + }, + { + 'url': 'https://vlare.tv/v/t7XSuZfK/2568', + 'info_dict': { + 'id': 'HSzfUoye', + 'ext': 'mp4', + 'title': 'Quake II (1997) - Gameplay AMD K6-III+ and 3dfx Voodoo Banshee', + } + } + ] + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + title = self._html_search_regex(r'(.+?)<\/title>', webpage, 'title').replace(' | Vlare', '') + video_urls = self._html_search_regex(r'sources: \[{"file":(.+?)\],', webpage, 'video_urls') + video_urls = video_urls.split(',') + video_urls_clean = [] + for i in video_urls: + if 'http' in i: + video_urls_clean.insert(0, {'url': i.replace("\"", "").replace("\n", "").replace("{file:", "")}) + return { + 'id': video_id, + 'title': title, + 'formats': video_urls_clean + } + + +class VlaretvPlaylistIE(InfoExtractor): + _VALID_URL = r'https?://vlare.tv/u/(?P<Channel_id>[0-9a-zA-Z]+)/playlist/(?P<id>[0-9]+)' + IE_NAME = 'Vlare.tv Playlist' + _TEST = { + 'url': 'https://vlare.tv/u/LVWDDFhi/playlist/2568', + 'info_dict': { + 'id': '2568', + 'title': 'LHA', + }, + 'playlist_count': 11, + } + + def _real_extract(self, url): + playlist_id = self._match_id(url) + + webpage = self._download_webpage(url, playlist_id) + urls = re.findall(r'<a href="(.+?)" class="video_thumbnail"', webpage) + title = self._html_search_regex(r'<title>(.+?)<\/title>', webpage, 'title').split('|')[1][1:-1] + entries = [] + for i in urls: + entry = { + '_type': 'url_transparent', + 'url': 'https://vlare.tv' + i, + 'id': re.match(r'\/v\/(.+?)\/', i), + } + entries.append(entry) + + return { + '_type': 'playlist', + 'title': title, + 'id': self._match_id(url), + 'entries': entries, + }