Created
December 20, 2022 02:45
-
-
Save xthesaintx/fc42628177ba34b14d29b01626b47450 to your computer and use it in GitHub Desktop.
Checks the Track ID input from CLI "SpotifyTackValidate.py TRACKID" output VALID or ERROR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import spotipy | |
import datetime | |
import pprint | |
import os | |
import sys | |
# from prompter import prompt, yesno | |
from spotipy.oauth2 import SpotifyOAuth | |
# Import the os module | |
import os | |
# Get the current working directory | |
os.chdir ('XXXX') | |
cwd = os.getcwd() | |
os.environ["PYTHONIOENCODING"] = "utf-8" | |
logtext="" | |
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="XXXX", | |
client_secret="XXXX", | |
redirect_uri="http://localhost:8000", | |
username='XXXX', | |
scope="user-library-read playlist-modify-public playlist-modify-private")) | |
#### FUNCTIONS #### | |
## TRACK ID AND INFO | |
def id_to_info(id_info_in): | |
id_info_out = sp.track(id_info_in) | |
return id_info_out | |
# Validate Track | |
seed_track_id = sys.argv[1] | |
print (seed_track_id) | |
try: | |
id_to_info (seed_track_id) | |
except: | |
print ("ERROR") | |
else: | |
print ("VALID") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment