]>
Commit | Line | Data |
---|---|---|
e1f93a0a PZ |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
de02d1f4 S |
5 | from ..utils import ( |
6 | int_or_none, | |
7 | remove_start, | |
8 | ) | |
e1f93a0a PZ |
9 | |
10 | ||
11 | class RozhlasIE(InfoExtractor): | |
12 | _VALID_URL = r'https?://(?:www\.)?prehravac\.rozhlas\.cz/audio/(?P<id>[0-9]+)' | |
de02d1f4 | 13 | _TESTS = [{ |
e1f93a0a PZ |
14 | 'url': 'http://prehravac.rozhlas.cz/audio/3421320', |
15 | 'md5': '504c902dbc9e9a1fd50326eccf02a7e2', | |
16 | 'info_dict': { | |
17 | 'id': '3421320', | |
18 | 'ext': 'mp3', | |
19 | 'title': 'Echo Pavla Klusáka (30.06.2015 21:00)', | |
20 | 'description': 'Osmdesátiny Terryho Rileyho jsou skvělou příležitostí proletět se elektronickými i akustickými díly zakladatatele minimalismu, který je aktivní už přes padesát let' | |
21 | } | |
de02d1f4 S |
22 | }, { |
23 | 'url': 'http://prehravac.rozhlas.cz/audio/3421320/embed', | |
24 | 'skip_download': True, | |
25 | }] | |
e1f93a0a PZ |
26 | |
27 | def _real_extract(self, url): | |
28 | audio_id = self._match_id(url) | |
e1f93a0a | 29 | |
de02d1f4 S |
30 | webpage = self._download_webpage( |
31 | 'http://prehravac.rozhlas.cz/audio/%s' % audio_id, audio_id) | |
e1f93a0a | 32 | |
de02d1f4 S |
33 | title = self._html_search_regex( |
34 | r'<h3>(.+?)</h3>\s*<p[^>]*>.*?</p>\s*<div[^>]+id=["\']player-track', | |
35 | webpage, 'title', default=None) or remove_start( | |
36 | self._og_search_title(webpage), 'Radio Wave - ') | |
37 | description = self._html_search_regex( | |
38 | r'<p[^>]+title=(["\'])(?P<url>(?:(?!\1).)+)\1[^>]*>.*?</p>\s*<div[^>]+id=["\']player-track', | |
39 | webpage, 'description', fatal=False, group='url') | |
40 | duration = int_or_none(self._search_regex( | |
41 | r'data-duration=["\'](\d+)', webpage, 'duration', default=None)) | |
e1f93a0a PZ |
42 | |
43 | return { | |
44 | 'id': audio_id, | |
de02d1f4 | 45 | 'url': 'http://media.rozhlas.cz/_audio/%s.mp3' % audio_id, |
e1f93a0a PZ |
46 | 'title': title, |
47 | 'description': description, | |
de02d1f4 S |
48 | 'duration': duration, |
49 | 'vcodec': 'none', | |
e1f93a0a | 50 | } |