From 0283618ac28012aeb8fe531634e3a10b84ba84b5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 15 Jun 2015 01:07:48 -0700 Subject: [PATCH 1/3] [thisamericanlife] Add a new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/thisamericanlife.py | 32 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 youtube_dl/extractor/thisamericanlife.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 6fdaf90b2..1eb7f7b5a 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -560,6 +560,7 @@ from .tf1 import TF1IE from .theonion import TheOnionIE from .theplatform import ThePlatformIE from .thesixtyone import TheSixtyOneIE +from .thisamericanlife import ThisAmericanLifeIE from .thisav import ThisAVIE from .tinypic import TinyPicIE from .tlc import TlcIE, TlcDeIE diff --git a/youtube_dl/extractor/thisamericanlife.py b/youtube_dl/extractor/thisamericanlife.py new file mode 100644 index 000000000..6118afa1a --- /dev/null +++ b/youtube_dl/extractor/thisamericanlife.py @@ -0,0 +1,32 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class ThisAmericanLifeIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?thisamericanlife\.org/radio-archives/episode/(?P\d+)' + _TEST = { + 'url': 'http://www.thisamericanlife.org/radio-archives/episode/487/harper-high-school-part-one', + 'md5': '5cda28076c9f9d1fd0b0f5cff5959948', + 'info_dict': { + 'id': '487', + 'title': '487: Harper High School, Part One', + 'url' : 'http://stream.thisamericanlife.org/487/stream/487_64k.m3u8', + 'ext': 'aac', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = self._html_search_regex(r']*>(.*?)', webpage, 'title') + media_url = 'http://stream.thisamericanlife.org/' + video_id + '/stream/' + video_id + '_64k.m3u8' + + return { + 'id': video_id, + 'title': title, + 'url': media_url, + 'ext': 'aac', + } From 733a559da5f53a11d9195f51b30b23fccf58bea7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 15 Jun 2015 09:35:48 -0700 Subject: [PATCH 2/3] [thisamericanlife] get info from tags --- youtube_dl/extractor/thisamericanlife.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/thisamericanlife.py b/youtube_dl/extractor/thisamericanlife.py index 6118afa1a..300884c1d 100644 --- a/youtube_dl/extractor/thisamericanlife.py +++ b/youtube_dl/extractor/thisamericanlife.py @@ -6,6 +6,7 @@ from .common import InfoExtractor class ThisAmericanLifeIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?thisamericanlife\.org/radio-archives/episode/(?P\d+)' + _TEST = { 'url': 'http://www.thisamericanlife.org/radio-archives/episode/487/harper-high-school-part-one', 'md5': '5cda28076c9f9d1fd0b0f5cff5959948', @@ -14,19 +15,26 @@ class ThisAmericanLifeIE(InfoExtractor): 'title': '487: Harper High School, Part One', 'url' : 'http://stream.thisamericanlife.org/487/stream/487_64k.m3u8', 'ext': 'aac', - } + 'thumbnail': 'http://www.thisamericanlife.org/sites/default/files/imagecache/large_square/episodes/487_lg_2.jpg', + 'description': 'We spent five months at Harper High School in Chicago, where last year alone 29 current and recent students were shot. 29. We went to get a sense of what it means to live in the midst of all this gun violence, how teens and adults navigate a world of funerals and Homecoming dances.', + }, + 'params': { + # m38u download + 'skip_download': True, + }, } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - title = self._html_search_regex(r']*>(.*?)', webpage, 'title') - media_url = 'http://stream.thisamericanlife.org/' + video_id + '/stream/' + video_id + '_64k.m3u8' + # TODO check to see if there's a free mp3. if so, download that, otherwise get the m3u8 stream. return { 'id': video_id, - 'title': title, - 'url': media_url, + 'title': self._html_search_regex(r' Date: Mon, 15 Jun 2015 09:50:39 -0700 Subject: [PATCH 3/3] [thisamericanlife] Remove unnecessary comment --- youtube_dl/extractor/thisamericanlife.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/youtube_dl/extractor/thisamericanlife.py b/youtube_dl/extractor/thisamericanlife.py index 300884c1d..295523271 100644 --- a/youtube_dl/extractor/thisamericanlife.py +++ b/youtube_dl/extractor/thisamericanlife.py @@ -28,8 +28,6 @@ class ThisAmericanLifeIE(InfoExtractor): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - # TODO check to see if there's a free mp3. if so, download that, otherwise get the m3u8 stream. - return { 'id': video_id, 'title': self._html_search_regex(r'