]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/deezer.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / deezer.py
index 3b1833c8d92a6bfc491f0c41b030788582c49107..2ca8be5ca07a9a6520998f5bf571e9f63bacf86d 100644 (file)
@@ -1,7 +1,4 @@
-from __future__ import unicode_literals
-
 import json
-import re
 
 from .common import InfoExtractor
 from ..utils import (
 
 class DeezerBaseInfoExtractor(InfoExtractor):
     def get_data(self, url):
-        if not self._downloader.params.get('test'):
+        if not self.get_param('test'):
             self.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!')
 
-        mobj = re.match(self._VALID_URL, url)
+        mobj = self._match_valid_url(url)
         data_id = mobj.group('id')
 
         webpage = self._download_webpage(url, data_id)
@@ -25,7 +22,7 @@ def get_data(self, url):
             default=None)
         if geoblocking_msg is not None:
             raise ExtractorError(
-                'Deezer said: %s' % geoblocking_msg, expected=True)
+                f'Deezer said: {geoblocking_msg}', expected=True)
 
         data_json = self._search_regex(
             (r'__DZR_APP_STATE__\s*=\s*({.+?})\s*</script>',
@@ -65,13 +62,12 @@ def _real_extract(self, url):
                 'preference': -100,  # Only the first 30 seconds
                 'ext': 'mp3',
             }]
-            self._sort_formats(formats)
             artists = ', '.join(
                 orderedSet(a.get('ART_NAME') for a in s.get('ARTISTS')))
             entries.append({
                 'id': s.get('SNG_ID'),
                 'duration': int_or_none(s.get('DURATION')),
-                'title': '%s - %s' % (artists, s.get('SNG_TITLE')),
+                'title': '{} - {}'.format(artists, s.get('SNG_TITLE')),
                 'uploader': s.get('ART_NAME'),
                 'uploader_id': s.get('ART_ID'),
                 'age_limit': 16 if s.get('EXPLICIT_LYRICS') == '1' else 0,
@@ -118,13 +114,12 @@ def _real_extract(self, url):
                 'preference': -100,  # Only the first 30 seconds
                 'ext': 'mp3',
             }]
-            self._sort_formats(formats)
             artists = ', '.join(
                 orderedSet(a.get('ART_NAME') for a in s.get('ARTISTS')))
             entries.append({
                 'id': s.get('SNG_ID'),
                 'duration': int_or_none(s.get('DURATION')),
-                'title': '%s - %s' % (artists, s.get('SNG_TITLE')),
+                'title': '{} - {}'.format(artists, s.get('SNG_TITLE')),
                 'uploader': s.get('ART_NAME'),
                 'uploader_id': s.get('ART_ID'),
                 'age_limit': 16 if s.get('EXPLICIT_LYRICS') == '1' else 0,