Merge pull request #384 from pylast/deprecate-streamable
This commit is contained in:
commit
dd869b5183
|
@ -2,3 +2,5 @@
|
||||||
filterwarnings =
|
filterwarnings =
|
||||||
once::DeprecationWarning
|
once::DeprecationWarning
|
||||||
once::PendingDeprecationWarning
|
once::PendingDeprecationWarning
|
||||||
|
|
||||||
|
xfail_strict=true
|
||||||
|
|
|
@ -29,6 +29,7 @@ import shelve
|
||||||
import ssl
|
import ssl
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import warnings
|
||||||
import xml.dom
|
import xml.dom
|
||||||
from http.client import HTTPSConnection
|
from http.client import HTTPSConnection
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
@ -1783,13 +1784,18 @@ class Artist(_Taggable):
|
||||||
return self.listener_count
|
return self.listener_count
|
||||||
|
|
||||||
def is_streamable(self):
|
def is_streamable(self):
|
||||||
"""Returns True if the artist is streamable."""
|
"""Returns True if the artist is streamable: always False because Last.fm has
|
||||||
|
deprecated the Radio API."""
|
||||||
return bool(
|
warnings.warn(
|
||||||
_number(
|
"Always returns False. Last.fm has deprecated the Radio API and will "
|
||||||
_extract(self._request(self.ws_prefix + ".getInfo", True), "streamable")
|
"it at some point. is_streamable() will be removed in pylast 5.0.0. "
|
||||||
)
|
"See https://www.last.fm/api/radio and "
|
||||||
|
"https://support.last.fm/t/"
|
||||||
|
"is-the-streamable-attribute-broken-it-always-returns-0/39723/3",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def get_bio(self, section, language=None):
|
def get_bio(self, section, language=None):
|
||||||
"""
|
"""
|
||||||
|
@ -2130,18 +2136,32 @@ class Track(_Opus):
|
||||||
return bool(loved)
|
return bool(loved)
|
||||||
|
|
||||||
def is_streamable(self):
|
def is_streamable(self):
|
||||||
"""Returns True if the track is available at Last.fm."""
|
"""Returns True if the artist is streamable: always False because Last.fm has
|
||||||
|
deprecated the Radio API."""
|
||||||
doc = self._request(self.ws_prefix + ".getInfo", True)
|
warnings.warn(
|
||||||
return _extract(doc, "streamable") == "1"
|
"Always returns False. Last.fm has deprecated the Radio API and will "
|
||||||
|
"it at some point. is_streamable() will be removed in pylast 5.0.0. "
|
||||||
|
"See https://www.last.fm/api/radio and "
|
||||||
|
"https://support.last.fm/t/"
|
||||||
|
"is-the-streamable-attribute-broken-it-always-returns-0/39723/3",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def is_fulltrack_available(self):
|
def is_fulltrack_available(self):
|
||||||
"""Returns True if the full track is available for streaming."""
|
"""Returns True if the full track is available for streaming: always False
|
||||||
|
because Last.fm has deprecated the Radio API."""
|
||||||
doc = self._request(self.ws_prefix + ".getInfo", True)
|
warnings.warn(
|
||||||
return (
|
"Always returns False. Last.fm has deprecated the Radio API and will "
|
||||||
doc.getElementsByTagName("streamable")[0].getAttribute("fulltrack") == "1"
|
"remove it at some point. is_fulltrack_available() will be removed in "
|
||||||
|
"pylast 5.0.0. See https://www.last.fm/api/radio and "
|
||||||
|
"https://support.last.fm/t/"
|
||||||
|
"is-the-streamable-attribute-broken-it-always-returns-0/39723/3",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def get_album(self):
|
def get_album(self):
|
||||||
"""Returns the album object of this track."""
|
"""Returns the album object of this track."""
|
||||||
|
|
|
@ -229,6 +229,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
mbid = artist1.get_mbid()
|
mbid = artist1.get_mbid()
|
||||||
|
|
||||||
playcount = artist1.get_playcount()
|
playcount = artist1.get_playcount()
|
||||||
|
with pytest.warns(DeprecationWarning):
|
||||||
streamable = artist1.is_streamable()
|
streamable = artist1.is_streamable()
|
||||||
name = artist1.get_name(properly_capitalized=False)
|
name = artist1.get_name(properly_capitalized=False)
|
||||||
name_cap = artist1.get_name(properly_capitalized=True)
|
name_cap = artist1.get_name(properly_capitalized=True)
|
||||||
|
@ -267,7 +268,6 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
assert corrected_artist_name == "Guns N' Roses"
|
assert corrected_artist_name == "Guns N' Roses"
|
||||||
|
|
||||||
@pytest.mark.xfail
|
|
||||||
def test_get_userplaycount(self):
|
def test_get_userplaycount(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = pylast.Artist("John Lennon", self.network, username=self.username)
|
artist = pylast.Artist("John Lennon", self.network, username=self.username)
|
||||||
|
@ -276,4 +276,4 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
playcount = artist.get_userplaycount()
|
playcount = artist.get_userplaycount()
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert playcount >= 0 # whilst xfail: # pragma: no cover
|
assert playcount >= 0
|
||||||
|
|
|
@ -267,8 +267,6 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
||||||
assert isinstance(artist, pylast.Artist)
|
assert isinstance(artist, pylast.Artist)
|
||||||
assert artist.name in ("MusicBrainz Test Artist", "MusicBrainzz Test Artist")
|
assert artist.name in ("MusicBrainz Test Artist", "MusicBrainzz Test Artist")
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="Broken at Last.fm: Track not found")
|
|
||||||
# https://support.last.fm/t/track-getinfo-with-mbid-returns-6-track-not-found/47905
|
|
||||||
def test_track_mbid(self):
|
def test_track_mbid(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
mbid = "ebc037b1-cc9c-44f2-a21f-83c219f0e1e0"
|
mbid = "ebc037b1-cc9c-44f2-a21f-83c219f0e1e0"
|
||||||
|
|
|
@ -123,6 +123,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
||||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
with pytest.warns(DeprecationWarning):
|
||||||
streamable = track.is_streamable()
|
streamable = track.is_streamable()
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
|
@ -133,6 +134,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
||||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
with pytest.warns(DeprecationWarning):
|
||||||
fulltrack_available = track.is_fulltrack_available()
|
fulltrack_available = track.is_fulltrack_available()
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
|
|
Loading…
Reference in a new issue