summary refs log tree commit diff
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2021-01-13 11:22:48 +0200
committerGitHub <noreply@github.com>2021-01-13 09:22:48 +0000
commit7c2d18a13f7eaa4008923ad73ed8e938229db848 (patch)
tree10798662169b4bcf7f1177d105ef9e65ced2c88d
parent2408e6d26a9a1bd899769903ac28a8deaaa778a3 (diff)
downloadyoutube-dl-7c2d18a13f7eaa4008923ad73ed8e938229db848.tar.gz
youtube-dl-7c2d18a13f7eaa4008923ad73ed8e938229db848.tar.xz
youtube-dl-7c2d18a13f7eaa4008923ad73ed8e938229db848.zip
[Mixcloud] Harmonize ID generation from lists with full ID generation (#27787)
Mixcloud IDs are generated as `username_slug` when the full ID dict has been
downloaded.  When downloading a list (e.g. uploads, favorites, ...), the temporary
ID is just the `slug`.  This made e.g. archive file usage require the download
of stream metadata before the download can be rejected as already downloaded.

This commit attempts to get the uploader username during the GraphQL query, so the
temporary IDs are generated similarly.
-rw-r--r--youtube_dl/extractor/mixcloud.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/youtube_dl/extractor/mixcloud.py b/youtube_dl/extractor/mixcloud.py
index 9759560f1..37f16a791 100644
--- a/youtube_dl/extractor/mixcloud.py
+++ b/youtube_dl/extractor/mixcloud.py
@@ -251,8 +251,13 @@ class MixcloudPlaylistBaseIE(MixcloudBaseIE):
                 cloudcast_url = cloudcast.get('url')
                 if not cloudcast_url:
                     continue
+                video_id = cloudcast.get('slug')
+                if video_id:
+                    owner_username = try_get(cloudcast, lambda x: x['owner']['username'], compat_str)
+                    if owner_username:
+                        video_id = '%s_%s' % (owner_username, video_id)
                 entries.append(self.url_result(
-                    cloudcast_url, MixcloudIE.ie_key(), cloudcast.get('slug')))
+                    cloudcast_url, MixcloudIE.ie_key(), video_id))
 
             page_info = items['pageInfo']
             has_next_page = page_info['hasNextPage']
@@ -321,7 +326,8 @@ class MixcloudUserIE(MixcloudPlaylistBaseIE):
     _DESCRIPTION_KEY = 'biog'
     _ROOT_TYPE = 'user'
     _NODE_TEMPLATE = '''slug
-          url'''
+          url
+          owner { username }'''
 
     def _get_playlist_title(self, title, slug):
         return '%s (%s)' % (title, slug)
@@ -345,6 +351,7 @@ class MixcloudPlaylistIE(MixcloudPlaylistBaseIE):
     _NODE_TEMPLATE = '''cloudcast {
             slug
             url
+            owner { username }
           }'''
 
     def _get_cloudcast(self, node):