commit
30d4cf9111
|
@ -3,7 +3,7 @@ pyLast
|
||||||
|
|
||||||
[](https://travis-ci.org/pylast/pylast)
|
[](https://travis-ci.org/pylast/pylast)
|
||||||
[](https://pypi.python.org/pypi/pylast/)
|
[](https://pypi.python.org/pypi/pylast/)
|
||||||
[](https://pypi.python.org/pypi/pylast/)
|
<!--[](https://pypi.python.org/pypi/pylast/)-->
|
||||||
[](https://codecov.io/gh/pylast/pylast)
|
[](https://codecov.io/gh/pylast/pylast)
|
||||||
[](https://coveralls.io/github/pylast/pylast?branch=develop)
|
[](https://coveralls.io/github/pylast/pylast?branch=develop)
|
||||||
[](https://landscape.io/github/hugovk/pylast/develop)
|
[](https://landscape.io/github/hugovk/pylast/develop)
|
||||||
|
|
|
@ -343,7 +343,7 @@ class _Network(object):
|
||||||
"""
|
"""
|
||||||
Returns a Scrobbler object used for submitting tracks to the server
|
Returns a Scrobbler object used for submitting tracks to the server
|
||||||
|
|
||||||
Quote from http://www.last.fm/api/submissions:
|
Quote from https://www.last.fm/api/submissions:
|
||||||
========
|
========
|
||||||
Client identifiers are used to provide a centrally managed database
|
Client identifiers are used to provide a centrally managed database
|
||||||
of the client versions, allowing clients to be banned if they are
|
of the client versions, allowing clients to be banned if they are
|
||||||
|
@ -382,7 +382,7 @@ class _Network(object):
|
||||||
return self.domain_names[domain_language]
|
return self.domain_names[domain_language]
|
||||||
|
|
||||||
def _get_url(self, domain, url_type):
|
def _get_url(self, domain, url_type):
|
||||||
return "http://%s/%s" % (
|
return "https://%s/%s" % (
|
||||||
self._get_language_domain(domain), self.urls[url_type])
|
self._get_language_domain(domain), self.urls[url_type])
|
||||||
|
|
||||||
def _get_ws_auth(self):
|
def _get_ws_auth(self):
|
||||||
|
@ -396,7 +396,7 @@ class _Network(object):
|
||||||
Makes sure that web service calls are at least 0.2 seconds apart.
|
Makes sure that web service calls are at least 0.2 seconds apart.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Delay time in seconds from section 4.4 of http://www.last.fm/api/tos
|
# Delay time in seconds from section 4.4 of https://www.last.fm/api/tos
|
||||||
DELAY_TIME = 0.2
|
DELAY_TIME = 0.2
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ class LastFMNetwork(_Network):
|
||||||
|
|
||||||
Most read-only webservices only require an api_key and an api_secret, see
|
Most read-only webservices only require an api_key and an api_secret, see
|
||||||
about obtaining them from:
|
about obtaining them from:
|
||||||
http://www.last.fm/api/account
|
https://www.last.fm/api/account
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -899,7 +899,7 @@ class LastFMNetwork(_Network):
|
||||||
_Network.__init__(
|
_Network.__init__(
|
||||||
self,
|
self,
|
||||||
name="Last.fm",
|
name="Last.fm",
|
||||||
homepage="http://last.fm",
|
homepage="https://www.last.fm",
|
||||||
ws_server=("ws.audioscrobbler.com", "/2.0/"),
|
ws_server=("ws.audioscrobbler.com", "/2.0/"),
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
api_secret=api_secret,
|
api_secret=api_secret,
|
||||||
|
@ -910,17 +910,17 @@ class LastFMNetwork(_Network):
|
||||||
token=token,
|
token=token,
|
||||||
domain_names={
|
domain_names={
|
||||||
DOMAIN_ENGLISH: 'www.last.fm',
|
DOMAIN_ENGLISH: 'www.last.fm',
|
||||||
DOMAIN_GERMAN: 'www.lastfm.de',
|
DOMAIN_GERMAN: 'www.last.fm/de',
|
||||||
DOMAIN_SPANISH: 'www.lastfm.es',
|
DOMAIN_SPANISH: 'www.last.fm/es',
|
||||||
DOMAIN_FRENCH: 'www.lastfm.fr',
|
DOMAIN_FRENCH: 'www.last.fm/fr',
|
||||||
DOMAIN_ITALIAN: 'www.lastfm.it',
|
DOMAIN_ITALIAN: 'www.last.fm/it',
|
||||||
DOMAIN_POLISH: 'www.lastfm.pl',
|
DOMAIN_POLISH: 'www.last.fm/pl',
|
||||||
DOMAIN_PORTUGUESE: 'www.lastfm.com.br',
|
DOMAIN_PORTUGUESE: 'www.last.fm/pt',
|
||||||
DOMAIN_SWEDISH: 'www.lastfm.se',
|
DOMAIN_SWEDISH: 'www.last.fm/sv',
|
||||||
DOMAIN_TURKISH: 'www.lastfm.com.tr',
|
DOMAIN_TURKISH: 'www.last.fm/tr',
|
||||||
DOMAIN_RUSSIAN: 'www.lastfm.ru',
|
DOMAIN_RUSSIAN: 'www.last.fm/ru',
|
||||||
DOMAIN_JAPANESE: 'www.lastfm.jp',
|
DOMAIN_JAPANESE: 'www.last.fm/ja',
|
||||||
DOMAIN_CHINESE: 'cn.last.fm',
|
DOMAIN_CHINESE: 'www.last.fm/zh',
|
||||||
},
|
},
|
||||||
urls={
|
urls={
|
||||||
"album": "music/%(artist)s/%(album)s",
|
"album": "music/%(artist)s/%(album)s",
|
||||||
|
@ -966,7 +966,7 @@ def get_lastfm_network(
|
||||||
|
|
||||||
Most read-only webservices only require an api_key and an api_secret, see
|
Most read-only webservices only require an api_key and an api_secret, see
|
||||||
about obtaining them from:
|
about obtaining them from:
|
||||||
http://www.last.fm/api/account
|
https://www.last.fm/api/account
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_deprecation_warning("Create a LastFMNetwork object instead")
|
_deprecation_warning("Create a LastFMNetwork object instead")
|
||||||
|
@ -997,7 +997,7 @@ class LibreFMNetwork(_Network):
|
||||||
_Network.__init__(
|
_Network.__init__(
|
||||||
self,
|
self,
|
||||||
name="Libre.fm",
|
name="Libre.fm",
|
||||||
homepage="http://libre.fm",
|
homepage="https://libre.fm",
|
||||||
ws_server=("libre.fm", "/2.0/"),
|
ws_server=("libre.fm", "/2.0/"),
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
api_secret=api_secret,
|
api_secret=api_secret,
|
||||||
|
|
|
@ -77,7 +77,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_scrobble(self):
|
def test_scrobble(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
timestamp = self.unix_timestamp()
|
timestamp = self.unix_timestamp()
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_love(self):
|
def test_love(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
track = self.network.get_track(artist, title)
|
track = self.network.get_track(artist, title)
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
|
||||||
|
@ -268,13 +268,13 @@ class TestPyLast(unittest.TestCase):
|
||||||
# Assert
|
# Assert
|
||||||
loved = lastfm_user.get_loved_tracks(limit=1)
|
loved = lastfm_user.get_loved_tracks(limit=1)
|
||||||
self.assertEqual(str(loved[0].track.artist), "Test Artist")
|
self.assertEqual(str(loved[0].track.artist), "Test Artist")
|
||||||
self.assertEqual(str(loved[0].track.title), "Test Title")
|
self.assertEqual(str(loved[0].track.title), "test title")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_unlove(self):
|
def test_unlove(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = pylast.Artist("Test Artist", self.network)
|
artist = pylast.Artist("Test Artist", self.network)
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
track = pylast.Track(artist, title, self.network)
|
track = pylast.Track(artist, title, self.network)
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
track.love()
|
track.love()
|
||||||
|
@ -286,7 +286,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
loved = lastfm_user.get_loved_tracks(limit=1)
|
loved = lastfm_user.get_loved_tracks(limit=1)
|
||||||
if len(loved): # OK to be empty but if not:
|
if len(loved): # OK to be empty but if not:
|
||||||
self.assertNotEqual(str(loved.track.artist), "Test Artist")
|
self.assertNotEqual(str(loved.track.artist), "Test Artist")
|
||||||
self.assertNotEqual(str(loved.track.title), "Test Title")
|
self.assertNotEqual(str(loved.track.title), "test title")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_get_100_albums(self):
|
def test_get_100_albums(self):
|
||||||
|
@ -360,7 +360,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_update_now_playing(self):
|
def test_update_now_playing(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
album = "Test Album"
|
album = "Test Album"
|
||||||
track_number = 1
|
track_number = 1
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
@ -372,7 +372,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
# Assert
|
# Assert
|
||||||
current_track = lastfm_user.get_now_playing()
|
current_track = lastfm_user.get_now_playing()
|
||||||
self.assertIsNotNone(current_track)
|
self.assertIsNotNone(current_track)
|
||||||
self.assertEqual(str(current_track.title), "Test Title")
|
self.assertEqual(str(current_track.title), "test title")
|
||||||
self.assertEqual(str(current_track.artist), "Test Artist")
|
self.assertEqual(str(current_track.artist), "Test Artist")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
|
@ -531,7 +531,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_user_play_count_in_track_info(self):
|
def test_user_play_count_in_track_info(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
track = pylast.Track(
|
track = pylast.Track(
|
||||||
artist=artist, title=title,
|
artist=artist, title=title,
|
||||||
network=self.network, username=self.username)
|
network=self.network, username=self.username)
|
||||||
|
@ -546,7 +546,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_user_loved_in_track_info(self):
|
def test_user_loved_in_track_info(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
title = "Test Title"
|
title = "test title"
|
||||||
track = pylast.Track(
|
track = pylast.Track(
|
||||||
artist=artist, title=title,
|
artist=artist, title=title,
|
||||||
network=self.network, username=self.username)
|
network=self.network, username=self.username)
|
||||||
|
@ -796,7 +796,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_wiki_content(self):
|
def test_track_wiki_content(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track = pylast.Track("Test Artist", "Test Title", self.network)
|
track = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
wiki = track.get_wiki_content()
|
wiki = track.get_wiki_content()
|
||||||
|
@ -808,7 +808,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_wiki_summary(self):
|
def test_track_wiki_summary(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track = pylast.Track("Test Artist", "Test Title", self.network)
|
track = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
wiki = track.get_wiki_summary()
|
wiki = track.get_wiki_summary()
|
||||||
|
@ -1449,12 +1449,12 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertIsInstance(playcount, int)
|
self.assertIsInstance(playcount, int)
|
||||||
self.assertGreater(playcount, 1)
|
self.assertGreater(playcount, 1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"http://www.last.fm/music/test%2bartist/test%2balbum", url)
|
"https://www.last.fm/music/test%2bartist/test%2balbum", url)
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_data(self):
|
def test_track_data(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
thing = self.network.get_track("Test Artist", "Test Title")
|
thing = self.network.get_track("Test Artist", "test title")
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
stringed = str(thing)
|
stringed = str(thing)
|
||||||
|
@ -1465,14 +1465,14 @@ class TestPyLast(unittest.TestCase):
|
||||||
url = thing.get_url(pylast.DOMAIN_FRENCH)
|
url = thing.get_url(pylast.DOMAIN_FRENCH)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(stringed, "Test Artist - Test Title")
|
self.assertEqual(stringed, "Test Artist - test title")
|
||||||
self.assertIn("pylast.Track('Test Artist', 'Test Title',", repr)
|
self.assertIn("pylast.Track('Test Artist', 'test title',", repr)
|
||||||
self.assertEqual(title, "Test Title")
|
self.assertEqual(title, "test title")
|
||||||
self.assertEqual(title, name)
|
self.assertEqual(title, name)
|
||||||
self.assertIsInstance(playcount, int)
|
self.assertIsInstance(playcount, int)
|
||||||
self.assertGreater(playcount, 1)
|
self.assertGreater(playcount, 1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"http://www.lastfm.fr/music/test%2bartist/_/test%2btitle", url)
|
"https://www.last.fm/fr/music/test%2bartist/_/test%2btitle", url)
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_tag_top_artists(self):
|
def test_tag_top_artists(self):
|
||||||
|
@ -1562,7 +1562,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
# Arrange
|
# Arrange
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
tags = ["tracktagola"]
|
tags = ["tracktagola"]
|
||||||
track = self.network.get_track("Test Artist", "Test Title")
|
track = self.network.get_track("Test Artist", "test title")
|
||||||
track.add_tags(tags)
|
track.add_tags(tags)
|
||||||
# Act
|
# Act
|
||||||
tracks = lastfm_user.get_tagged_tracks('tracktagola', limit=1)
|
tracks = lastfm_user.get_tagged_tracks('tracktagola', limit=1)
|
||||||
|
@ -1625,7 +1625,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
playlist = pylast.Playlist(user, id, self.network)
|
playlist = pylast.Playlist(user, id, self.network)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
playlist.get_url(),
|
playlist.get_url(),
|
||||||
"http://www.last.fm/user/kaxior/library/"
|
"https://www.last.fm/user/kaxior/library/"
|
||||||
"playlists/67ajb_top_100_classick_rock_songs")
|
"playlists/67ajb_top_100_classick_rock_songs")
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
@ -1643,7 +1643,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
title = "One track playlist"
|
title = "One track playlist"
|
||||||
description = "Testing"
|
description = "Testing"
|
||||||
playlist = self.network.create_new_playlist(title, description)
|
playlist = self.network.create_new_playlist(title, description)
|
||||||
track = pylast.Track("Test Artist", "Test Title", self.network)
|
track = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
playlist.add_track(track)
|
playlist.add_track(track)
|
||||||
|
@ -1827,7 +1827,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_tracks_notequal(self):
|
def test_tracks_notequal(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track1 = pylast.Track("Test Artist", "Test Title", self.network)
|
track1 = pylast.Track("Test Artist", "test title", self.network)
|
||||||
track2 = pylast.Track("Test Artist", "Test Track", self.network)
|
track2 = pylast.Track("Test Artist", "Test Track", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
@ -1837,7 +1837,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_id(self):
|
def test_track_id(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track = pylast.Track("Test Artist", "Test Title", self.network)
|
track = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
id = track.get_id()
|
id = track.get_id()
|
||||||
|
@ -1855,7 +1855,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
title = track.get_title(properly_capitalized=True)
|
title = track.get_title(properly_capitalized=True)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(title, "Test Title")
|
self.assertEqual(title, "test title")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_listener_count(self):
|
def test_track_listener_count(self):
|
||||||
|
@ -1912,7 +1912,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertEqual("blues", name)
|
self.assertEqual("blues", name)
|
||||||
self.assertTrue(tag1 == tag1)
|
self.assertTrue(tag1 == tag1)
|
||||||
self.assertTrue(tag1 != tag2)
|
self.assertTrue(tag1 != tag2)
|
||||||
self.assertEqual(url, "http://www.last.fm/tag/blues")
|
self.assertEqual(url, "https://www.last.fm/tag/blues")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_tags_similar(self):
|
def test_tags_similar(self):
|
||||||
|
@ -1951,7 +1951,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertGreater(playcount, 1)
|
self.assertGreater(playcount, 1)
|
||||||
self.assertTrue(artist1 != artist2)
|
self.assertTrue(artist1 != artist2)
|
||||||
self.assertEqual(name.lower(), name_cap.lower())
|
self.assertEqual(name.lower(), name_cap.lower())
|
||||||
self.assertEqual(url, "http://www.last.fm/music/radiohead")
|
self.assertEqual(url, "https://www.last.fm/music/radiohead")
|
||||||
self.assertEqual(mbid, "a74b1b7f-71a5-4011-9441-d0b5e4122711")
|
self.assertEqual(mbid, "a74b1b7f-71a5-4011-9441-d0b5e4122711")
|
||||||
self.assertIsInstance(streamable, bool)
|
self.assertIsInstance(streamable, bool)
|
||||||
|
|
||||||
|
@ -2007,13 +2007,13 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertEqual(text, "Italy")
|
self.assertEqual(text, "Italy")
|
||||||
self.assertTrue(country1 == country1)
|
self.assertTrue(country1 == country1)
|
||||||
self.assertTrue(country1 != country2)
|
self.assertTrue(country1 != country2)
|
||||||
self.assertEqual(url, "http://www.last.fm/place/italy")
|
self.assertEqual(url, "https://www.last.fm/place/italy")
|
||||||
|
|
||||||
@handle_lastfm_exceptions
|
@handle_lastfm_exceptions
|
||||||
def test_track_eq_none_is_false(self):
|
def test_track_eq_none_is_false(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track1 = None
|
track1 = None
|
||||||
track2 = pylast.Track("Test Artist", "Test Title", self.network)
|
track2 = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
self.assertFalse(track1 == track2)
|
self.assertFalse(track1 == track2)
|
||||||
|
@ -2022,7 +2022,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
def test_track_ne_none_is_true(self):
|
def test_track_ne_none_is_true(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
track1 = None
|
track1 = None
|
||||||
track2 = pylast.Track("Test Artist", "Test Title", self.network)
|
track2 = pylast.Track("Test Artist", "test title", self.network)
|
||||||
|
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
self.assertTrue(track1 != track2)
|
self.assertTrue(track1 != track2)
|
||||||
|
|
Loading…
Reference in a new issue