Skip to content

Commit

Permalink
Fix bug with detecting track lengths under strange MusicBrainz alt at…
Browse files Browse the repository at this point in the history
…tribute name.
  • Loading branch information
sheriferson committed Feb 7, 2024
1 parent 5d150c7 commit fcf492b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/scrobble/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/test__cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down

0 comments on commit fcf492b

Please sign in to comment.