]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/nick.py
[ie/generic] Add `key_query` extractor-arg
[yt-dlp.git] / yt_dlp / extractor / nick.py
index 60e6e7315df7a1385e5cd3acd223c0d79e0f67e2..653b10b9d0a837627b8f3122eac8aa5763657bed 100644 (file)
@@ -1,8 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-import re
-
 from .mtv import MTVServicesInfoExtractor
 from ..utils import update_url_query
 
@@ -27,7 +22,7 @@ class NickIE(MTVServicesInfoExtractor):
                     'title': 'SpongeBob SquarePants: "A Place for Pets/Lockdown for Love" S1',
                     'description': 'A Place for Pets/Lockdown for Love: When customers bring pets into the Krusty Krab, Mr. Krabs realizes pets are more profitable than owners. Plankton ruins another date with Karen, so she puts the Chum Bucket on lockdown until he proves his affection.',
 
-                }
+                },
             },
             {
                 'md5': '839a04f49900a1fcbf517020d94e0737',
@@ -37,7 +32,7 @@ class NickIE(MTVServicesInfoExtractor):
                     'title': 'SpongeBob SquarePants: "A Place for Pets/Lockdown for Love" S2',
                     'description': 'A Place for Pets/Lockdown for Love: When customers bring pets into the Krusty Krab, Mr. Krabs realizes pets are more profitable than owners. Plankton ruins another date with Karen, so she puts the Chum Bucket on lockdown until he proves his affection.',
 
-                }
+                },
             },
             {
                 'md5': 'f1145699f199770e2919ee8646955d46',
@@ -47,7 +42,7 @@ class NickIE(MTVServicesInfoExtractor):
                     'title': 'SpongeBob SquarePants: "A Place for Pets/Lockdown for Love" S3',
                     'description': 'A Place for Pets/Lockdown for Love: When customers bring pets into the Krusty Krab, Mr. Krabs realizes pets are more profitable than owners. Plankton ruins another date with Karen, so she puts the Chum Bucket on lockdown until he proves his affection.',
 
-                }
+                },
             },
             {
                 'md5': 'd463116875aee2585ee58de3b12caebd',
@@ -57,7 +52,7 @@ class NickIE(MTVServicesInfoExtractor):
                     'title': 'SpongeBob SquarePants: "A Place for Pets/Lockdown for Love" S4',
                     'description': 'A Place for Pets/Lockdown for Love: When customers bring pets into the Krusty Krab, Mr. Krabs realizes pets are more profitable than owners. Plankton ruins another date with Karen, so she puts the Chum Bucket on lockdown until he proves his affection.',
 
-                }
+                },
             },
         ],
     }, {
@@ -68,6 +63,7 @@ class NickIE(MTVServicesInfoExtractor):
             'description': 'md5:9d65a66df38e02254852794b2809d1cf',
             'title': 'Blue\'s Imagination Station',
         },
+        'skip': 'Not accessible?',
     }]
 
     def _get_feed_query(self, uri):
@@ -76,16 +72,12 @@ def _get_feed_query(self, uri):
             'mgid': uri,
         }
 
-    def _extract_mgid(self, webpage):
-        mgid = self._search_regex(r'"media":{"video":{"config":{"uri":"(mgid:.*?)"', webpage, 'mgid', default=None)
-        return mgid
-
     def _real_extract(self, url):
-        domain, video_type, display_id = re.match(self._VALID_URL, url).groups()
-        if video_type.startswith("episodes"):
+        domain, video_type, display_id = self._match_valid_url(url).groups()
+        if video_type.startswith('episodes'):
             return super()._real_extract(url)
         video_data = self._download_json(
-            'http://%s/data/video.endLevel.json' % domain,
+            f'http://{domain}/data/video.endLevel.json',
             display_id, query={
                 'urlKey': display_id,
             })
@@ -121,7 +113,7 @@ class NickBrIE(MTVServicesInfoExtractor):
     }]
 
     def _real_extract(self, url):
-        domain, display_id = re.match(self._VALID_URL, url).groups()
+        domain, display_id = self._match_valid_url(url).groups()
         webpage = self._download_webpage(url, display_id)
         uri = self._search_regex(
             r'data-(?:contenturi|mgid)="([^"]+)', webpage, 'mgid')
@@ -192,30 +184,10 @@ class NickDeIE(MTVServicesInfoExtractor):
     def _get_feed_url(self, uri, url=None):
         video_id = self._id_from_uri(uri)
         config = self._download_json(
-            'http://media.mtvnservices.com/pmt/e1/access/index.html?uri=%s&configtype=edge&ref=%s' % (uri, url), video_id)
+            f'http://media.mtvnservices.com/pmt/e1/access/index.html?uri={uri}&configtype=edge&ref={url}', video_id)
         return self._remove_template_parameter(config['feedWithQueryParams'])
 
 
-class NickNightIE(NickDeIE):
-    IE_NAME = 'nicknight'
-    _VALID_URL = r'https?://(?:www\.)(?P<host>nicknight\.(?:de|at|tv))/(?:playlist|shows)/(?:[^/]+/)*(?P<id>[^/?#&]+)'
-    _TESTS = [{
-        'url': 'http://www.nicknight.at/shows/977-awkward/videos/85987-nimmer-beste-freunde',
-        'only_matching': True,
-    }, {
-        'url': 'http://www.nicknight.at/shows/977-awkward',
-        'only_matching': True,
-    }, {
-        'url': 'http://www.nicknight.at/shows/1900-faking-it',
-        'only_matching': True,
-    }]
-
-    def _extract_mrss_url(self, webpage, *args):
-        return self._search_regex(
-            r'mrss\s*:\s*(["\'])(?P<url>http.+?)\1', webpage,
-            'mrss url', group='url')
-
-
 class NickRuIE(MTVServicesInfoExtractor):
     IE_NAME = 'nickelodeonru'
     _VALID_URL = r'https?://(?:www\.)nickelodeon\.(?:ru|fr|es|pt|ro|hu|com\.tr)/[^/]+/(?:[^/]+/)*(?P<id>[^/?#&]+)'
@@ -249,4 +221,4 @@ def _real_extract(self, url):
         video_id = self._match_id(url)
         webpage = self._download_webpage(url, video_id)
         mgid = self._extract_mgid(webpage, url)
-        return self.url_result('http://media.mtvnservices.com/embed/%s' % mgid)
+        return self.url_result(f'http://media.mtvnservices.com/embed/{mgid}')