Add MBIDs to media_file, album and artist

This commit is contained in:
Deluan 2020-08-27 16:51:55 -04:00
parent 64ccb4d188
commit 6663c079e0
9 changed files with 138 additions and 2 deletions

View file

@ -52,6 +52,13 @@ func (s *mediaFileMapper) toMediaFile(md metadata.Metadata) model.MediaFile {
mf.OrderAlbumName = sanitizeFieldForSorting(mf.Album)
mf.OrderArtistName = sanitizeFieldForSorting(mf.Artist)
mf.OrderAlbumArtistName = sanitizeFieldForSorting(mf.AlbumArtist)
mf.CatalogNum = md.CatalogNum()
mf.MbzTrackID = md.MbzTrackID()
mf.MbzAlbumID = md.MbzAlbumID()
mf.MbzArtistID = md.MbzArtistID()
mf.MbzAlbumArtistID = md.MbzAlbumArtistID()
mf.MbzAlbumType = md.MbzAlbumType()
mf.MbzAlbumComment = md.MbzAlbumComment()
// TODO Get Creation time. https://github.com/djherbis/times ?
mf.CreatedAt = md.ModificationTime()

View file

@ -52,6 +52,37 @@ var _ = Describe("ffmpegExtractor", func() {
})
Context("extractMetadata", func() {
It("extracts MusicBrainz custom tags", func() {
const output = `
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Colt 45 - Underground Post-Punk, Tropical Tapes, Lo Fi Electronics And Others Sounds From Brazil (1983 - 1993) Selected By Tetine/01-06 X.m4a':
Metadata:
title : X
artist : Saara Saara
composer : Servio Tulio & Raul Rachid
album : Colt 45 - Underground Post-Punk, Tropical Tapes, Lo Fi Electronics And Others Sounds From Brazil (1983 - 1993) Selected By Tetine
genre : Alternative
MusicBrainz Release Group Id: 0
MusicBrainz Album Artist Id: 194
MusicBrainz Artist Id: 200455
MusicBrainz Album Release Country: Unknown
MusicBrainz Album Id: 11406732
MusicBrainz Track Id: 11406732-6
Label : Slum Dunk Music
publisher : Slum Dunk Music
MusicBrainz Album Type: Compilation
MusicBrainz Album Comment: MP3
CATALOGNUMBER : SLUM DUNK MUSIC 009
`
md, _ := extractMetadata("tests/fixtures/test.mp3", output)
Expect(md.CatalogNum()).To(Equal("SLUM DUNK MUSIC 009"))
Expect(md.MbzTrackID()).To(Equal("11406732-6"))
Expect(md.MbzAlbumID()).To(Equal("11406732"))
Expect(md.MbzArtistID()).To(Equal("200455"))
Expect(md.MbzAlbumArtistID()).To(Equal("194"))
Expect(md.MbzAlbumType()).To(Equal("Compilation"))
Expect(md.MbzAlbumComment()).To(Equal("MP3"))
})
It("detects embedded cover art correctly", func() {
const output = `
Input #0, mp3, from '/Users/deluan/Music/iTunes/iTunes Media/Music/Compilations/Putumayo Presents Blues Lounge/09 Pablo's Blues.mp3':

View file

@ -51,6 +51,13 @@ type Metadata interface {
HasPicture() bool
Comment() string
Compilation() bool
CatalogNum() string
MbzTrackID() string
MbzAlbumID() string
MbzArtistID() string
MbzAlbumArtistID() string
MbzAlbumType() string
MbzAlbumComment() string
Duration() float32
BitRate() int
ModificationTime() time.Time
@ -87,6 +94,25 @@ func (m *baseMetadata) DiscNumber() (int, int) { return m.parseTuple("disc", "d
func (m *baseMetadata) DiscSubtitle() string {
return m.getTag("tsst", "discsubtitle", "setsubtitle")
}
func (m *baseMetadata) CatalogNum() string { return m.getTag("catalognumber") }
func (m *baseMetadata) MbzTrackID() string {
return m.getTag("musicbrainz_trackid", "musicbrainz track id")
}
func (m *baseMetadata) MbzAlbumID() string {
return m.getTag("musicbrainz_albumid", "musicbrainz album id")
}
func (m *baseMetadata) MbzArtistID() string {
return m.getTag("musicbrainz_artistid", "musicbrainz artist id")
}
func (m *baseMetadata) MbzAlbumArtistID() string {
return m.getTag("musicbrainz_albumartistid", "musicbrainz album artist id")
}
func (m *baseMetadata) MbzAlbumType() string {
return m.getTag("musicbrainz_albumtype", "musicbrainz album type")
}
func (m *baseMetadata) MbzAlbumComment() string {
return m.getTag("musicbrainz_albumcomment", "musicbrainz album comment")
}
func (m *baseMetadata) ModificationTime() time.Time { return m.fileInfo.ModTime() }
func (m *baseMetadata) Size() int64 { return m.fileInfo.Size() }