mirror of
https://github.com/JonasunderscoreJones/turbo-octo-potato.git
synced 2025-10-25 19:19:19 +02:00
added forcesync and only syncs new by default
This commit is contained in:
parent
fa58cd5893
commit
a1ca707fa7
1 changed files with 17 additions and 1 deletions
|
|
@ -118,6 +118,8 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
VERBOSE_LOGGING = "-v" in sys.argv or "--verbose" in sys.argv
|
VERBOSE_LOGGING = "-v" in sys.argv or "--verbose" in sys.argv
|
||||||
|
FORCE_RESYNC_ALL = "-f" in sys.argv or "--force-all" in sys.argv
|
||||||
|
|
||||||
try:
|
try:
|
||||||
SKIPSONGS = int(sys.argv[sys.argv.index("--skip") + 1]) if "--skip" in sys.argv else int(sys.argv[sys.argv.index("-s") + 1]) if "-s" in sys.argv else 0
|
SKIPSONGS = int(sys.argv[sys.argv.index("--skip") + 1]) if "--skip" in sys.argv else int(sys.argv[sys.argv.index("-s") + 1]) if "-s" in sys.argv else 0
|
||||||
except:
|
except:
|
||||||
|
|
@ -125,7 +127,6 @@ if __name__ == "__main__":
|
||||||
print("E.g.: --skip 88")
|
print("E.g.: --skip 88")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
verboseprint("Authenticating Spotify...")
|
verboseprint("Authenticating Spotify...")
|
||||||
|
|
||||||
# Create a Spotipy instance with authentication
|
# Create a Spotipy instance with authentication
|
||||||
|
|
@ -143,6 +144,14 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
liked_songs_playlist_songs = get_all_songs_from_playlist(LIKEDSONGPLAYLIST_ID)
|
liked_songs_playlist_songs = get_all_songs_from_playlist(LIKEDSONGPLAYLIST_ID)
|
||||||
|
|
||||||
|
if not FORCE_RESYNC_ALL:
|
||||||
|
verboseprint("Syncing only new songs...")
|
||||||
|
liked_songs = [x for x in liked_songs if x not in liked_songs_playlist_songs]
|
||||||
|
print(liked_songs)
|
||||||
|
if len(liked_songs) == 0:
|
||||||
|
print("Nothing to do.")
|
||||||
|
exit()
|
||||||
|
|
||||||
print(f"Number of liked tracks: {len(liked_songs)}")
|
print(f"Number of liked tracks: {len(liked_songs)}")
|
||||||
print(f"Number of playlist songs: {len(liked_songs_playlist_songs)}")
|
print(f"Number of playlist songs: {len(liked_songs_playlist_songs)}")
|
||||||
print(f"Skipping the first {SKIPSONGS} songs...")
|
print(f"Skipping the first {SKIPSONGS} songs...")
|
||||||
|
|
@ -169,5 +178,12 @@ if __name__ == "__main__":
|
||||||
break
|
break
|
||||||
except KeyboardInterrupt: # Allow the user to interrupt the script
|
except KeyboardInterrupt: # Allow the user to interrupt the script
|
||||||
exit()
|
exit()
|
||||||
|
except spotipy.SpotifyException as e:
|
||||||
|
if e.http_status == 429:
|
||||||
|
time.sleep(30)
|
||||||
|
verboseprint(" ]")
|
||||||
|
verboseprint("WARN:RATELIMIT EXCEEDED] Waiting 30 seconds to proceed...")
|
||||||
|
else:
|
||||||
|
print(e.http_status)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue