mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 13:38:15 -08:00
fix: ensure mbids in mbidmapping are discovered (#180)
This commit is contained in:
parent
937f9062b5
commit
c8a11ef018
3 changed files with 44 additions and 3 deletions
|
|
@ -264,6 +264,34 @@ func TestImportListenBrainz_MbzDisabled(t *testing.T) {
|
||||||
truncateTestData(t)
|
truncateTestData(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImportListenBrainz_MBIDMapping(t *testing.T) {
|
||||||
|
|
||||||
|
src := path.Join("..", "test_assets", "listenbrainz_shoko1_123456789.zip")
|
||||||
|
destDir := filepath.Join(cfg.ConfigDir(), "import")
|
||||||
|
dest := filepath.Join(destDir, "listenbrainz_shoko1_123456789.zip")
|
||||||
|
|
||||||
|
// not going to make the dest dir because engine should make it already
|
||||||
|
|
||||||
|
input, err := os.ReadFile(src)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.NoError(t, os.WriteFile(dest, input, os.ModePerm))
|
||||||
|
|
||||||
|
engine.RunImporter(logger.Get(), store, &mbz.MbzErrorCaller{})
|
||||||
|
|
||||||
|
album, err := store.GetAlbum(context.Background(), db.GetAlbumOpts{MusicBrainzID: uuid.MustParse("177ebc28-0115-3897-8eb3-ebf74ce23790")})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "Zombie", album.Title)
|
||||||
|
artist, err := store.GetArtist(context.Background(), db.GetArtistOpts{MusicBrainzID: uuid.MustParse("c98d40fd-f6cf-4b26-883e-eaa515ee2851")})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "The Cranberries", artist.Name)
|
||||||
|
track, err := store.GetTrack(context.Background(), db.GetTrackOpts{MusicBrainzID: uuid.MustParse("3bbeb4e3-ab6d-460d-bfc5-de49e4251061")})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "Zombie", track.Title)
|
||||||
|
|
||||||
|
truncateTestData(t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestImportKoito(t *testing.T) {
|
func TestImportKoito(t *testing.T) {
|
||||||
|
|
||||||
src := path.Join("..", "test_assets", "koito_export_test.json")
|
src := path.Join("..", "test_assets", "koito_export_test.json")
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,14 @@ func ImportListenBrainzFile(ctx context.Context, store db.DB, mbzc mbz.MusicBrai
|
||||||
}
|
}
|
||||||
artistMbzIDs, err := utils.ParseUUIDSlice(payload.TrackMeta.AdditionalInfo.ArtistMBIDs)
|
artistMbzIDs, err := utils.ParseUUIDSlice(payload.TrackMeta.AdditionalInfo.ArtistMBIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debug().Err(err).Msg("Failed to parse one or more uuids")
|
l.Debug().AnErr("error", err).Msg("ImportListenBrainzFile: Failed to parse one or more UUIDs")
|
||||||
|
}
|
||||||
|
if len(artistMbzIDs) < 1 {
|
||||||
|
l.Debug().AnErr("error", err).Msg("ImportListenBrainzFile: Attempting to parse artist UUIDs from mbid_mapping")
|
||||||
|
utils.ParseUUIDSlice(payload.TrackMeta.MBIDMapping.ArtistMBIDs)
|
||||||
|
if err != nil {
|
||||||
|
l.Debug().AnErr("error", err).Msg("ImportListenBrainzFile: Failed to parse one or more UUIDs")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rgMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.ReleaseGroupMBID)
|
rgMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.ReleaseGroupMBID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -93,11 +100,17 @@ func ImportListenBrainzFile(ctx context.Context, store db.DB, mbzc mbz.MusicBrai
|
||||||
}
|
}
|
||||||
releaseMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.ReleaseMBID)
|
releaseMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.ReleaseMBID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
releaseMbzID = uuid.Nil
|
releaseMbzID, err = uuid.Parse(payload.TrackMeta.MBIDMapping.ReleaseMBID)
|
||||||
|
if err != nil {
|
||||||
|
releaseMbzID = uuid.Nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recordingMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.RecordingMBID)
|
recordingMbzID, err := uuid.Parse(payload.TrackMeta.AdditionalInfo.RecordingMBID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
recordingMbzID = uuid.Nil
|
recordingMbzID, err = uuid.Parse(payload.TrackMeta.MBIDMapping.RecordingMBID)
|
||||||
|
if err != nil {
|
||||||
|
recordingMbzID = uuid.Nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var client string
|
var client string
|
||||||
|
|
|
||||||
BIN
test_assets/listenbrainz_shoko1_123456789.zip
Normal file
BIN
test_assets/listenbrainz_shoko1_123456789.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue