From a7551ef1621eacd7bf1c19ba04bb083c464d28b5 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 28 Jul 2025 10:52:02 -0400 Subject: [PATCH] [music] Weird hack to get timezone for LFM scrobbles Last.fm seems to send timestamps for scrobbles with a timezone of UTC but the actual timezone is already localized. But that means we can't extract the timezone we want, even though the timestamp is already in the right timezone for storage. --- vrobbler/apps/scrobbles/importers/lastfm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vrobbler/apps/scrobbles/importers/lastfm.py b/vrobbler/apps/scrobbles/importers/lastfm.py index 6e01020..c5100d2 100644 --- a/vrobbler/apps/scrobbles/importers/lastfm.py +++ b/vrobbler/apps/scrobbles/importers/lastfm.py @@ -50,6 +50,9 @@ class LastFM: enrich=True, ) + tz_timestamp = self.vrobbler_user.profile.get_timestamp_with_tz( + lfm_scrobble.get("timestamp") + ) timestamp = lfm_scrobble.get("timestamp") stop_timestamp = timestamp + timedelta( seconds=track.run_time_seconds @@ -63,7 +66,7 @@ class LastFM: played_to_completion=True, in_progress=False, media_type=Scrobble.MediaType.TRACK, - timezone=timestamp.tzinfo.name, + timezone=tz_timestamp.tzinfo.name, ) # Vrobbler scrobbles on finish, LastFM scrobbles on start seconds_eariler = timestamp - timedelta(seconds=20)