From 2e90dff2c2ecade8afb444b086fbc0ad6d2c812d Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 16 Mar 2015 20:05:02 +0100 Subject: [PATCH] The Daily Show Podcast support --- youtube_dl/extractor/__init__.py | 3 +- youtube_dl/extractor/comedycentral.py | 21 ++++++++++++++ youtube_dl/extractor/libsyn.py | 41 +++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 youtube_dl/extractor/libsyn.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 1bb3e1a1c..e94779d40 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -84,7 +84,7 @@ ) from .collegehumor import CollegeHumorIE from .collegerama import CollegeRamaIE -from .comedycentral import ComedyCentralIE, ComedyCentralShowsIE +from .comedycentral import ComedyCentralIE, ComedyCentralShowsIE, TheDailyShowPodcastIE from .comcarcoff import ComCarCoffIE from .commonmistakes import CommonMistakesIE, UnicodeBOMIE from .condenast import CondeNastIE @@ -250,6 +250,7 @@ LetvPlaylistIE ) from .lifenews import LifeNewsIE +from .libsyn import LibsynIE from .liveleak import LiveLeakIE from .livestream import ( LivestreamIE, diff --git a/youtube_dl/extractor/comedycentral.py b/youtube_dl/extractor/comedycentral.py index e5edcc84b..e427b9821 100644 --- a/youtube_dl/extractor/comedycentral.py +++ b/youtube_dl/extractor/comedycentral.py @@ -2,6 +2,7 @@ import re +from .common import InfoExtractor from .mtv import MTVServicesInfoExtractor from ..compat import ( compat_str, @@ -272,3 +273,23 @@ def _real_extract(self, url): 'title': show_name + ' ' + title, 'description': description, } + +class TheDailyShowPodcastIE(InfoExtractor): + _VALID_URL = r'(?Phttps?:)?//thedailyshow\.cc\.com/podcast/(?P[a-z\-]+)' + + def _real_extract(self, url): + display_id = self._match_id(url) + webpage = self._download_webpage(url, display_id) + + player_url = self._search_regex(r']+)?\s*src="((?:https?:)?//html5-player\.libsyn\.com/embed/episode/id/[0-9]+)', webpage, 'player URL') + if player_url.startswith('//'): + mobj = re.match(self._VALID_URL, url) + scheme = mobj.group('scheme') + if not scheme: + scheme = 'https:' + player_url = scheme + player_url + + return { + '_type': 'url_transparent', + 'url': player_url, + } diff --git a/youtube_dl/extractor/libsyn.py b/youtube_dl/extractor/libsyn.py new file mode 100644 index 000000000..4b5029f89 --- /dev/null +++ b/youtube_dl/extractor/libsyn.py @@ -0,0 +1,41 @@ +# encoding: utf-8 +from .common import InfoExtractor +from ..utils import ( + unified_strdate, +) + +class LibsynIE(InfoExtractor): + _VALID_URL = r'(?:https?:)?//html5-player\.libsyn\.com/embed/episode/id/(?P[0-9]+)(?:/.*)?' + + def _real_extract(self, url): + if url.startswith('//'): + url = 'https:' + url + display_id = self._match_id(url) + webpage = self._download_webpage(url, display_id) + + podcast_title = self._search_regex(r'

(.*?)

', webpage, 'show title') + podcast_episode_title = self._search_regex(r'

(.*?)

', webpage, 'episode title') + podcast_date = unified_strdate(self._search_regex(r'
Released: (.*?)
', webpage, 'release date')) + podcast_description = self._search_regex(r'
(.*?)
', webpage, 'description') + + url0 = self._search_regex(r'var mediaURLLibsyn = "(?Phttps?://.*)";', webpage, 'first media URL') + url1 = self._search_regex(r'var mediaURL = "(?Phttps?://.*)";', webpage, 'second media URL') + + if url0 != url1: + formats = [{ + 'url': url0 + }, { + 'url': url1 + }] + else: + formats = [{ + 'url': url0 + }] + + return { + 'id': display_id, + 'title': podcast_episode_title, + 'description': podcast_description, + 'upload_date': podcast_date, + 'formats': formats, + }