Skip to content

Commit

Permalink
metadata: --artist & --album tags take priority over derived
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyatsats committed Dec 15, 2019
1 parent 8459ad7 commit 48b9318
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,7 @@ func ProbeTagsToInfo(p *ffprobe.Tags) *Info {
// compare file & path info against ffprobe.Tags info and combine into best
// return includes boolean if info sources match (no update necessary)
func (m *Metadata) MatchBestInfo(c, p *Info) (*Info, bool) {
// set custom artist
if len(c.Artist) > 0 {
m.Info.Artist = c.Artist
}

// set custom album
if len(c.Album) > 0 {
m.Info.mergeAlbumInfo(infoFromAlbum(c.Album), true)
}

// pull info from album
// pull date info from ffprobe.Tags album and force merge into itself
p.mergeAlbumInfo(infoFromAlbum(p.Album), true)

// compare using safeFilename since info is derived from filename
Expand All @@ -72,8 +62,11 @@ func (m *Metadata) MatchBestInfo(c, p *Info) (*Info, bool) {
compare.Album = safeFilename(compare.Album)
compare.Title = safeFilename(compare.Title)

match := true
if *m.Info != *compare {
// take longer album if custom album not set
match = false

// take longer album
m.Info.mergeAlbumInfo(p, false)

if len(m.Info.Artist) == 0 {
Expand All @@ -89,11 +82,25 @@ func (m *Metadata) MatchBestInfo(c, p *Info) (*Info, bool) {
if len(m.Info.Title) < len(p.Title) {
m.Info.Title = p.Title
}
}

return m.Info, false
// set custom artist
if len(c.Artist) > 0 {
if c.Artist != m.Info.Artist {
match = false
}
m.Info.Artist = c.Artist
}

// set custom album
if len(c.Album) > 0 {
if c.Album != m.Info.ToAlbum() {
match = false
}
m.Info.mergeAlbumInfo(infoFromAlbum(c.Album), true)
}

return m.Info, true
return m.Info, match
}

// derive info album info from nested folder path
Expand Down

0 comments on commit 48b9318

Please sign in to comment.