Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F223728
get_track_info.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
985 B
Referenced Files
None
Subscribers
None
get_track_info.py
View Options
#!/usr/bin/env python3
import
sys
import
json
import
tekore
as
tk
import
libmusicleague
import
pyml_config
as
config
# 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
trackarg
=
sys
.
argv
[
1
]
print
(
trackarg
)
try
:
#tk.from_url(trackarg)
print
(
"Looks like it's a track URL, we'll use that"
)
track
=
spotify
.
track
(
tk
.
from_url
(
trackarg
)[
1
])
except
:
print
(
"Looks like it's not a URL, maybe it's a URI?"
)
try
:
track
=
spotify
.
track
(
trackarg
)
except
:
print
(
"Still failed?!?"
)
#trackid = tk.from_url(trackarg)[1]
#track = spotify.track(trackid)
#print(track.asbuiltin())
json_object
=
json
.
loads
(
track
.
json
())
#json_pretty = json.dumps(json_object, indent="\t", separators=(',', ':'))
json_pretty
=
json
.
dumps
(
json_object
,
cls
=
libmusicleague
.
CompactJSONEncoder
)
# json_pretty = json.dumps(json_object, indent=0)
print
(
json_pretty
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sat, May 17, 2:25 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
158119
Default Alt Text
get_track_info.py (985 B)
Attached To
Mode
rPYMUSICLEAGUE PyMusicLeague
Attached
Detach File
Event Timeline
Log In to Comment