2 from __future__ import unicode_literals
6 from .common import InfoExtractor
9 class NPORadioIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>.*)'
12 'url': 'http://www.npo.nl/radio/radio-1',
16 'title': 'NPO Radio 1',
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
24 title = self._html_search_regex(
25 self._html_get_attribute_regex('data-channel'), webpage, 'title')
27 json_data = json.loads(
28 self._html_search_regex(
29 self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'))
34 'ext': json_data['codec'],
35 'url': json_data['url']
38 def _html_get_attribute_regex(self, attribute):
39 return r'{0}\s*=\s*\'([^\']+)\''.format(attribute)