mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-23 07:10:31 +03:00
refactor: moved magic strings to consts
This commit is contained in:
parent
5ef80d2490
commit
b4c7cac964
@ -1,6 +1,8 @@
|
||||
package consts
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
AppName = "navidrome"
|
||||
@ -40,3 +42,8 @@ var (
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
VariousArtists = "Various Artists"
|
||||
UnknownArtist = "[Unknown Artist]"
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/model"
|
||||
)
|
||||
|
||||
@ -121,7 +122,7 @@ func FromMediaFile(mf *model.MediaFile) Entry {
|
||||
func realArtistName(mf *model.MediaFile) string {
|
||||
switch {
|
||||
case mf.Compilation:
|
||||
return "Various Artists"
|
||||
return consts.VariousArtists
|
||||
case mf.AlbumArtist != "":
|
||||
return mf.AlbumArtist
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
. "github.com/Masterminds/squirrel"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/model"
|
||||
"github.com/deluan/rest"
|
||||
@ -108,7 +109,7 @@ func (r *albumRepository) Refresh(ids ...string) error {
|
||||
al.CoverArtId = ""
|
||||
}
|
||||
if al.Compilation {
|
||||
al.AlbumArtist = "Various Artists"
|
||||
al.AlbumArtist = consts.VariousArtists
|
||||
}
|
||||
if al.AlbumArtist == "" {
|
||||
al.AlbumArtist = al.Artist
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
. "github.com/Masterminds/squirrel"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/deluan/navidrome/conf"
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/model"
|
||||
"github.com/deluan/navidrome/utils"
|
||||
@ -128,7 +129,7 @@ func (r *artistRepository) Refresh(ids ...string) error {
|
||||
toUpdate := 0
|
||||
for _, ar := range artists {
|
||||
if ar.Compilation {
|
||||
ar.AlbumArtist = "Various Artists"
|
||||
ar.AlbumArtist = consts.VariousArtists
|
||||
}
|
||||
if ar.AlbumArtist != "" {
|
||||
ar.Name = ar.AlbumArtist
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/model"
|
||||
)
|
||||
@ -241,7 +242,7 @@ func (s *TagScanner) toMediaFile(md *Metadata) model.MediaFile {
|
||||
mf.AlbumID = s.albumID(md)
|
||||
mf.Album = s.mapAlbumName(md)
|
||||
if md.Artist() == "" {
|
||||
mf.Artist = "[Unknown Artist]"
|
||||
mf.Artist = consts.UnknownArtist
|
||||
} else {
|
||||
mf.Artist = md.Artist()
|
||||
}
|
||||
@ -278,13 +279,13 @@ func (s *TagScanner) mapTrackTitle(md *Metadata) string {
|
||||
func (s *TagScanner) mapArtistName(md *Metadata) string {
|
||||
switch {
|
||||
case md.Compilation():
|
||||
return "Various Artists"
|
||||
return consts.VariousArtists
|
||||
case md.AlbumArtist() != "":
|
||||
return md.AlbumArtist()
|
||||
case md.Artist() != "":
|
||||
return md.Artist()
|
||||
default:
|
||||
return "[Unknown Artist]"
|
||||
return consts.UnknownArtist
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user