From bb15f8b8e2383a84b1e28bb6ee85f01687df819e Mon Sep 17 00:00:00 2001 From: dngfx Date: Sun, 23 Sep 2018 02:21:43 +0100 Subject: make last.fm say "is now playing", if they're currently playing. --- modules/lastfm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/lastfm.py b/modules/lastfm.py index 35c903ba..0d6873a2 100644 --- a/modules/lastfm.py +++ b/modules/lastfm.py @@ -1,7 +1,7 @@ #--require-config lastfm-api-key import Utils -import time +from datetime import datetime, timezone URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/" @@ -41,11 +41,11 @@ class Module(object): np = True else: played = int(now_playing["date"]["uts"]) - timenow = int(time.time()) - np = bool(timenow - played > 240) + dts = int(datetime.now(tz=timezone.utc).timestamp()) + np = bool((dts - played) < 120) - time_language = "last listened to" if np == False \ - else "is now playing" + time_language = "is listening to" if np else "last " \ + + "listened to" ytquery = " - ".join([artist, track_name]) -- cgit v1.3.1-10-gc9f91