From 90709a0fc5c7e9f1ddf90b7dbefe0f0a02f332e2 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Mon, 22 Feb 2016 22:52:32 +0100 Subject: [PATCH] Add support for Shush.se. --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/shush.py | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 youtube_dl/extractor/shush.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 1ae606f1e..f77162fe7 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -632,6 +632,7 @@ from .sexykarma import SexyKarmaIE from .shahid import ShahidIE from .shared import SharedIE from .sharesix import ShareSixIE +from .shush import ShushIE from .sina import SinaIE from .skynewsarabia import ( SkyNewsArabiaIE, diff --git a/youtube_dl/extractor/shush.py b/youtube_dl/extractor/shush.py new file mode 100644 index 000000000..e216d141c --- /dev/null +++ b/youtube_dl/extractor/shush.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..compat import ( + compat_parse_qs, +) +from ..utils import ( + encode_dict, + sanitized_Request, + urlencode_postdata, +) + + +class ShushIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?shush\.se/(?:index\.php)?\?(?Pid=[0-9]+&show=.+)' + _TEST = { + 'url': 'http://www.shush.se/index.php?id=23&show=thirdwatch', + 'md5': '13d99f581a174b82e239b85720cbfa2a', + 'info_dict': { + 'id': '23-thirdwatch', + 'ext': 'mp4', + 'title': 'Third Watch Season 2 Episode: 1 – The Lost', + 'thumbnail': 're:^https?://.*\.(gif|jpg)$', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + parsed_id = compat_parse_qs(video_id) + if parsed_id: + video_id = "%s-%s" % (parsed_id['id'][0], parsed_id['show'][0]) + + webpage = self._download_webpage(url, video_id) + + title = self._search_regex(r'Shush.se - Watch (.+?) \| Free Online Streaming', webpage, 'title') + query_id = self._html_search_regex(r'\{link:"([a-zA-Z0-9@/!=]+)",image:', webpage, 'query_id') + + file_info_request = sanitized_Request('http://www.shush.se/plugins/load.php') + file_info_request.add_header("Content-type", 'application/x-www-form-urlencoded') + file_info_request.data = urlencode_postdata(encode_dict({'link': query_id})) + file_info = self._download_json(file_info_request, video_id) + + return { + 'id': video_id, + 'title': title, + 'url': file_info["link"], + 'ext': file_info["type"], + 'thumbnail': file_info["image"], + }