Skip to content

Commit

Permalink
fix soundcloud export cli and unplayable check
Browse files Browse the repository at this point in the history
  • Loading branch information
amCap1712 committed Aug 23, 2024
1 parent e439888 commit 798b7f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
20 changes: 19 additions & 1 deletion troi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,19 @@ def cli():
type=str,
required=False,
multiple=True)
@click.option('--soundcloud-user-id', help="The soundcloud user name to upload the playlist to", type=str, required=False)
@click.option('--soundcloud-token',
help="The soundcloud token with the correct permissions required to upload playlists",
type=str,
required=False)
@click.option('--soundcloud-url',
help="instead of creating a new soundcloud playlist, update the existing playlist at this url",
type=str,
required=False,
multiple=True)
@click.argument('args', nargs=-1, type=click.UNPROCESSED)
def playlist(patch, quiet, save, token, upload, args, created_for, name, desc, min_recordings, spotify_user_id, spotify_token,
spotify_url):
spotify_url, soundcloud_user_id, soundcloud_token, soundcloud_url):
"""
Generate a global MBID based playlist using a patch
"""
Expand Down Expand Up @@ -93,6 +103,14 @@ def playlist(patch, quiet, save, token, upload, args, created_for, name, desc, m
"is_collaborative": False,
"existing_urls": spotify_url
}
if soundcloud_token:
patch_args["soundcloud"] = {
"user_id": soundcloud_user_id,
"token": soundcloud_token,
"is_public": True,
"is_collaborative": False,
"existing_urls": soundcloud_url
}

if args is None:
args = []
Expand Down
8 changes: 4 additions & 4 deletions troi/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ def submit_to_spotify(self,
return submitted

def submit_to_soundcloud(self,
user_id: str,
access_token: str,
is_public: bool = True,
existing_urls: str = None):
user_id: str,
access_token: str,
is_public: bool = True,
existing_urls: str = None):
""" Given soundcloud user id, soundcloud auth token, upload the playlists generated in the current element to Soundcloud and return the
urls of submitted playlists.
Expand Down
16 changes: 8 additions & 8 deletions troi/tools/soundcloud_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def lookup_soundcloud_ids(recordings):

def _check_unplayable_tracks(soundcloud: SoundcloudAPI, playlist_id: str):
""" Retrieve tracks for given spotify playlist and split into lists of playable and unplayable tracks """
response = soundcloud.get_playlist_tracks(playlist_id)
tracks = [item.get("tracks", []) for item in response]
tracks = soundcloud.get_playlist_tracks(playlist_id)
track_details = [
{
"id": track["id"],
"title": track["title"],
"streamable": track.get("streamable", True)
}
for track in tracks]
{
"id": track["id"],
"title": track["title"],
"streamable": track.get("streamable", True)
}
for track in tracks
]

playable = []
unplayable = []
Expand Down

0 comments on commit 798b7f8

Please sign in to comment.