Add all files
This commit is contained in:
26
download_spotify.py
Executable file
26
download_spotify.py
Executable file
@@ -0,0 +1,26 @@
|
||||
import sys
|
||||
from subprocess import call
|
||||
import re
|
||||
|
||||
url_pattern = "^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"
|
||||
|
||||
def main():
|
||||
if (len(sys.argv) != 2):
|
||||
print("Wrong parameters!")
|
||||
sys.exit(-1)
|
||||
url = sys.argv[1].strip()
|
||||
print("passing link " + str(url))
|
||||
if (re.match(url_pattern,url) == None):
|
||||
print("Url has to be a valid link!")
|
||||
sys.exit(-1)
|
||||
|
||||
if ("spotify" not in url or "https://" not in url):
|
||||
print("Url has to be a spotify link!")
|
||||
sys.exit(-1)
|
||||
print("executing command")
|
||||
call("cd \"/home/sem/TODO MUSIC\"", shell=True)
|
||||
call("spotdl download " + url, shell=True, user="sem")
|
||||
# call("./download-spotify.sh " + url, shell=True, user="sem") # run as user sem to have the SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET environment variables set
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user