Explo icon indicating copy to clipboard operation
Explo copied to clipboard

Explo will fail to get the exploration playlist if ListenBrainz timezone is ahead of UTC

Open firewalkwithm3 opened this issue 10 months ago • 1 comments

I have set my timezone to UTC+8 at https://listenbrainz.org/settings/select_timezone Therefore, ListenBrainz generates my exploration playlist every Monday at 00:00 UTC+8.

However, the API returns the playlist's created time in UTC+0 meaning Explo thinks the playlist was created on Sunday and therefore will never return any playlist.

I made the following change and it works correctly for my case at least:

diff --git a/src/listenbrainz.go b/src/listenbrainz.go
index c4dfb47..b48b74a 100644
--- a/src/listenbrainz.go
+++ b/src/listenbrainz.go
@@ -194,7 +194,7 @@ func getWeeklyExploration(cfg Listenbrainz) (string, error) {
 	for _, playlist := range playlists.Playlist {
 
 		_, currentWeek := time.Now().Local().ISOWeek()
-		_, creationWeek := playlist.Data.Date.ISOWeek()
+		_, creationWeek := playlist.Data.Date.Local().ISOWeek()
 
 		if strings.Contains(playlist.Data.Title, "Weekly Exploration") && currentWeek == creationWeek {
 			id := strings.Split(playlist.Data.Identifier, "/")
@@ -271,4 +271,4 @@ func lbRequest(path string) ([]byte, error) { // Handle ListenBrainz API request
 		return nil, err
 	}
 	return body, nil
-}
\ No newline at end of file
+}

firewalkwithm3 avatar Apr 09 '25 13:04 firewalkwithm3

Thanks for reporting and giving a fix! It will be incorporated in the refactor.

LumePart avatar Apr 10 '25 16:04 LumePart