[music] Fix timezones on lastfm imports

This commit is contained in:
2025-07-25 17:35:56 -04:00
parent 5427198185
commit b2077678e2

View File

@ -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)