From 0115eca1c6867e185aaa6813432e08b5dbfcf428 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Sun, 25 May 2025 15:53:01 +0200 Subject: [PATCH] Minor code cleanup when creation time.Duration --- internal/backends/deezer/deezer.go | 2 +- internal/backends/funkwhale/funkwhale.go | 2 +- internal/backends/spotify/spotify.go | 2 +- internal/backends/spotifyhistory/models.go | 2 +- internal/backends/subsonic/subsonic.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/backends/deezer/deezer.go b/internal/backends/deezer/deezer.go index a6eaec2..9d622df 100644 --- a/internal/backends/deezer/deezer.go +++ b/internal/backends/deezer/deezer.go @@ -251,7 +251,7 @@ func (t Track) AsTrack() models.Track { TrackName: t.Title, ReleaseName: t.Album.Title, ArtistNames: []string{t.Artist.Name}, - Duration: time.Duration(t.Duration * int(time.Second)), + Duration: time.Duration(t.Duration) * time.Second, AdditionalInfo: map[string]any{}, } diff --git a/internal/backends/funkwhale/funkwhale.go b/internal/backends/funkwhale/funkwhale.go index d9632a6..8874c70 100644 --- a/internal/backends/funkwhale/funkwhale.go +++ b/internal/backends/funkwhale/funkwhale.go @@ -220,7 +220,7 @@ func (t Track) AsTrack() models.Track { } if len(t.Uploads) > 0 { - track.Duration = time.Duration(t.Uploads[0].Duration * int(time.Second)) + track.Duration = time.Duration(t.Uploads[0].Duration) * time.Second } return track diff --git a/internal/backends/spotify/spotify.go b/internal/backends/spotify/spotify.go index b00ebba..fbfe821 100644 --- a/internal/backends/spotify/spotify.go +++ b/internal/backends/spotify/spotify.go @@ -258,7 +258,7 @@ func (t Track) AsTrack() models.Track { TrackName: t.Name, ReleaseName: t.Album.Name, ArtistNames: make([]string, 0, len(t.Artists)), - Duration: time.Duration(t.DurationMs * int(time.Millisecond)), + Duration: time.Duration(t.DurationMs) * time.Millisecond, TrackNumber: t.TrackNumber, DiscNumber: t.DiscNumber, ISRC: t.ExternalIDs.ISRC, diff --git a/internal/backends/spotifyhistory/models.go b/internal/backends/spotifyhistory/models.go index a2eba23..3efaa38 100644 --- a/internal/backends/spotifyhistory/models.go +++ b/internal/backends/spotifyhistory/models.go @@ -89,7 +89,7 @@ func (i HistoryItem) AsListen() models.Listen { AdditionalInfo: models.AdditionalInfo{}, }, ListenedAt: i.Timestamp, - PlaybackDuration: time.Duration(i.MillisecondsPlayed * int(time.Millisecond)), + PlaybackDuration: time.Duration(i.MillisecondsPlayed) * time.Millisecond, UserName: i.UserName, } if trackURL, err := formatSpotifyUri(i.SpotifyTrackUri); err != nil { diff --git a/internal/backends/subsonic/subsonic.go b/internal/backends/subsonic/subsonic.go index aa1b1e3..f75366d 100644 --- a/internal/backends/subsonic/subsonic.go +++ b/internal/backends/subsonic/subsonic.go @@ -121,7 +121,7 @@ func SongAsLove(song subsonic.Child, username string) models.Love { AdditionalInfo: map[string]any{ "subsonic_id": song.ID, }, - Duration: time.Duration(song.Duration * int(time.Second)), + Duration: time.Duration(song.Duration) * time.Second, }, }