From 45bc915507abd5318822681f3ea9c0772d88a247 Mon Sep 17 00:00:00 2001 From: Loknar Date: Tue, 12 Sep 2017 20:18:39 +0000 Subject: [PATCH] add extractor for skypixel.com resolves https://github.com/rg3/youtube-dl/issues/13495 --- youtube_dl/extractor/common.py | 22 +++++++++ youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/skypixel.py | 74 ++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 youtube_dl/extractor/skypixel.py diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 74d30ec50..23255c6ac 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -809,6 +809,28 @@ class InfoExtractor(object): else: return res + def _simple_search_between(self, search_str, start_str, end_str): + """ + Searches string for a starting substring followed by an ending substring + and returns the substring in between. If starting or ending substring are + not found returns None. + @search_str [str, unicode] + @start_str [str, unicode] + @end_str [str, unicode] + """ + assert(type(search_str) in (str, unicode)) + assert(type(start_str) in (str, unicode)) + assert(type(end_str) in (str, unicode)) + search_start = search_str.find(start_str) + if search_start == -1: + return None + between_a = search_start + len(start_str) + search_end = search_str[between_a:].find(end_str) + if search_end == -1: + return None + between_b = search_end + between_a + return search_str[between_a:between_b] + def _get_netrc_login_info(self, netrc_machine=None): username = None password = None diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 46a11f3ef..936243e7a 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -928,6 +928,7 @@ from .shared import ( from .showroomlive import ShowRoomLiveIE from .sina import SinaIE from .sixplay import SixPlayIE +from .skypixel import SkypixelIE from .skylinewebcams import SkylineWebcamsIE from .skynewsarabia import ( SkyNewsArabiaIE, diff --git a/youtube_dl/extractor/skypixel.py b/youtube_dl/extractor/skypixel.py new file mode 100644 index 000000000..4b54f3bd7 --- /dev/null +++ b/youtube_dl/extractor/skypixel.py @@ -0,0 +1,74 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class SkypixelIE(InfoExtractor): + """InfoExtractor for Skypixel.com""" + + _VALID_URL = r'https?://(?:www\.)?skypixel\.com/share/video/(?P[^&#]+)' + _TESTS = [ + { + 'url': 'https://skypixel.com/share/video/check-out-my-latest-artwork-4f90b8ac-e7c3-4ed8-82c2-203addfd629e', + 'info_dict': { + 'id': 'check-out-my-latest-artwork-4f90b8ac-e7c3-4ed8-82c2-203addfd629e', + 'ext': 'mp4', + 'title': 'Check out my latest artwork!', + 'uploader': 'Alby98', + 'thumbnail': 'http://dn-djidl2.qbox.me/cloud/c89382b0b8dc75ea9f07354e098e0971/2.jpg', + }, + 'params': { + 'noplaylist': True, + 'skip_download': True, + } + }, + { + 'url': 'https://www.skypixel.com/share/video/undirfellsrett-i-vatnsdal-8-9-2017', + 'info_dict': { + 'id': 'undirfellsrett-i-vatnsdal-8-9-2017', + 'ext': 'mp4', + 'title': 'Undirfellsrétt í Vatnsdal 8/9/2017', + 'uploader': 'Flokmundur', + 'thumbnail': 'http://dn-djidl2.qbox.me/cloud/3c1a3aea1bdc042362a36ed482edb3ae/2.jpg', + }, + 'params': { + 'noplaylist': True, + 'skip_download': True, + } + } + ] + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + title = self._og_search_title(webpage).strip() + title = title.replace(' | SkyPixel.com', '') + uploader = self._simple_search_between( + webpage, u'') + assert(uploader is not None) + djivideos_url = self._simple_search_between( + webpage, u'