Page MenuHomePhorge

get_date.py
No OneTemporary

get_date.py

#!/usr/bin/env python3
import sys
import tekore as tk
import libmusicleague
import pyml_config as config
import json
# Set up Spotify connection using client token
conf = (config.client_id, config.client_secret)
token = tk.request_client_token(*conf)
spotify = tk.Spotify(token)
# Get track ID from first argument
arg = sys.argv[1]
stype = libmusicleague.spotify_type(arg)
if stype == "track":
track = libmusicleague.return_spotify_track(arg)
json_object = json.loads(track.json())
releasedate = json_object['album']['release_date']
trackname = json_object['name'] + " by " + json_object['artists'][0]['name']
spiel = trackname + " was released on " + releasedate
elif stype == "album":
tu = libmusicleague.spotify_type_and_id(arg) # get tuple
album = spotify.album(tu[1]) # second element of tuple is ID
releasedate = album.asbuiltin()['release_date']
fullname = album.asbuiltin()['name'] + " by " + album.asbuiltin()['artists'][0]['name']
spiel = fullname + " was released on " + releasedate
print(spiel)

File Metadata

Mime Type
text/x-python
Expires
Sun, Apr 27, 7:31 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
154019
Default Alt Text
get_date.py (1 KB)

Event Timeline