Some small refactorings
This commit is contained in:
+10
-10
@@ -31,7 +31,7 @@ func newMediaFileMapper(rootFolder string, genres model.GenreRepository) *mediaF
|
||||
}
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) toMediaFile(md *metadata.Tags) model.MediaFile {
|
||||
func (s mediaFileMapper) toMediaFile(md metadata.Tags) model.MediaFile {
|
||||
mf := &model.MediaFile{}
|
||||
mf.ID = s.trackID(md)
|
||||
mf.Title = s.mapTrackTitle(md)
|
||||
@@ -82,7 +82,7 @@ func sanitizeFieldForSorting(originalValue string) string {
|
||||
return utils.NoArticle(v)
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) mapTrackTitle(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) mapTrackTitle(md metadata.Tags) string {
|
||||
if md.Title() == "" {
|
||||
s := strings.TrimPrefix(md.FilePath(), s.rootFolder+string(os.PathSeparator))
|
||||
e := filepath.Ext(s)
|
||||
@@ -91,7 +91,7 @@ func (s *mediaFileMapper) mapTrackTitle(md *metadata.Tags) string {
|
||||
return md.Title()
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) mapAlbumArtistName(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) mapAlbumArtistName(md metadata.Tags) string {
|
||||
switch {
|
||||
case md.AlbumArtist() != "":
|
||||
return md.AlbumArtist()
|
||||
@@ -104,14 +104,14 @@ func (s *mediaFileMapper) mapAlbumArtistName(md *metadata.Tags) string {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) mapArtistName(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) mapArtistName(md metadata.Tags) string {
|
||||
if md.Artist() != "" {
|
||||
return md.Artist()
|
||||
}
|
||||
return consts.UnknownArtist
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) mapAlbumName(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) mapAlbumName(md metadata.Tags) string {
|
||||
name := md.Album()
|
||||
if name == "" {
|
||||
return "[Unknown Album]"
|
||||
@@ -119,24 +119,24 @@ func (s *mediaFileMapper) mapAlbumName(md *metadata.Tags) string {
|
||||
return name
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) trackID(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) trackID(md metadata.Tags) string {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(md.FilePath())))
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) albumID(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) albumID(md metadata.Tags) string {
|
||||
albumPath := strings.ToLower(fmt.Sprintf("%s\\%s", s.mapAlbumArtistName(md), s.mapAlbumName(md)))
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(albumPath)))
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) artistID(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) artistID(md metadata.Tags) string {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(strings.ToLower(s.mapArtistName(md)))))
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) albumArtistID(md *metadata.Tags) string {
|
||||
func (s mediaFileMapper) albumArtistID(md metadata.Tags) string {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(strings.ToLower(s.mapAlbumArtistName(md)))))
|
||||
}
|
||||
|
||||
func (s *mediaFileMapper) mapGenres(genres []string) (string, model.Genres) {
|
||||
func (s mediaFileMapper) mapGenres(genres []string) (string, model.Genres) {
|
||||
var result model.Genres
|
||||
unique := map[string]struct{}{}
|
||||
var all []string
|
||||
|
||||
Reference in New Issue
Block a user