Compare commits
3 commits
main
...
fix-mbid-t
Author | SHA1 | Date | |
---|---|---|---|
|
69cc18bcbd | ||
|
8d784d6417 | ||
|
58fa3094d8 |
|
@ -1592,7 +1592,12 @@ class _Opus(_BaseObject, _Taggable):
|
||||||
def get_mbid(self):
|
def get_mbid(self):
|
||||||
"""Returns the MusicBrainz ID of the album or track."""
|
"""Returns the MusicBrainz ID of the album or track."""
|
||||||
|
|
||||||
doc = self._request(self.ws_prefix + ".getInfo", cacheable=True)
|
try:
|
||||||
|
doc = self._request(self.ws_prefix + ".getInfo", cacheable=True)
|
||||||
|
except WSError as e:
|
||||||
|
if int(e.get_id()) == STATUS_INVALID_PARAMS and str(e) == "Track not found":
|
||||||
|
return None
|
||||||
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lfm = doc.getElementsByTagName("lfm")[0]
|
lfm = doc.getElementsByTagName("lfm")[0]
|
||||||
|
|
|
@ -241,9 +241,16 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
assert corrected_track_name == "Mr. Brownstone"
|
assert corrected_track_name == "Mr. Brownstone"
|
||||||
|
|
||||||
def test_track_with_no_mbid(self):
|
@pytest.mark.parametrize(
|
||||||
|
("test_artist", "test_track"),
|
||||||
|
[
|
||||||
|
("Static-X", "Set It Off"), # Track with no MBID
|
||||||
|
("Zytaris", "Shores of Life"), # "Track not found"
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_track_with_no_mbid(self, test_artist, test_track):
|
||||||
# Arrange
|
# Arrange
|
||||||
track = pylast.Track("Static-X", "Set It Off", self.network)
|
track = pylast.Track(test_track, test_artist, self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
mbid = track.get_mbid()
|
mbid = track.get_mbid()
|
||||||
|
|
Loading…
Reference in a new issue