]>
Commit | Line | Data |
---|---|---|
49aeedb8 S |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
2e90dff2 | 6 | from .common import InfoExtractor |
49aeedb8 S |
7 | from ..utils import unified_strdate |
8 | ||
2e90dff2 | 9 | |
10 | class LibsynIE(InfoExtractor): | |
49aeedb8 S |
11 | _VALID_URL = r'https?://html5-player\.libsyn\.com/embed/episode/id/(?P<id>[0-9]+)' |
12 | ||
13 | _TEST = { | |
14 | 'url': 'http://html5-player.libsyn.com/embed/episode/id/3377616/', | |
15 | 'md5': '443360ee1b58007bc3dcf09b41d093bb', | |
9ef4f12b | 16 | 'info_dict': { |
49aeedb8 S |
17 | 'id': '3377616', |
18 | 'ext': 'mp3', | |
19 | 'title': "The Daily Show Podcast without Jon Stewart - Episode 12: Bassem Youssef: Egypt's Jon Stewart", | |
20 | 'description': 'md5:601cb790edd05908957dae8aaa866465', | |
21 | 'upload_date': '20150220', | |
9ef4f12b | 22 | }, |
49aeedb8 | 23 | } |
2e90dff2 | 24 | |
25 | def _real_extract(self, url): | |
49aeedb8 S |
26 | video_id = self._match_id(url) |
27 | ||
28 | webpage = self._download_webpage(url, video_id) | |
29 | ||
30 | formats = [{ | |
31 | 'url': media_url, | |
32 | } for media_url in set(re.findall('var\s+mediaURL(?:Libsyn)?\s*=\s*"([^"]+)"', webpage))] | |
33 | ||
34 | podcast_title = self._search_regex( | |
35 | r'<h2>([^<]+)</h2>', webpage, 'title') | |
36 | episode_title = self._search_regex( | |
37 | r'<h3>([^<]+)</h3>', webpage, 'title', default=None) | |
38 | ||
39 | title = '%s - %s' %(podcast_title, episode_title) if podcast_title else episode_title | |
40 | ||
41 | description = self._html_search_regex( | |
42 | r'<div id="info_text_body">(.+?)</div>', webpage, | |
43 | 'description', fatal=False) | |
44 | ||
45 | thumbnail = self._search_regex( | |
46 | r'<img[^>]+class="info-show-icon"[^>]+src="([^"]+)"', | |
47 | webpage, 'thumbnail', fatal=False) | |
48 | ||
49 | release_date = unified_strdate(self._search_regex( | |
50 | r'<div class="release_date">Released: ([^<]+)<', webpage, 'release date', fatal=False)) | |
2e90dff2 | 51 | |
52 | return { | |
49aeedb8 S |
53 | 'id': video_id, |
54 | 'title': title, | |
55 | 'description': description, | |
56 | 'thumbnail': thumbnail, | |
57 | 'upload_date': release_date, | |
2e90dff2 | 58 | 'formats': formats, |
59 | } |