From 969c0fe31c066621520f6d03abc47d05aee9caac Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 29 Jun 2017 13:10:45 -0600 Subject: [PATCH] [cjsw] Add new extractor --- youtube_dl/extractor/cjsw.py | 50 ++++++++++++++++++++++++++++++ youtube_dl/extractor/extractors.py | 1 + 2 files changed, 51 insertions(+) create mode 100644 youtube_dl/extractor/cjsw.py diff --git a/youtube_dl/extractor/cjsw.py b/youtube_dl/extractor/cjsw.py new file mode 100644 index 000000000..5a6fce175 --- /dev/null +++ b/youtube_dl/extractor/cjsw.py @@ -0,0 +1,50 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + unescapeHTML, +) + + +class CJSWIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P[\S]+)/(?P[0-9]+)/?' + IE_NAME = 'cjsw' + _TEST = { + 'url': 'http://cjsw.com/program/freshly-squeezed/episode/20170620', + 'md5': 'cee14d40f1e9433632c56e3d14977120', + 'info_dict': { + 'id': '20170620', + 'ext': 'mp3', + 'title': 'Freshly Squeezed', + 'description': 'Sled Island artists featured // Live session with Phi Pho, followed by a live session with Sinzere & The Late Nights! // Stay Fresh Y\'all!!', + } + } + + def _real_extract(self, url): + episode_id = self._match_id(url) + + webpage = self._download_webpage(url, episode_id) + + episode_controls = re.search(r']+class=(["\'])episode-controls\1[^>]*>', webpage) + if not episode_controls: + raise ExtractorError('No streamable podcast', video_id=episode_id, expected=True) + + title = unescapeHTML(self._search_regex( + r']+data-showname=(["\'])(?P.*?)\1[^>]*>', webpage, 'title', group='title')) + description = unescapeHTML(self._html_search_regex( + r'<p>(?P<description>.*?)</p>', webpage, 'description', fatal=False)) + formats = [{ + 'url': self._html_search_regex( + r'<button[^>]+data-audio-src=(["\'])(?P<audio_url>.*?)\1[^>]*>', webpage, 'audio_url', group='audio_url'), + 'ext': 'mp3', + }] + return { + 'id': episode_id, + 'title': title, + 'description': description, + 'formats': formats, + } diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 45591f2a7..a7cea5429 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -178,6 +178,7 @@ from .chirbit import ( ChirbitProfileIE, ) from .cinchcast import CinchcastIE +from .cjsw import CJSWIE from .clipfish import ClipfishIE from .cliphunter import CliphunterIE from .cliprs import ClipRsIE