mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Extract all id3 frames from file
This commit is contained in:
parent
5dea258058
commit
4d18212f5d
2 changed files with 11 additions and 9 deletions
|
@ -79,7 +79,7 @@ func (m *baseMetadata) Composer() string { return m.getTag("composer", "t
|
|||
func (m *baseMetadata) Genre() string { return m.getTag("genre") }
|
||||
func (m *baseMetadata) Year() int { return m.parseYear("date") }
|
||||
func (m *baseMetadata) Comment() string { return m.getTag("comment") }
|
||||
func (m *baseMetadata) Compilation() bool { return m.parseBool("compilation") }
|
||||
func (m *baseMetadata) Compilation() bool { return m.parseBool("tcmp", "compilation") }
|
||||
func (m *baseMetadata) TrackNumber() (int, int) { return m.parseTuple("track", "tracknumber") }
|
||||
func (m *baseMetadata) DiscNumber() (int, int) { return m.parseTuple("disc", "discnumber") }
|
||||
func (m *baseMetadata) DiscSubtitle() string {
|
||||
|
@ -168,10 +168,12 @@ func (m *baseMetadata) parseTuple(tags ...string) (int, int) {
|
|||
return 0, 0
|
||||
}
|
||||
|
||||
func (m *baseMetadata) parseBool(tagName string) bool {
|
||||
if v, ok := m.tags[tagName]; ok {
|
||||
i, _ := strconv.Atoi(strings.TrimSpace(v))
|
||||
return i == 1
|
||||
func (m *baseMetadata) parseBool(tags ...string) bool {
|
||||
for _, tagName := range tags {
|
||||
if v, ok := m.tags[tagName]; ok {
|
||||
i, _ := strconv.Atoi(strings.TrimSpace(v))
|
||||
return i == 1
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -57,10 +57,10 @@ int taglib_read(const char *filename, unsigned long id) {
|
|||
if (mp3File->ID3v2Tag()) {
|
||||
const auto &frameListMap(mp3File->ID3v2Tag()->frameListMap());
|
||||
|
||||
if (!frameListMap["TCMP"].isEmpty())
|
||||
tags.insert("compilation", frameListMap["TCMP"].front()->toString());
|
||||
if (!frameListMap["TSST"].isEmpty())
|
||||
tags.insert("discsubtitle", frameListMap["TSST"].front()->toString());
|
||||
for (const auto &[name, values] : frameListMap) {
|
||||
if (!values.isEmpty())
|
||||
tags.insert(name, values.front()->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue