diff --git a/src/scrobble/musicbrainz.py b/src/scrobble/musicbrainz.py index 14f49bf..2859bec 100644 --- a/src/scrobble/musicbrainz.py +++ b/src/scrobble/musicbrainz.py @@ -32,7 +32,10 @@ def parse_musicbrainz_result(cls, result: dict, disc_no: Optional[int] = 1): """ track_position: int = int(result['position']) title: str = result['recording']['title'] - length: int = int(result['length']) / 1000 + if 'length' in result: + length: int = int(result['length']) / 1000 + elif 'track_or_recording_length' in result: + length: int = int(result['track_or_recording_length']) / 1000 return Track(title, disc_no, track_position, length) diff --git a/tests/test_barcode_scanner.py b/tests/test__barcode_scanner.py similarity index 100% rename from tests/test_barcode_scanner.py rename to tests/test__barcode_scanner.py diff --git a/tests/test__cd.py b/tests/test__cd.py index 7954a98..4e549ae 100644 --- a/tests/test__cd.py +++ b/tests/test__cd.py @@ -25,6 +25,12 @@ def test_cd_track_length(): assert len(TEST_CD) == 14 +def test_cd_track_length_alt_attribute_name(): + alt_test_cd: CD = CD.find_cd(4988005346872, choice=False) + assert len(alt_test_cd) == 15 + assert alt_test_cd.tracks[0].track_length > 0 + + def test_cd_string_representation(): assert str(TEST_CD) == "💿 Lacuna Coil - Comalies (2002)"