]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[nrk:playlist] Add extractor (Closes #5245)
authorSergey M․ <dstftw@gmail.com>
Sat, 21 Mar 2015 12:22:08 +0000 (18:22 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 21 Mar 2015 12:22:08 +0000 (18:22 +0600)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/nrk.py

index 7eb9b4fbbb1dd6ceac016ab6c10fb71b72369101..e25e4a582e2a4a811e3b30b3c2271535874217c8 100644 (file)
@@ -346,6 +346,7 @@ from .npo import (
 )
 from .nrk import (
     NRKIE,
+    NRKPlaylistIE,
     NRKTVIE,
 )
 from .ntvde import NTVDeIE
index 117a78aa178813ff0da19755d462d031f0265a01..c2a8202dd181f3c747e5d26633cb40c7ad3fa764 100644 (file)
@@ -76,6 +76,37 @@ class NRKIE(InfoExtractor):
         }
 
 
+class NRKPlaylistIE(InfoExtractor):
+    _VALID_URL = r'http://(?:www\.)?nrk\.no/(?:[^/]+/)*(?P<id>[^/]+)'
+
+    _TEST = {
+        'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763',
+        'info_dict': {
+            'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763',
+            'title': 'Gjenopplev den historiske solformørkelsen',
+            'description': 'md5:c2df8ea3bac5654a26fc2834a542feed',
+        },
+        'playlist_mincount': 2,
+    }
+
+    def _real_extract(self, url):
+        playlist_id = self._match_id(url)
+
+        webpage = self._download_webpage(url, playlist_id)
+
+        entries = [
+            self.url_result('nrk:%s' % video_id, 'NRK')
+            for video_id in re.findall(
+                r'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="(\d+)"', webpage)
+        ]
+
+        playlist_title = self._og_search_title(webpage)
+        playlist_description = self._og_search_description(webpage)
+
+        return self.playlist_result(
+            entries, playlist_id, playlist_title, playlist_description)
+
+
 class NRKTVIE(InfoExtractor):
     _VALID_URL = r'(?P<baseurl>http://tv\.nrk(?:super)?\.no/)(?:serie/[^/]+|program)/(?P<id>[a-zA-Z]{4}\d{8})(?:/\d{2}-\d{2}-\d{4})?(?:#del=(?P<part_id>\d+))?'