Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F217217
get_date.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
get_date.py
View Options
#!/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
Details
Attached
Mime Type
text/x-python
Expires
Sun, Apr 27, 7:31 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
154019
Default Alt Text
get_date.py (1 KB)
Attached To
Mode
rPYMUSICLEAGUE PyMusicLeague
Attached
Detach File
Event Timeline
Log In to Comment