Code style: All uppercase acronyms URL, ISRC, ID, HTTP

This commit is contained in:
Philipp Wolfer 2025-04-29 13:23:41 +02:00
parent 39b31fc664
commit d51c97c648
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
26 changed files with 137 additions and 137 deletions

View file

@ -34,7 +34,7 @@ import (
type SpotifyApiBackend struct {
client Client
clientId string
clientID string
clientSecret string
}
@ -53,14 +53,14 @@ func (b *SpotifyApiBackend) Options() []models.BackendOption {
}
func (b *SpotifyApiBackend) InitConfig(config *config.ServiceConfig) error {
b.clientId = config.GetString("client-id")
b.clientID = config.GetString("client-id")
b.clientSecret = config.GetString("client-secret")
return nil
}
func (b *SpotifyApiBackend) OAuth2Strategy(redirectUrl *url.URL) auth.OAuth2Strategy {
func (b *SpotifyApiBackend) OAuth2Strategy(redirectURL *url.URL) auth.OAuth2Strategy {
conf := oauth2.Config{
ClientID: b.clientId,
ClientID: b.clientID,
ClientSecret: b.clientSecret,
Scopes: []string{
"user-read-currently-playing",
@ -68,16 +68,16 @@ func (b *SpotifyApiBackend) OAuth2Strategy(redirectUrl *url.URL) auth.OAuth2Stra
"user-library-read",
"user-library-modify",
},
RedirectURL: redirectUrl.String(),
RedirectURL: redirectURL.String(),
Endpoint: spotify.Endpoint,
}
return auth.NewStandardStrategy(conf)
}
func (b *SpotifyApiBackend) OAuth2Config(redirectUrl *url.URL) oauth2.Config {
func (b *SpotifyApiBackend) OAuth2Config(redirectURL *url.URL) oauth2.Config {
return oauth2.Config{
ClientID: b.clientId,
ClientID: b.clientID,
ClientSecret: b.clientSecret,
Scopes: []string{
"user-read-currently-playing",
@ -85,7 +85,7 @@ func (b *SpotifyApiBackend) OAuth2Config(redirectUrl *url.URL) oauth2.Config {
"user-library-read",
"user-library-modify",
},
RedirectURL: redirectUrl.String(),
RedirectURL: redirectURL.String(),
Endpoint: spotify.Endpoint,
}
}
@ -251,7 +251,7 @@ func (t Track) AsTrack() models.Track {
Duration: time.Duration(t.DurationMs * int(time.Millisecond)),
TrackNumber: t.TrackNumber,
DiscNumber: t.DiscNumber,
ISRC: t.ExternalIds.ISRC,
ISRC: t.ExternalIDs.ISRC,
AdditionalInfo: map[string]any{},
}
@ -264,30 +264,30 @@ func (t Track) AsTrack() models.Track {
info["music_service"] = "spotify.com"
}
if t.ExternalUrls.Spotify != "" {
info["origin_url"] = t.ExternalUrls.Spotify
info["spotify_id"] = t.ExternalUrls.Spotify
if t.ExternalURLs.Spotify != "" {
info["origin_url"] = t.ExternalURLs.Spotify
info["spotify_id"] = t.ExternalURLs.Spotify
}
if t.Album.ExternalUrls.Spotify != "" {
info["spotify_album_id"] = t.Album.ExternalUrls.Spotify
if t.Album.ExternalURLs.Spotify != "" {
info["spotify_album_id"] = t.Album.ExternalURLs.Spotify
}
if len(t.Artists) > 0 {
info["spotify_artist_ids"] = extractArtistIds(t.Artists)
info["spotify_artist_ids"] = extractArtistIDs(t.Artists)
}
if len(t.Album.Artists) > 0 {
info["spotify_album_artist_ids"] = extractArtistIds(t.Album.Artists)
info["spotify_album_artist_ids"] = extractArtistIDs(t.Album.Artists)
}
return track
}
func extractArtistIds(artists []Artist) []string {
artistIds := make([]string, len(artists))
func extractArtistIDs(artists []Artist) []string {
artistIDs := make([]string, len(artists))
for i, artist := range artists {
artistIds[i] = artist.ExternalUrls.Spotify
artistIDs[i] = artist.ExternalURLs.Spotify
}
return artistIds
return artistIDs
}