浏览代码

Fix scrobbling videos

Colin Powell 2 年之前
父节点
当前提交
69bdc60087
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 4 1
      vrobbler/apps/scrobbles/scrobblers.py
  2. 3 2
      vrobbler/apps/scrobbles/utils.py

+ 4 - 1
vrobbler/apps/scrobbles/scrobblers.py

@@ -102,10 +102,13 @@ def build_scrobble_dict(data_dict: dict, user_id: int) -> dict:
     elif data_dict.get("NotificationType") == "PlaybackStop":
     elif data_dict.get("NotificationType") == "PlaybackStop":
         jellyfin_status = "stopped"
         jellyfin_status = "stopped"
 
 
+    playback_seconds = convert_to_seconds(
+        data_dict.get("PlaybackPosition", "")
+    )
     return {
     return {
         "user_id": user_id,
         "user_id": user_id,
         "timestamp": parse(data_dict.get("UtcTimestamp")),
         "timestamp": parse(data_dict.get("UtcTimestamp")),
-        "playback_position_seconds": data_dict.get("PlaybackPosition", ""),
+        "playback_position_seconds": playback_seconds,
         "source": data_dict.get("ClientName", "Vrobbler"),
         "source": data_dict.get("ClientName", "Vrobbler"),
         "source_id": data_dict.get("MediaSourceId"),
         "source_id": data_dict.get("MediaSourceId"),
         "jellyfin_status": jellyfin_status,
         "jellyfin_status": jellyfin_status,

+ 3 - 2
vrobbler/apps/scrobbles/utils.py

@@ -20,13 +20,14 @@ def convert_to_seconds(run_time: str) -> int:
     This is actually deprecated, as we now convert to seconds before saving.
     This is actually deprecated, as we now convert to seconds before saving.
     But for older videos, we'll leave this here.
     But for older videos, we'll leave this here.
     """
     """
+    run_time_int = 0
     if ":" in str(run_time):
     if ":" in str(run_time):
         run_time_list = run_time.split(":")
         run_time_list = run_time.split(":")
         hours = int(run_time_list[0])
         hours = int(run_time_list[0])
         minutes = int(run_time_list[1])
         minutes = int(run_time_list[1])
         seconds = int(run_time_list[2])
         seconds = int(run_time_list[2])
-        run_time = (((hours * 60) + minutes) * 60) + seconds
-    return int(run_time)
+        run_time_int = int((((hours * 60) + minutes) * 60) + seconds)
+    return run_time_int
 
 
 
 
 def parse_mopidy_uri(uri: str) -> dict:
 def parse_mopidy_uri(uri: str) -> dict: