[thisamericanlife] get info from <meta> tags
[youtube-dl] / youtube_dl / extractor / thisamericanlife.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class ThisAmericanLifeIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?thisamericanlife\.org/radio-archives/episode/(?P<id>\d+)'
9
10     _TEST = {
11         'url': 'http://www.thisamericanlife.org/radio-archives/episode/487/harper-high-school-part-one',
12         'md5': '5cda28076c9f9d1fd0b0f5cff5959948',
13         'info_dict': {
14             'id': '487',
15             'title': '487: Harper High School, Part One',
16             'url' : 'http://stream.thisamericanlife.org/487/stream/487_64k.m3u8',
17             'ext': 'aac',
18             'thumbnail': 'http://www.thisamericanlife.org/sites/default/files/imagecache/large_square/episodes/487_lg_2.jpg',
19             '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.',
20         },
21         'params': {
22             # m38u download
23             'skip_download': True,
24         },
25     }
26
27     def _real_extract(self, url):
28         video_id = self._match_id(url)
29         webpage = self._download_webpage(url, video_id)
30
31         # TODO check to see if there's a free mp3. if so, download that, otherwise get the m3u8 stream.
32
33         return {
34             'id': video_id,
35             'title': self._html_search_regex(r'<meta property="twitter:title" content="(.*?)"', webpage, 'title'),
36             'url': 'http://stream.thisamericanlife.org/' + video_id + '/stream/' + video_id + '_64k.m3u8',
37             'ext': 'aac',
38             'thumbnail': self._html_search_regex(r'<meta property="og:image" content="(.*?)"', webpage, 'thumbnail'),
39             'description': self._html_search_regex(r'<meta name="description" content="(.*?)"', webpage, 'description'),
40         }