Skip to content

Commit

Permalink
Enable whipper to use track title (whipper-team#430)
Browse files Browse the repository at this point in the history
* Enable whipper to use track title if possible

track.title = t.get('title', t['recording']['title']).

Since if a track itself doesn't have a title then the track
title is the same with the recording title. Otherwise, a track
has its own title then t['title'] is different from
t['recording']['title'] and whipper chooses t['title'].

[Fixes whipper-team#192]
Signed-off-by: ABCbum <[email protected]>

* Add test case to check for track title

Using an existing JSON release file

Signed-off-by: ABCbum <[email protected]>
  • Loading branch information
ABCbum authored and JoeLametta committed Dec 13, 2019
1 parent 6e3e21f commit 31d589b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion whipper/common/mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _getMetadata(release, discid, country=None):
track.sortName = trackCredit.getSortName()
track.mbidArtist = trackCredit.getIds()

track.title = t['recording']['title']
track.title = t.get('title', t['recording']['title'])
track.mbid = t['id']
track.mbidRecording = t['recording']['id']
track.mbidWorks = _getWorks(t['recording'])
Expand Down
18 changes: 18 additions & 0 deletions whipper/test/test_common_mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ def testMissingReleaseDate(self):

self.assertFalse(metadata.release)

def testTrackTitle(self):
"""
Check that the track title metadata is taken from MusicBrainz's track
title (which may differ from the recording title, as in this case)
see https://github.com/whipper-team/whipper/issues/192
"""
# Using: The KLF - Space & Chill Out
# https://musicbrainz.org/release/c56ff16e-1d81-47de-926f-ba22891bd2bd
filename = 'whipper.release.c56ff16e-1d81-47de-926f-ba22891bd2bd.json'
path = os.path.join(os.path.dirname(__file__), filename)
with open(path, "rb") as handle:
response = json.loads(handle.read().decode('utf-8'))
discid = "b.yqPuCBdsV5hrzDvYrw52iK_jE-"

metadata = mbngs._getMetadata(response['release'], discid)
track1 = metadata.tracks[0]
self.assertEqual(track1.title, 'Brownsville Turnaround')

def test2MeterSessies10(self):
# various artists, multiple artists per track
filename = 'whipper.release.a76714e0-32b1-4ed4-b28e-f86d99642193.json'
Expand Down

0 comments on commit 31d589b

Please sign in to comment.