2 from __future__ import unicode_literals
8 from .common import InfoExtractor
10 # audios on fm4.orf.at are only available for 7 days, so we can't
14 class FM4IE(InfoExtractor):
15 IE_DESC = 'fm4.orf.at'
16 _VALID_URL = r'http://fm4\.orf\.at/7tage#(?P<date>[0-9]+)/(?P<show>[\w]+)'
18 def _extract_entry_dict(self, info, title, subtitle):
20 'id': info['loopStreamId'].replace('.mp3', ''),
21 'url': 'http://loopstream01.apa.at/?channel=fm4&id=%s' % info['loopStreamId'],
23 'description': subtitle,
24 'duration': (info['end'] - info['start']) / 1000,
25 'timestamp': info['start'] / 1000,
31 def _real_extract(self, url):
32 mobj = re.match(self._VALID_URL, url)
33 show_date = mobj.group('date')
34 show_id = mobj.group('show')
36 data = self._download_json(
37 'http://audioapi.orf.at/fm4/json/2.0/broadcasts/%s/4%s' % (show_date, show_id),
41 entries = [ self._extract_entry_dict(t, data['title'], data['subtitle']) for t in data['streams']]
46 'title': data['title'],
47 'description': data['subtitle'],