diff --git a/whipper/common/mbngs.py b/whipper/common/mbngs.py index cff56e7d..660d0057 100644 --- a/whipper/common/mbngs.py +++ b/whipper/common/mbngs.py @@ -135,7 +135,8 @@ def getSortName(self): return self.joiner(lambda i: i.get('artist').get('sort-name', None)) def getName(self): - return self.joiner(lambda i: i.get('artist').get('name', None)) + return self.joiner(lambda i: i.get('name', + i.get('artist').get('name', None))) def getIds(self): return self.joiner(lambda i: i.get('artist').get('id', None), @@ -214,7 +215,9 @@ def _getMetadata(releaseShort, release, discid, country=None): discMD.title = title for t in medium['track-list']: track = TrackMetadata() - trackCredit = _Credit(t['recording']['artist-credit']) + trackCredit = _Credit( + t.get('artist-credit', t['recording']['artist-credit'] + )) if len(trackCredit) > 1: logger.debug('artist-credit more than 1: %r', trackCredit) diff --git a/whipper/test/test_common_mbngs.py b/whipper/test/test_common_mbngs.py index 78879e2f..a3b2f2a6 100644 --- a/whipper/test/test_common_mbngs.py +++ b/whipper/test/test_common_mbngs.py @@ -114,3 +114,81 @@ def testMalaInCuba(self): ';ec07a209-55ff-4084-bc41-9d4d1764e075' ';f626b92e-07b1-4a19-ad13-c09d690db66c' ) + + def testNorthernGateway(self): + """ + check the received metadata for artists tagged with [unknown] + and artists tagged with an alias in MusicBrainz + + see https://github.com/JoeLametta/whipper/issues/155 + """ + filename = 'whipper.release.38b05c7d-65fe-4dc0-9c10-33a391b86703.json' + path = os.path.join(os.path.dirname(__file__), filename) + handle = open(path, "rb") + response = json.loads(handle.read()) + handle.close() + discid = "rzGHHqfPWIq1GsOLhhlBcZuqo.I-" + + metadata = mbngs._getMetadata({}, response['release'], discid) + self.assertEquals(metadata.artist, u'Various Artists') + self.assertEquals(metadata.release, u'2010') + self.assertEquals(metadata.mbidArtist, + u'89ad4ac3-39f7-470e-963a-56509c546377') + + self.assertEquals(len(metadata.tracks), 10) + + track2 = metadata.tracks[1] + + self.assertEquals(track2.artist, u'Twisted Reaction feat. Danielle') + self.assertEquals(track2.sortName, + u'Twisted Reaction feat. [unknown]') + self.assertEquals(track2.mbidArtist, + u'4f69f624-73ea-4a16-b822-bd2ca58032bf' + ';125ec42a-7229-4250-afc5-e057484327fe' + ) + + track4 = metadata.tracks[3] + + self.assertEquals(track4.artist, u'BioGenesis') + self.assertEquals(track4.sortName, + u'Bio Genesis') + self.assertEquals(track4.mbidArtist, + u'dd61b86c-c015-43e1-9a28-58fceb0975c8' + ) + + def testNenaAndKimWildSingle(self): + """ + check the received metadata for artists that differ between + named on release and named in recording + """ + filename = 'whipper.release.f484a9fc-db21-4106-9408-bcd105c90047.json' + path = os.path.join(os.path.dirname(__file__), filename) + handle = open(path, "rb") + response = json.loads(handle.read()) + handle.close() + discid = "X2c2IQ5vUy5x6Jh7Xi_DGHtA1X8-" + + metadata = mbngs._getMetadata({}, response['release'], discid) + self.assertEquals(metadata.artist, u'Nena & Kim Wilde') + self.assertEquals(metadata.release, u'2003-05-19') + self.assertEquals(metadata.mbidArtist, + u'38bfaa7f-ee98-48cb-acd0-946d7aeecd76' + ';4b462375-c508-432a-8c88-ceeec38b16ae') + + self.assertEquals(len(metadata.tracks), 4) + + track1 = metadata.tracks[0] + + self.assertEquals(track1.artist, u'Nena & Kim Wilde') + self.assertEquals(track1.sortName, u'Nena & Wilde, Kim') + self.assertEquals(track1.mbidArtist, + u'38bfaa7f-ee98-48cb-acd0-946d7aeecd76' + ';4b462375-c508-432a-8c88-ceeec38b16ae') + + track2 = metadata.tracks[1] + + self.assertEquals(track2.artist, u'Nena & Kim Wilde') + self.assertEquals(track2.sortName, u'Nena & Wilde, Kim') + self.assertEquals(track2.mbidArtist, + u'38bfaa7f-ee98-48cb-acd0-946d7aeecd76' + ';4b462375-c508-432a-8c88-ceeec38b16ae') diff --git a/whipper/test/whipper.release.38b05c7d-65fe-4dc0-9c10-33a391b86703.json b/whipper/test/whipper.release.38b05c7d-65fe-4dc0-9c10-33a391b86703.json new file mode 100644 index 00000000..5ba9564e --- /dev/null +++ b/whipper/test/whipper.release.38b05c7d-65fe-4dc0-9c10-33a391b86703.json @@ -0,0 +1 @@ +{"release": {"status": "Promotion", "artist-credit": [{"artist": {"sort-name": "Various Artists", "disambiguation": "add compilations to this artist", "id": "89ad4ac3-39f7-470e-963a-56509c546377", "name": "Various Artists"}}], "label-info-list": [], "title": "Northern Gateway", "release-event-count": 1, "medium-count": 1, "cover-art-archive": {"count": "3", "front": "true", "back": "true", "artwork": "true"}, "release-event-list": [{"date": "2010", "area": {"sort-name": "Germany", "iso-3166-1-code-list": ["DE"], "id": "85752fda-13c4-31a3-bee5-0e5cb1f51dad", "name": "Germany"}}], "medium-list": [{"position": "1", "track-count": 10, "format": "CD", "disc-list": [{"offset-list": [150, 31869, 65080, 100394, 137049, 176151, 205976, 236876, 269301, 301592], "id": "rzGHHqfPWIq1GsOLhhlBcZuqo.I-", "sectors": "333836", "offset-count": 10}], "track-list": [{"artist-credit": [{"artist": {"sort-name": "Bubble", "disambiguation": "Psytrance duo consisting of Guy Sernat and Karen Bagdasarov", "id": "4b136bbc-0bd1-4cb9-be8e-c251cf3666d4", "name": "Bubble"}}], "number": "1", "artist-credit-phrase": "Bubble", "recording": {"artist-credit": [{"artist": {"sort-name": "Bubble", "disambiguation": "Psytrance duo consisting of Guy Sernat and Karen Bagdasarov", "id": "4b136bbc-0bd1-4cb9-be8e-c251cf3666d4", "name": "Bubble"}}], "length": "422920", "artist-credit-phrase": "Bubble", "id": "b8eb2826-20ef-42f0-9df1-f66d8bac9f0f", "title": "Different Story"}, "length": "422920", "position": "1", "id": "33eabef0-24be-4d98-bb6a-aa5499854bd1", "track_or_recording_length": "422920"}, {"artist-credit": [{"artist": {"sort-name": "Twisted Reaction", "id": "4f69f624-73ea-4a16-b822-bd2ca58032bf", "name": "Twisted Reaction"}}, " feat. ", {"name": "Danielle", "artist": {"sort-name": "[unknown]", "disambiguation": "Special Purpose Artist - Do not add releases here, if possible.", "id": "125ec42a-7229-4250-afc5-e057484327fe", "name": "[unknown]"}}], "number": "2", "artist-credit-phrase": "Twisted Reaction feat. Danielle", "recording": {"artist-credit": [{"artist": {"sort-name": "Twisted Reaction", "id": "4f69f624-73ea-4a16-b822-bd2ca58032bf", "name": "Twisted Reaction"}}, " feat. ", {"name": "Danielle", "artist": {"sort-name": "[unknown]", "disambiguation": "Special Purpose Artist - Do not add releases here, if possible.", "id": "125ec42a-7229-4250-afc5-e057484327fe", "name": "[unknown]"}}], "length": "442813", "artist-credit-phrase": "Twisted Reaction feat. Danielle", "id": "ac52c692-6b13-401f-810b-d9b733b6594e", "title": "New Generation of Science"}, "length": "442813", "position": "2", "id": "ef43e443-f305-4085-b51c-db75ee1bdbfd", "track_or_recording_length": "442813"}, {"artist-credit": [{"artist": {"sort-name": "Painkiller", "disambiguation": "Psytrance artist based in Barcelona, Spain.", "id": "06391f11-b2a5-4168-8296-c0ed1b0fbe26", "name": "Painkiller"}}, " & ", {"name": "Chris", "artist": {"sort-name": "[unknown]", "disambiguation": "Special Purpose Artist - Do not add releases here, if possible.", "id": "125ec42a-7229-4250-afc5-e057484327fe", "name": "[unknown]"}}], "number": "3", "artist-credit-phrase": "Painkiller & Chris", "recording": {"artist-credit": [{"artist": {"sort-name": "Painkiller", "disambiguation": "Psytrance artist based in Barcelona, Spain.", "id": "06391f11-b2a5-4168-8296-c0ed1b0fbe26", "name": "Painkiller"}}, " & ", {"name": "Chris", "artist": {"sort-name": "[unknown]", "disambiguation": "Special Purpose Artist - Do not add releases here, if possible.", "id": "125ec42a-7229-4250-afc5-e057484327fe", "name": "[unknown]"}}], "length": "470853", "artist-credit-phrase": "Painkiller & Chris", "id": "311ffad5-9877-4c6a-9b48-160412835607", "title": "Purest Form"}, "length": "470853", "position": "3", "id": "098f0417-5449-4046-b006-08eefad21839", "track_or_recording_length": "470853"}, {"artist-credit": [{"name": "BioGenesis", "artist": {"sort-name": "Bio Genesis", "disambiguation": "Spanish psy-trance project", "id": "dd61b86c-c015-43e1-9a28-58fceb0975c8", "name": "Bio Genesis"}}], "number": "4", "artist-credit-phrase": "BioGenesis", "recording": {"artist-credit": [{"name": "BioGenesis", "artist": {"sort-name": "Bio Genesis", "disambiguation": "Spanish psy-trance project", "id": "dd61b86c-c015-43e1-9a28-58fceb0975c8", "name": "Bio Genesis"}}], "length": "488733", "artist-credit-phrase": "BioGenesis", "id": "b1c99a56-e802-4a34-919c-b754fa056a8f", "title": "Ride the Wave"}, "length": "488733", "position": "4", "id": "be9cac8e-d770-47cd-bc13-6189eac14e17", "track_or_recording_length": "488733"}, {"artist-credit": [{"name": "R.E.V.", "artist": {"sort-name": "Rev", "disambiguation": "psytrance artist Troy Leidich", "id": "d7f9d566-4341-4b19-8219-e3f2e84cf7a7", "name": "Rev"}}], "number": "5", "artist-credit-phrase": "R.E.V.", "recording": {"artist-credit": [{"name": "R.E.V.", "artist": {"sort-name": "Rev", "disambiguation": "psytrance artist Troy Leidich", "id": "d7f9d566-4341-4b19-8219-e3f2e84cf7a7", "name": "Rev"}}], "length": "521360", "artist-credit-phrase": "R.E.V.", "id": "8fe058dc-1cea-43ca-81b3-e2613ed315e4", "title": "PU 329"}, "length": "521360", "position": "5", "id": "6525bbd7-fdc4-45a2-b0d9-c8a7e723cfab", "track_or_recording_length": "521360"}, {"artist-credit": [{"artist": {"sort-name": "Schatzhauser", "disambiguation": "Psychedelic trance artist from Rostock,Germany", "id": "75110376-62a8-427e-a53c-67ad6adb06b1", "name": "Schatzhauser"}}], "number": "6", "artist-credit-phrase": "Schatzhauser", "recording": {"artist-credit": [{"artist": {"sort-name": "Schatzhauser", "disambiguation": "Psychedelic trance artist from Rostock,Germany", "id": "75110376-62a8-427e-a53c-67ad6adb06b1", "name": "Schatzhauser"}}], "length": "397666", "artist-credit-phrase": "Schatzhauser", "id": "c8aa0332-d0fd-428b-93ce-f14df73cb962", "title": "Wet Dreams"}, "length": "397666", "position": "6", "id": "00ab6a04-14d0-491f-9997-046339ee79fc", "track_or_recording_length": "397666"}, {"artist-credit": [{"artist": {"sort-name": "Audio Hijack", "id": "f4edc6b9-adea-436e-b855-f4463d34c77f", "name": "Audio Hijack"}}, " & ", {"artist": {"sort-name": "Painkiller", "disambiguation": "Psytrance artist based in Barcelona, Spain.", "id": "06391f11-b2a5-4168-8296-c0ed1b0fbe26", "name": "Painkiller"}}], "number": "7", "artist-credit-phrase": "Audio Hijack & Painkiller", "recording": {"artist-credit": [{"artist": {"sort-name": "Audio Hijack", "id": "f4edc6b9-adea-436e-b855-f4463d34c77f", "name": "Audio Hijack"}}, " & ", {"artist": {"sort-name": "Painkiller", "disambiguation": "Psytrance artist based in Barcelona, Spain.", "id": "06391f11-b2a5-4168-8296-c0ed1b0fbe26", "name": "Painkiller"}}], "length": "412000", "artist-credit-phrase": "Audio Hijack & Painkiller", "id": "707305b1-fdb2-48df-8fc4-85955cdab049", "title": "Flying Oscillator"}, "length": "412000", "position": "7", "id": "9604b6d8-ccf4-465e-9b90-f8f463542b1c", "track_or_recording_length": "412000"}, {"artist-credit": [{"artist": {"sort-name": "Members of Mayday", "id": "620efc10-77da-428f-9d78-2ebc75760f46", "name": "Members of Mayday"}}], "number": "8", "artist-credit-phrase": "Members of Mayday", "recording": {"artist-credit": [{"artist": {"sort-name": "Members of Mayday", "id": "620efc10-77da-428f-9d78-2ebc75760f46", "name": "Members of Mayday"}}], "length": "432333", "artist-credit-phrase": "Members of Mayday", "id": "89225fc3-c062-4fa9-a858-3eebe3b276e0", "title": "Sonic Empire (SynSUN remix)"}, "length": "432333", "position": "8", "id": "9472e2af-47e1-422c-8ebd-046154347f16", "track_or_recording_length": "432333"}, {"artist-credit": [{"artist": {"sort-name": "DNA", "disambiguation": "Psy-Trance artists A-tan Injection & Zeev Kardonsky", "id": "97113e01-3faf-495e-9140-0f5913aa32fb", "name": "DNA"}}], "number": "9", "artist-credit-phrase": "DNA", "recording": {"artist-credit": [{"artist": {"sort-name": "DNA", "disambiguation": "Psy-Trance artists A-tan Injection & Zeev Kardonsky", "id": "97113e01-3faf-495e-9140-0f5913aa32fb", "name": "DNA"}}], "length": "430546", "artist-credit-phrase": "DNA", "id": "ccd46826-4306-4795-8db1-2e500b8fdfd3", "title": "Signal 5"}, "length": "430546", "position": "9", "id": "39e389b4-e649-4222-857c-0fc471b8989c", "track_or_recording_length": "430546"}, {"artist-credit": [{"artist": {"sort-name": "Mekkanikka", "id": "41b8ca73-8460-4aaa-8dd8-5484c714dfdc", "name": "Mekkanikka"}}], "number": "10", "artist-credit-phrase": "Mekkanikka", "recording": {"artist-credit": [{"artist": {"sort-name": "Mekkanikka", "id": "41b8ca73-8460-4aaa-8dd8-5484c714dfdc", "name": "Mekkanikka"}}], "length": "429920", "artist-credit-phrase": "Mekkanikka", "id": "76290178-6b32-469f-945a-8ef28b3269f7", "title": "Hawain Snow"}, "length": "429920", "position": "10", "id": "07b79fd2-4da8-4331-946d-de08f50d1d9a", "track_or_recording_length": "429920"}], "disc-count": 1}], "text-representation": {"language": "eng", "script": "Latn"}, "label-info-count": 0, "country": "DE", "date": "2010", "artist-credit-phrase": "Various Artists", "quality": "normal", "id": "38b05c7d-65fe-4dc0-9c10-33a391b86703"}} \ No newline at end of file diff --git a/whipper/test/whipper.release.f484a9fc-db21-4106-9408-bcd105c90047.json b/whipper/test/whipper.release.f484a9fc-db21-4106-9408-bcd105c90047.json new file mode 100644 index 00000000..37709b37 --- /dev/null +++ b/whipper/test/whipper.release.f484a9fc-db21-4106-9408-bcd105c90047.json @@ -0,0 +1 @@ +{"release": {"status": "Official", "artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "barcode": "5050466625021", "asin": "B000095K86", "label-info-count": 1, "label-info-list": [{"catalog-number": "5050466-6250-2-1", "label": {"sort-name": "Warner Strategic Marketing (Germany)", "id": "29910c68-a655-4054-b933-da75d8f82bdf", "name": "Warner Strategic Marketing (Germany)"}}], "cover-art-archive": {"count": "2", "front": "true", "back": "true", "artwork": "true"}, "release-event-list": [{"date": "2003-05-19", "area": {"sort-name": "Germany", "iso-3166-1-code-list": ["DE"], "id": "85752fda-13c4-31a3-bee5-0e5cb1f51dad", "name": "Germany"}}], "packaging": "Slim Jewel Case", "text-representation": {"language": "deu", "script": "Latn"}, "date": "2003-05-19", "quality": "normal", "id": "f484a9fc-db21-4106-9408-bcd105c90047", "release-event-count": 1, "title": "Anyplace, Anywhere, Anytime", "country": "DE", "medium-count": 1, "artist-credit-phrase": "Nena & Kim Wilde", "medium-list": [{"position": "1", "track-count": 4, "format": "CD", "disc-list": [{"offset-list": [150, 17037, 35418, 53803], "id": "X2c2IQ5vUy5x6Jh7Xi_DGHtA1X8-", "sectors": "66872", "offset-count": 4}], "track-list": [{"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "number": "1", "artist-credit-phrase": "Nena & Kim Wilde", "recording": {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "length": "223480", "artist-credit-phrase": "Nena & Kim Wilde", "id": "fde5622c-ce23-4ebb-975d-51d4a926f901", "title": "Anyplace, Anywhere, Anytime (radio version)"}, "length": "225160", "position": "1", "id": "1cc96e78-28ed-3820-b0b6-614c35b121ac", "track_or_recording_length": "225160"}, {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "recording": {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " mit ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "length": "244000", "artist-credit-phrase": "Nena mit Kim Wilde", "id": "5f19758e-7421-4c71-a599-9a9575d8e1b0", "title": "Anyplace, Anywhere, Anytime (new version)"}, "length": "245080", "position": "2", "artist-credit-phrase": "Nena & Kim Wilde", "track_or_recording_length": "245080", "id": "f16db4bf-9a34-3d5a-a975-c9375ab7a2ca", "number": "2"}, {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "number": "3", "artist-credit-phrase": "Nena & Kim Wilde", "recording": {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "length": "245133", "artist-credit-phrase": "Nena & Kim Wilde", "id": "0620f76f-faa0-4931-95f8-aacb9cdbe469", "title": "Irgendwie, irgendwo, irgendwann (new version)"}, "length": "245133", "position": "3", "id": "ce2c4edd-6eab-36c8-8f84-e8c85f197a88", "track_or_recording_length": "245133"}, {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "number": "4", "artist-credit-phrase": "Nena & Kim Wilde", "recording": {"artist-credit": [{"artist": {"sort-name": "Nena", "disambiguation": "the person, performing solo since 1987", "id": "38bfaa7f-ee98-48cb-acd0-946d7aeecd76", "name": "Nena"}}, " & ", {"artist": {"sort-name": "Wilde, Kim", "id": "4b462375-c508-432a-8c88-ceeec38b16ae", "name": "Kim Wilde"}}], "length": "173627", "artist-credit-phrase": "Nena & Kim Wilde", "id": "1e266d6e-44c7-4fdb-a064-23167a4af473", "title": "Nur getr\u00e4umt (new version)"}, "length": "173627", "position": "4", "id": "6e178989-7d8e-3c33-9628-50bdda7c4483", "track_or_recording_length": "173627"}], "disc-count": 1}]}} \ No newline at end of file