This commit is contained in:
Footsiefat 2021-10-22 18:23:47 +13:00
commit 6c0fc89696
2 changed files with 34 additions and 17 deletions

View File

@ -8,7 +8,7 @@
<img src="https://user-images.githubusercontent.com/12180913/138040605-c9d46e45-3830-4a4b-a7ac-c56bb0d76335.png">
</p>
[Discord Server](https://discord.gg/skVNQKtyFq) - [Matrix Server](https://matrix.to/#/#zspotify:matrix.org) - [Gitea Mirror](https://git.robinsmediateam.dev/Footsiefat/zspotify)
[Discord Server](https://discord.gg/skVNQKtyFq) - [Matrix Server](https://matrix.to/#/#zspotify:matrix.org) - [Gitea Mirror](https://git.robinsmediateam.dev/Footsiefat/zspotify) - [Main Site](https://footsiefat.github.io/)
```
Requirements:

View File

@ -69,6 +69,20 @@ def sanitize_data(value):
return value.replace("|", "-")
def split_input(selection):
""" Returns a list of inputted strings """
inputs = []
if "-" in selection:
for number in range(int(selection.split("-")[0]), int(selection.split("-")[1]) + 1):
inputs.append(number)
return inputs
else:
selections = selection.split(",")
for i in selections:
inputs.append(i.strip())
return inputs
def splash():
""" Displays splash screen """
print("=================================\n"
@ -373,8 +387,10 @@ def search(search_term):
if len(tracks) + len(albums) + len(playlists) == 0:
print("NO RESULTS FOUND - EXITING...")
else:
position = int(input("SELECT ITEM BY ID: "))
selection = str(input("SELECT ITEM(S) BY ID: "))
inputs = split_input(selection)
for pos in inputs:
position = int(pos)
if position <= total_tracks:
track_id = tracks[position - 1]["id"]
download_track(track_id)
@ -383,7 +399,8 @@ def search(search_term):
else:
playlist_choice = playlists[position -
total_tracks - total_albums - 1]
playlist_songs = get_playlist_songs(token, playlist_choice['id'])
playlist_songs = get_playlist_songs(
token, playlist_choice['id'])
for song in playlist_songs:
if song['track']['id'] is not None:
download_track(song['track']['id'], sanitize_data(