From b2077678e276c2fa39c003d25b904c7b81e5fa2e Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 25 Jul 2025 17:35:56 -0400 Subject: [PATCH] [music] Fix timezones on lastfm imports --- vrobbler/apps/scrobbles/importers/lastfm.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vrobbler/apps/scrobbles/importers/lastfm.py b/vrobbler/apps/scrobbles/importers/lastfm.py index f74e398..23a8d36 100644 --- a/vrobbler/apps/scrobbles/importers/lastfm.py +++ b/vrobbler/apps/scrobbles/importers/lastfm.py @@ -50,20 +50,22 @@ class LastFM: enrich=True, ) - timezone = settings.TIME_ZONE - if self.vrobbler_user.profile: - timezone = self.vrobbler_user.profile.timezone - - timestamp = lfm_scrobble.get("timestamp") + timestamp = self.vrobbler_user.profile.get_timestamp_with_tz( + lfm_scrobble.get("timestamp") + ) + stop_timestamp = timestamp + timedelta( + seconds=track.run_time_seconds + ) new_scrobble = Scrobble( user=self.vrobbler_user, timestamp=timestamp, + stop_timestamp=stop_timestamp, source=source, track=track, - timezone=timezone, played_to_completion=True, in_progress=False, media_type=Scrobble.MediaType.TRACK, + timezone=timestamp.tzinfo.name, ) # Vrobbler scrobbles on finish, LastFM scrobbles on start seconds_eariler = timestamp - timedelta(seconds=20)