Merge pull request #135 from dinorox/develop
Support for artist.getCorrection and track.getCorrection
This commit is contained in:
commit
3e434f3714
|
@ -1928,6 +1928,12 @@ class Artist(_BaseObject, _Taggable):
|
|||
|
||||
return self.name
|
||||
|
||||
def get_correction(self):
|
||||
"""Returns the corrected artist name."""
|
||||
|
||||
return _extract(
|
||||
self._request(self.ws_prefix + ".getCorrection"), "name")
|
||||
|
||||
def get_cover_image(self, size=COVER_MEGA):
|
||||
"""
|
||||
Returns a uri to the cover image
|
||||
|
@ -2947,6 +2953,12 @@ class Track(_Opus):
|
|||
def __init__(self, artist, title, network, username=None):
|
||||
super(Track, self).__init__(artist, title, network, "track", username)
|
||||
|
||||
def get_correction(self):
|
||||
"""Returns the corrected track name."""
|
||||
|
||||
return _extract(
|
||||
self._request(self.ws_prefix + ".getCorrection"), "name")
|
||||
|
||||
def get_duration(self):
|
||||
"""Returns the track duration."""
|
||||
|
||||
|
|
|
@ -1908,6 +1908,25 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertEqual(str(tracks[0].track.artist), "Johnny Cash")
|
||||
self.assertEqual(str(tracks[0].track.title), "Ring of Fire")
|
||||
|
||||
def test_artist_get_correction(self):
|
||||
# Arrange
|
||||
artist = pylast.Artist("guns and roses", self.network)
|
||||
|
||||
# Act
|
||||
corrected_artist_name = artist.get_correction()
|
||||
|
||||
# Assert
|
||||
self.assertEqual(corrected_artist_name, "Guns N' Roses")
|
||||
|
||||
def test_track_get_correction(self):
|
||||
# Arrange
|
||||
track = pylast.Track("Guns N' Roses", "mrbrownstone", self.network)
|
||||
|
||||
# Act
|
||||
corrected_track_name = track.get_correction()
|
||||
|
||||
# Assert
|
||||
self.assertEqual(corrected_track_name, "Mr. Brownstone")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(failfast=True)
|
||||
|
|
Loading…
Reference in a new issue