]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/pokemon.py
[ie/generic] Add `key_query` extractor-arg
[yt-dlp.git] / yt_dlp / extractor / pokemon.py
index eef0d02ca977ec58efdd0ffe9bb015188b2faeab..1769684f72101c35836ad9d6f7f9fe9fb59ceee0 100644 (file)
@@ -1,5 +1,3 @@
-import re
-
 from .common import InfoExtractor
 from ..utils import (
     ExtractorError,
@@ -50,7 +48,7 @@ def _real_extract(self, url):
         video_id, display_id = self._match_valid_url(url).groups()
         webpage = self._download_webpage(url, video_id or display_id)
         video_data = extract_attributes(self._search_regex(
-            r'(<[^>]+data-video-id="%s"[^>]*>)' % (video_id if video_id else '[a-z0-9]{32}'),
+            r'(<[^>]+data-video-id="{}"[^>]*>)'.format(video_id if video_id else '[a-z0-9]{32}'),
             webpage, 'video data element'))
         video_id = video_data['data-video-id']
         title = video_data.get('data-video-title') or self._html_search_meta(
@@ -59,7 +57,7 @@ def _real_extract(self, url):
         return {
             '_type': 'url_transparent',
             'id': video_id,
-            'url': 'limelight:media:%s' % video_id,
+            'url': f'limelight:media:{video_id}',
             'title': title,
             'description': video_data.get('data-video-summary'),
             'thumbnail': video_data.get('data-video-poster'),
@@ -82,13 +80,13 @@ class PokemonWatchIE(InfoExtractor):
             'ext': 'mp4',
             'title': 'Lillier and the Staff!',
             'description': 'md5:338841b8c21b283d24bdc9b568849f04',
-        }
+        },
     }, {
         'url': 'https://watch.pokemon.com/en-us/#/player?id=3fe7752ba09141f0b0f7756d1981c6b2',
-        'only_matching': True
+        'only_matching': True,
     }, {
         'url': 'https://watch.pokemon.com/de-de/player.html?id=b3c402e111a4459eb47e12160ab0ba07',
-        'only_matching': True
+        'only_matching': True,
     }]
 
     def _extract_media(self, channel_array, video_id):
@@ -104,7 +102,7 @@ def _real_extract(self, url):
         info = {
             '_type': 'url',
             'id': video_id,
-            'url': 'limelight:media:%s' % video_id,
+            'url': f'limelight:media:{video_id}',
             'ie_key': 'LimelightMedia',
         }
 
@@ -122,7 +120,7 @@ def _real_extract(self, url):
 
         if video_data is None:
             raise ExtractorError(
-                'Video %s does not exist' % video_id, expected=True)
+                f'Video {video_id} does not exist', expected=True)
 
         info['_type'] = 'url_transparent'
         images = video_data.get('images')
@@ -136,42 +134,3 @@ def _real_extract(self, url):
             'episode': video_data.get('title'),
             'episode_number': int_or_none(video_data.get('episode')),
         })
-
-
-class PokemonSoundLibraryIE(InfoExtractor):
-    _VALID_URL = r'https?://soundlibrary\.pokemon\.co\.jp'
-
-    _TESTS = [{
-        'url': 'https://soundlibrary.pokemon.co.jp/',
-        'info_dict': {
-            'title': 'Pokémon Diamond and Pearl Sound Tracks',
-        },
-        'playlist_mincount': 149,
-    }]
-
-    def _real_extract(self, url):
-        musicbox_webpage = self._download_webpage(
-            'https://soundlibrary.pokemon.co.jp/musicbox', None,
-            'Downloading list of songs')
-        song_titles = [x.group(1) for x in re.finditer(r'<span>([^>]+?)</span><br/>をてもち曲に加えます。', musicbox_webpage)]
-        song_titles = song_titles[4::2]
-
-        # each songs don't have permalink; instead we return all songs at once
-        song_entries = [{
-            'id': f'pokemon-soundlibrary-{song_id}',
-            'url': f'https://soundlibrary.pokemon.co.jp/api/assets/signing/sounds/wav/{song_id}.wav',
-            # note: the server always serves MP3 files, despite its extension of the URL above
-            'ext': 'mp3',
-            'acodec': 'mp3',
-            'vcodec': 'none',
-            'title': song_title,
-            'track': song_title,
-            'artist': 'Nintendo / Creatures Inc. / GAME FREAK inc.',
-            'uploader': 'Pokémon',
-            'release_year': 2006,
-            'release_date': '20060928',
-            'track_number': song_id,
-            'album': 'Pokémon Diamond and Pearl',
-        } for song_id, song_title in enumerate(song_titles, 1)]
-
-        return self.playlist_result(song_entries, playlist_title='Pokémon Diamond and Pearl Sound Tracks')