From 61d2c36f18c5eb4b32e8dd125493c5200fda2f94 Mon Sep 17 00:00:00 2001 From: buo Date: Wed, 18 Nov 2015 10:53:14 +0900 Subject: [PATCH] [ikshow] Add new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/ikshow.py | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 youtube_dl/extractor/ikshow.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 26e5745d6..0cf96672f 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -244,6 +244,7 @@ from .huffpost import HuffPostIE from .hypem import HypemIE from .iconosquare import IconosquareIE from .ign import IGNIE, OneUPIE +from .ikshow import IkshowIE from .imdb import ( ImdbIE, ImdbListIE diff --git a/youtube_dl/extractor/ikshow.py b/youtube_dl/extractor/ikshow.py new file mode 100644 index 000000000..7f512efab --- /dev/null +++ b/youtube_dl/extractor/ikshow.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals + +import re +import base64 + +from .common import InfoExtractor +from ..utils import js_to_json + + +class IkshowIE(InfoExtractor): + IE_NAME = 'ikshow.net' + _VALID_URL = r'http://ikshow\.net/shows/(?P[^/]+)/(?P[^/]+)' + + _TEST = { + 'url': 'http://ikshow.net/shows/running-man/episode-273/', + 'info_dict': { + 'id': 'running-man-episode-273', + 'ext': 'mp4', + 'title': 'Running Man Ep 273 English Subtitle', + 'description': 'Free to watch and download Running Man Episode 273 with Eng Sub', + } + } + + def _extract_id(self, url): + mobj = re.match(self._VALID_URL, url) + return '%s-%s' % (mobj.group('show_id'), mobj.group('episode_id')) + + def _real_extract(self, url): + video_id = self._extract_id(url) + webpage = self._download_webpage(url, video_id) + + params = self._search_regex( + r'''(?s)jwplayer\("mediaplayer"\)\.setup\((\{.*?\})\);''', + webpage, 'video url') + params = re.sub(r'window\.atob\(("[a-zA-Z0-9+/=]+")\)', '\\1', params) + params = self._parse_json(params, video_id, transform_source=js_to_json) + formats = [{ + 'url': base64.b64decode(s['file']).decode('utf-8'), + 'ext': s['type'], + } for s in params['sources']] + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': self._og_search_title(webpage), + 'description': self._html_search_meta('description', webpage), + 'formats': formats, + }