From 8fd0ed6e176b770c4482a34d2d0bf2fdd314a3db Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 22 Dec 2025 10:23:34 -0500 Subject: [PATCH] [scrobbles] Auto set playback seconds --- PROJECT.org | 10 +++++++++- vrobbler/apps/scrobbles/models.py | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/PROJECT.org b/PROJECT.org index ce2224c..4c354b0 100644 --- a/PROJECT.org +++ b/PROJECT.org @@ -92,7 +92,7 @@ fetching and simple saving. :LOGBOOK: CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20 :END: -* Backlog [1/21] +* Backlog [2/24] ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles: ** TODO [#C] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement: :PROPERTIES: @@ -446,10 +446,18 @@ original intent of the scrobble. It may also allow us to clean up junk scrobbles if the data was just horribly wrong. +** TODO [#A] When creating org-mode tasks, don't copy comments :vrobbler:bug:scrobbles:tasks: ** TODO [#A] Fix lookup of music tracks from Musicbrainz :vrobbler:bug:tracks:music: +:PROPERTIES: +:ID: 2bc1cc0b-6c4e-bc3d-e7c3-47df364df206 +:END: Turns out we're not looking up music tracks properly, again. +** DONE [#B] Auto calc duration if no playback time seconds present :vrobbler:bug:scrobbles:personal:project: +:PROPERTIES: +:ID: e16228b2-b062-bd00-32e6-b2353e6406e9 +:END: ** DONE [#A] Fix raw text webpage title not truncating to 254 chars :vrobbler:personal:bug:webpages: :PROPERTIES: :ID: 13fa0efd-2c3f-dd07-deb2-62882096feff diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 7263780..82decb4 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -702,6 +702,9 @@ class Scrobble(TimeStampedModel): if self.media_obj: self.media_type = self.MediaType(self.media_obj.__class__.__name__) + if (self.timestamp and self.stop_timestamp) and (not self.playback_position_seconds or self.playback_position_seconds <= 0): + self.playback_position_seconds = (self.stop_timestamp - self.timestamp).seconds + return super(Scrobble, self).save(*args, **kwargs) def get_absolute_url(self):