// extractID3 attempts to extract MusicBrainz Picard tags from m.Raw(), where m.Format // is assumed to be a supported version of ID3. func extractID3(m tag.Metadata) Info { var txxx, ufid string switch m.Format() { case tag.ID3v2_2: txxx, ufid = "TXX", "UFI" case tag.ID3v2_3, tag.ID3v2_4: txxx, ufid = "TXXX", "UFID" } i := Info{} for k, v := range m.Raw() { switch { case strings.HasPrefix(k, txxx): if str, ok := v.(*tag.Comm); ok { i.set(str.Description, str.Text) } case strings.HasPrefix(k, ufid): if id, ok := v.(*tag.UFID); ok { if id.Provider == UFIDProviderURL { i.set(Recording, string(id.Identifier)) } } } } return i }
// extractMP4Vorbis attempts to extract MusicBrainz Picard tags from m.Raw(), where m.Format // is assumed to be MP4 or VORBIS. func extractMP4Vorbis(m tag.Metadata) Info { i := Info{} for t, v := range m.Raw() { if s, ok := v.(string); ok { i.set(t, s) } } return i }