[nrk:playlist] Relax video id regex and improve _VALID_URL

This commit is contained in:
Sergey M․ 2015-03-21 20:42:48 +06:00
parent 5379a2d40d
commit a09141548a

View File

@ -77,17 +77,25 @@ def _real_extract(self, url):
class NRKPlaylistIE(InfoExtractor): class NRKPlaylistIE(InfoExtractor):
_VALID_URL = r'http://(?:www\.)?nrk\.no/(?!video)[^/]+/(?P<id>[^/]+)' _VALID_URL = r'http://(?:www\.)?nrk\.no/(?!video)(?:[^/]+/)+(?P<id>[^/]+)'
_TEST = { _TESTS = [{
'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763', 'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763',
'info_dict': { 'info_dict': {
'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763', 'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763',
'title': 'Gjenopplev den historiske solformørkelsen', 'title': 'Gjenopplev den historiske solformørkelsen',
'description': 'md5:c2df8ea3bac5654a26fc2834a542feed', 'description': 'md5:c2df8ea3bac5654a26fc2834a542feed',
}, },
'playlist_mincount': 2, 'playlist_count': 2,
} }, {
'url': 'http://www.nrk.no/kultur/bok/rivertonprisen-til-karin-fossum-1.12266449',
'info_dict': {
'id': 'rivertonprisen-til-karin-fossum-1.12266449',
'title': 'Rivertonprisen til Karin Fossum',
'description': 'Første kvinne på 15 år til å vinne krimlitteraturprisen.',
},
'playlist_count': 5,
}]
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
@ -97,7 +105,8 @@ def _real_extract(self, url):
entries = [ entries = [
self.url_result('nrk:%s' % video_id, 'NRK') self.url_result('nrk:%s' % video_id, 'NRK')
for video_id in re.findall( for video_id in re.findall(
r'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="(\d+)"', webpage) r'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="([^"]+)"',
webpage)
] ]
playlist_title = self._og_search_title(webpage) playlist_title = self._og_search_title(webpage)