diff options
| author | 2018-09-23 02:21:43 +0100 | |
|---|---|---|
| committer | 2018-09-23 02:21:43 +0100 | |
| commit | bb15f8b8e2383a84b1e28bb6ee85f01687df819e (patch) | |
| tree | 081fe869600f5d6eb84470d342425ebc54ac2c15 /modules/lastfm.py | |
| parent | make last.fm say "is now playing", if they're currently playing. (diff) | |
| signature | ||
make last.fm say "is now playing", if they're currently playing.
Diffstat (limited to 'modules/lastfm.py')
| -rw-r--r-- | modules/lastfm.py | 10 |
1 files changed, 5 insertions, 5 deletions
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]) |
