make last.fm say "is now playing", if they're currently playing.
This commit is contained in:
parent
d335deed40
commit
bb15f8b8e2
1 changed files with 5 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
#--require-config lastfm-api-key
|
#--require-config lastfm-api-key
|
||||||
|
|
||||||
import Utils
|
import Utils
|
||||||
import time
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
|
URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ class Module(object):
|
||||||
np = True
|
np = True
|
||||||
else:
|
else:
|
||||||
played = int(now_playing["date"]["uts"])
|
played = int(now_playing["date"]["uts"])
|
||||||
timenow = int(time.time())
|
dts = int(datetime.now(tz=timezone.utc).timestamp())
|
||||||
np = bool(timenow - played > 240)
|
np = bool((dts - played) < 120)
|
||||||
|
|
||||||
time_language = "last listened to" if np == False \
|
time_language = "is listening to" if np else "last " \
|
||||||
else "is now playing"
|
+ "listened to"
|
||||||
|
|
||||||
ytquery = " - ".join([artist, track_name])
|
ytquery = " - ".join([artist, track_name])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue