-
Notifications
You must be signed in to change notification settings - Fork 738
/
Copy pathspotify.py
29 lines (27 loc) · 1.05 KB
/
spotify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import spotdl
import sys,os
def spotify():
if(len(sys.argv) <= 1):
print("try 'python3 spotify.py -h' for help")
return 1
elif(sys.argv[1] == '-h'):
print("To download a song run,\n python3 spotify.py $trackUrl\n\nTo download an album run,\n python3 spotify.py $albumUrl\n\nTo download a playlist run,\n python3 spotify.py $playlistUrl")
return 1
url = sys.argv[1]
if (url.find('track') > -1):
os.system(f'spotdl --song {url}')
else:
# Playlist
if (url.find('playlist') > -1):
os.system(f"spotdl -p {url} --write-to playlist.txt")
os.system(f"spotdl --list playlist.txt")
# Artist
if (url.find('artist') > -1):
os.system(f"spotdl --all {url} --write-to artist.txt")
os.system(f"spotdl --list artist.txt")
# album
if (url.find('album') > -1):
os.system(f"spotdl -a {url} --write-to album.txt")
os.system(f"spotdl --list album.txt")
if __name__ == "__main__":
spotify()