Skip to content

Commit

Permalink
[Mixcloud] Harmonize ID generation from lists with full ID generation
Browse files Browse the repository at this point in the history
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 PR attempts to get the uploader username during the GraphQL query, so the
temporary IDs are generated similarly.
  • Loading branch information
akx committed Jan 13, 2021
1 parent 4759543 commit 7e02822
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions youtube_dl/extractor/mixcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ def _real_extract(self, url):
cloudcast_url = cloudcast.get('url')
if not cloudcast_url:
continue
video_id = cloudcast['slug']
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']
Expand Down Expand Up @@ -321,7 +325,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)
Expand All @@ -345,6 +350,7 @@ class MixcloudPlaylistIE(MixcloudPlaylistBaseIE):
_NODE_TEMPLATE = '''cloudcast {
slug
url
owner { username }
}'''

def _get_cloudcast(self, node):
Expand Down

0 comments on commit 7e02822

Please sign in to comment.