mirror of
https://github.com/JonasunderscoreJones/turbo-octo-potato.git
synced 2025-10-25 11:09:18 +02:00
added the ability to skip songs
adds a flag -s/--skip that allows for skipping of the first x amount of songs. this can be useful for when the script got hung up on an api ratelimit and you want it to continue where it left off.
This commit is contained in:
parent
1a121f544f
commit
85edae7c3c
1 changed files with 9 additions and 2 deletions
|
|
@ -117,6 +117,13 @@ if __name__ == "__main__":
|
|||
|
||||
# Parse command-line arguments
|
||||
VERBOSE_LOGGING = "-v" in sys.argv or "--verbose" in sys.argv
|
||||
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
|
||||
except:
|
||||
print("[--skip/-s] Require a number to be set.")
|
||||
print("E.g.: --skip 88")
|
||||
exit()
|
||||
|
||||
|
||||
verboseprint("Authenticating Spotify...")
|
||||
|
||||
|
|
@ -137,7 +144,7 @@ if __name__ == "__main__":
|
|||
|
||||
print(f"Number of liked tracks: {len(liked_songs)}")
|
||||
print(f"Number of playlist songs: {len(liked_songs_playlist_songs)}")
|
||||
|
||||
print(f"Skipping the first {SKIPSONGS} songs...")
|
||||
tracknr = 0
|
||||
for track_uri, track_name, artist_name in liked_songs:
|
||||
tracknr += 1
|
||||
|
|
@ -155,7 +162,7 @@ if __name__ == "__main__":
|
|||
elif VERBOSE_LOGGING:
|
||||
verboseprint("%-10s %13s" % (f"ETA:{round((((int(len(liked_songs))-tracknr)*0.75)/60))}min", f"[{tracknr}/{int(len(liked_songs))}]") + "%32.32s %s" % (track['artists'][0]['name'], track['name']))
|
||||
# Loop until the API call succeeds
|
||||
while True:
|
||||
while tracknr > SKIPSONGS:
|
||||
try:
|
||||
loop_do()
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue