[vevo] Fix _call_api
[youtube-dl] / youtube_dl / extractor / vevo.py
index 4ad1e87e4c6b4b3d8f74c893bf93328ff498c577..35f974c4e9e6ca6c786b103016b4059fb98f7155 100644 (file)
@@ -149,8 +149,8 @@ class VevoIE(InfoExtractor):
         auth_info = self._parse_json(webpage, video_id)
         self._api_url_template = self.http_scheme() + '//apiv2.vevo.com/%s?token=' + auth_info['access_token']
 
-    def _call_api(self, path, video_id, note, errnote, fatal=True):
-        return self._download_json(self._api_url_template % path, video_id, note, errnote)
+    def _call_api(self, path, *args, **kwargs):
+        return self._download_json(self._api_url_template % path, *args, **kwargs)
 
     def _real_extract(self, url):
         video_id = self._match_id(url)
@@ -307,7 +307,7 @@ class VevoIE(InfoExtractor):
 
 
 class VevoPlaylistIE(InfoExtractor):
-    _VALID_URL = r'https?://www\.vevo\.com/watch/(?:playlist|genre)/(?P<id>[^/?#&]+)'
+    _VALID_URL = r'https?://www\.vevo\.com/watch/(?P<kind>playlist|genre)/(?P<id>[^/?#&]+)'
 
     _TESTS = [{
         'url': 'http://www.vevo.com/watch/playlist/dadbf4e7-b99f-4184-9670-6f0e547b6a29',
@@ -316,10 +316,13 @@ class VevoPlaylistIE(InfoExtractor):
             'title': 'Best-Of: Birdman',
         },
         'playlist_count': 10,
-        'params': {
-            'proxy': '52.53.186.253:8083',
-            'no_check_certificate': True,
+    }, {
+        'url': 'http://www.vevo.com/watch/genre/rock',
+        'info_dict': {
+            'id': 'rock',
+            'title': 'Rock',
         },
+        'playlist_count': 20,
     }, {
         'url': 'http://www.vevo.com/watch/playlist/dadbf4e7-b99f-4184-9670-6f0e547b6a29?index=0',
         'md5': '32dcdfddddf9ec6917fc88ca26d36282',
@@ -332,17 +335,15 @@ class VevoPlaylistIE(InfoExtractor):
             'uploader': 'Birdman',
         },
         'expected_warnings': ['Unable to download SMIL file'],
-        'params': {
-            'proxy': '52.53.186.253:8083',
-            'no_check_certificate': True,
-        },
     }, {
         'url': 'http://www.vevo.com/watch/genre/rock?index=0',
         'only_matching': True,
     }]
 
     def _real_extract(self, url):
-        playlist_id = self._match_id(url)
+        mobj = re.match(self._VALID_URL, url)
+        playlist_id = mobj.group('id')
+        playlist_kind = mobj.group('kind')
 
         webpage = self._download_webpage(url, playlist_id)
 
@@ -360,9 +361,10 @@ class VevoPlaylistIE(InfoExtractor):
             self._search_regex(
                 r'window\.__INITIAL_STORE__\s*=\s*({.+?});\s*</script>',
                 webpage, 'initial store'),
-            playlist_id)['default']['playlists']
+            playlist_id)['default']['%ss' % playlist_kind]
 
-        playlist = list(playlists.values())[0]
+        playlist = (list(playlists.values())[0]
+                    if playlist_kind == 'playlist' else playlists[playlist_id])
 
         entries = [
             self.url_result('vevo:%s' % src, VevoIE.ie_key())