Last active
July 11, 2020 21:45
-
-
Save jmeridth/129e63d79b1d27e786ff8a9bbea61356 to your computer and use it in GitHub Desktop.
Revisions
-
jmeridth revised this gist
Jul 11, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,20 +14,20 @@ offset = 0 limit = 50 while(True): tracks = spotify.saved_tracks(limit=limit, offset=offset) if(len(tracks.items) == 0): break; saved_tracks.extend(tracks.items) if(len(tracks.items) < offset): break offset += offset print("{} Saved Songs Found".format(len(saved_tracks))) token = tk.prompt_for_user_token(*conf, scope=tk.scope.every) spotify = tk.Spotify(token) saved_track_ids = [track.track.id for track in saved_tracks] for chunk in zip(*(iter(saved_track_ids),) * limit): try: spotify.saved_tracks_add(track_ids=chunk) except Exception as e: -
jmeridth revised this gist
Jul 11, 2020 . No changes.There are no files selected for viewing
-
jmeridth created this gist
Jul 11, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ CLIENT_ID=PUT_CLIENT_ID_HERE CLIENT_SECRET=PUT_CLIENT_SECRET_HERE REDIRECT_URI=PUT_REDIRECT_URI_HERE This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ import tekore as tk import os client_id = os.environ.get("CLIENT_ID") client_secret = os.environ.get("CLIENT_SECRET") redirect_uri = os.environ.get("REDIRECT_URI") conf = (client_id, client_secret, redirect_uri) token = tk.prompt_for_user_token(*conf, scope=tk.scope.every) # will open webpage for you to log into first account spotify = tk.Spotify(token) saved_tracks = [] offset = 0 limit = 50 while(True): tracks = spotify.saved_tracks(limit=50, offset=offset) if(len(tracks.items) == 0): break; saved_tracks.extend(tracks.items) if(len(tracks.items) < 20): break offset += 20 print("{} Saved Songs Found".format(len(saved_tracks))) token = tk.prompt_for_user_token(*conf, scope=tk.scope.every) spotify = tk.Spotify(token) saved_track_ids = [track.track.id for track in saved_tracks] for chunk in zip(*(iter(saved_track_ids),) * 50): try: spotify.saved_tracks_add(track_ids=chunk) except Exception as e: print(e) print('done adding saved songs to new account') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ certifi==2020.6.20 chardet==3.0.4 idna==2.10 requests==2.24.0 six==1.15.0 spotipy==2.13.0 urllib3==1.25.9 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ #!/bin/bash cp .env.template .env source .env python3 -m venv env source env/bin/activate pip install -r requirements.txt python move_saved_songs_from_one_account_to_another.py