mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-03 00:41:15 -05:00
LastFM: catch and fall back to "some point in time" if LastFM's API doesn't show the listened-to date
This commit is contained in:
parent
52ec05a041
commit
932a27e588
@ -172,12 +172,14 @@ class LastFM(callbacks.Plugin):
|
|||||||
if album:
|
if album:
|
||||||
album = ircutils.bold("[%s] " % album)
|
album = ircutils.bold("[%s] " % album)
|
||||||
|
|
||||||
time = int(trackdata["date"]["uts"]) # Time of last listen
|
try:
|
||||||
# Format this using the preferred time format.
|
time = int(trackdata["date"]["uts"]) # Time of last listen
|
||||||
tformat = conf.supybot.reply.format.time()
|
# Format this using the preferred time format.
|
||||||
time = datetime.fromtimestamp(time).strftime(tformat)
|
tformat = conf.supybot.reply.format.time()
|
||||||
irc.reply('%s listened to %s by %s %sat %s' %
|
time = datetime.fromtimestamp(time).strftime(tformat)
|
||||||
(ircutils.bold(user), track, artist, album, time))
|
except KeyError: # Nothing given by the API?
|
||||||
|
time = "some point in time"
|
||||||
|
|
||||||
|
|
||||||
np = wrap(nowPlaying, [optional("something")])
|
np = wrap(nowPlaying, [optional("something")])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user