]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/soundcloud.py
[cleanup] misc
[yt-dlp.git] / yt_dlp / extractor / soundcloud.py
index c7078ece6dcff108f00e7c20bd686ce0c91d236a..412331e17c7d699a410cc9c81e5e64fb9accae9d 100644 (file)
@@ -23,7 +23,6 @@
     int_or_none,
     KNOWN_EXTENSIONS,
     mimetype2ext,
-    network_exceptions,
     remove_end,
     parse_qs,
     str_or_none,
@@ -306,7 +305,7 @@ def _download_json(self, *args, **kwargs):
                 raise
 
     def _real_initialize(self):
-        self._CLIENT_ID = self._downloader.cache.load('soundcloud', 'client_id') or 'fSSdm5yTnDka1g0Fz1CO5Yx6z0NbeHAj'
+        self._CLIENT_ID = self._downloader.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
         self._login()
 
     _USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
@@ -708,10 +707,11 @@ def resolve_entry(*candidates):
                 yield resolve_entry(e, e.get('track'), e.get('playlist'))
 
             url = response.get('next_href')
+            if not url:
+                break
             query.pop('offset', None)
 
 
-
 class SoundcloudUserIE(SoundcloudPagedPlaylistBaseIE):
     _VALID_URL = r'''(?x)
                         https?://
@@ -855,7 +855,7 @@ def _real_extract(self, url):
 
 class SoundcloudSearchIE(SearchInfoExtractor, SoundcloudIE):
     IE_NAME = 'soundcloud:search'
-    IE_DESC = 'Soundcloud search'
+    IE_DESC = 'Soundcloud search, "scsearch" keyword'
     _MAX_RESULTS = float('inf')
     _TESTS = [{
         'url': 'scsearch15:post-avant jazzcore',
@@ -880,25 +880,14 @@ def _get_collection(self, endpoint, collection_id, **query):
         })
         next_url = update_url_query(self._API_V2_BASE + endpoint, query)
 
-        collected_results = 0
-
         for i in itertools.count(1):
             response = self._download_json(
-                next_url, collection_id, 'Downloading page {0}'.format(i),
+                next_url, collection_id, f'Downloading page {i}',
                 'Unable to download API page', headers=self._HEADERS)
 
-            collection = response.get('collection', [])
-            if not collection:
-                break
-
-            collection = list(filter(bool, collection))
-            collected_results += len(collection)
-
-            for item in collection:
-                yield self.url_result(item['uri'], SoundcloudIE.ie_key())
-
-            if not collection or collected_results >= limit:
-                break
+            for item in response.get('collection') or []:
+                if item:
+                    yield self.url_result(item['uri'], SoundcloudIE.ie_key())
 
             next_url = response.get('next_href')
             if not next_url:
@@ -906,4 +895,4 @@ def _get_collection(self, endpoint, collection_id, **query):
 
     def _get_n_results(self, query, n):
         tracks = self._get_collection('search/tracks', query, limit=n, q=query)
-        return self.playlist_result(tracks, playlist_title=query)
+        return self.playlist_result(tracks, query, query)