Parcourir la source

Fix not properly sending playback ticks

Colin Powell il y a 2 ans
Parent
commit
b988e4bf0a
1 fichiers modifiés avec 6 ajouts et 5 suppressions
  1. 6 5
      mopidy_webhooks/frontend.py

+ 6 - 5
mopidy_webhooks/frontend.py

@@ -33,6 +33,7 @@ class WebhooksFrontend(pykka.ThreadingActor, CoreListener):
         album_name = ""
         if track.album:
             album_name = getattr(track.album, "name")
+
         return {
             "name": track.name,
             "artist": artists,
@@ -71,7 +72,7 @@ class WebhooksFrontend(pykka.ThreadingActor, CoreListener):
         artists = ", ".join(sorted([a.name for a in track.artists]))
         self.last_start_time = int(time.time())
         logger.debug(f"Now playing track: {artists} - {track.name}")
-        post_data = self._build_post_data(tl_track.track)
+        post_data = self._build_post_data(tl_track.track, time_position=0)
 
         # Build post data to send to urls
         if not self.webhook_urls:
@@ -84,11 +85,11 @@ class WebhooksFrontend(pykka.ThreadingActor, CoreListener):
         track = tl_track.track
         artists = ", ".join(sorted([a.name for a in track.artists]))
         duration = track.length and track.length // 1000 or 0
-        time_position = time_position // 1000
+        time_position_sec = time_position // 1000
 
         post_data = self._build_post_data(tl_track.track, time_position=time_position)
 
-        if time_position < duration // 2 and time_position < 240:
+        if time_position_sec < duration // 2 and time_position_sec < 240:
             logger.debug(
                 "Track not played long enough to scrobble. (50% or 240s)"
             )
@@ -106,11 +107,11 @@ class WebhooksFrontend(pykka.ThreadingActor, CoreListener):
         track = tl_track.track
         artists = ", ".join(sorted([a.name for a in track.artists]))
         duration = track.length and track.length // 1000 or 0
-        time_position = time_position // 1000
+        time_position_sec = time_position // 1000
 
         post_data = self._build_post_data(tl_track.track, time_position=time_position)
 
-        if time_position < duration // 2 and time_position < 240:
+        if time_position_sec < duration // 2 and time_position_sec < 240:
             logger.debug(
                 "Track not played long enough to scrobble. (50% or 240s)"
             )