From 60c3b671bf618c82877294568d6c3d40a9326433 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 19 Oct 2017 23:58:20 +0300 Subject: [PATCH 1/9] Be a good citizen https://snarky.ca/how-to-use-your-project-travis-to-help-test-python-itself/ --- .travis.yml | 2 ++ tox.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e10837f..39948ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,8 @@ matrix: env: TOXENV=pypy3 - python: pypy env: TOXENV=pypy + - python: 3.6-dev + env: TOXENV=py36dev allow_failures: - env: TOXENV=pypy - env: TOXENV=pypy3 diff --git a/tox.ini b/tox.ini index 33c73be..81ff0e1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py36, py35, py34, pypy, pypy3 +envlist = py27, py36, py35, py34, pypy, pypy3, py36dev recreate = False [testenv] From 0d98c3590f2448225b35bf44e5baca24e7ef319d Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Thu, 2 Nov 2017 01:09:46 +0100 Subject: [PATCH 2/9] Added parameter to retrieve higher resolution user avatars --- pylast/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 40b9f07..d02d5bc 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -2409,12 +2409,19 @@ class User(_BaseObject, _Chartable): return self._get_things( "getTopTracks", "track", Track, params, cacheable) - def get_image(self): - """Returns the user's avatar.""" + def get_image(self, size=COVER_EXTRA_LARGE): + """ + Returns the user's avatar + size can be one of: + COVER_EXTRA_LARGE + COVER_LARGE + COVER_MEDIUM + COVER_SMALL + """ doc = self._request(self.ws_prefix + ".getInfo", True) - return _extract(doc, "image") + return _extract_all(doc, "image")[size] def get_url(self, domain_name=DOMAIN_ENGLISH): """Returns the url of the user page on the network. From 35f67a09cb9ec0cd581e4642789130f6f3eabe90 Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Thu, 2 Nov 2017 16:31:41 +0100 Subject: [PATCH 3/9] Replaced deprecated COVER_ constants with SIZE_ --- pylast/__init__.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index d02d5bc..8602734 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -86,11 +86,11 @@ DOMAIN_RUSSIAN = 9 DOMAIN_JAPANESE = 10 DOMAIN_CHINESE = 11 -COVER_SMALL = 0 -COVER_MEDIUM = 1 -COVER_LARGE = 2 -COVER_EXTRA_LARGE = 3 -COVER_MEGA = 4 +SIZE_SMALL = COVER_SMALL = 0 +SIZE_MEDIUM = COVER_MEDIUM = 1 +SIZE_LARGE = COVER_LARGE = 2 +SIZE_EXTRA_LARGE = COVER_EXTRA_LARGE = 3 +SIZE_MEGA = COVER_MEGA = 4 IMAGES_ORDER_POPULARITY = "popularity" IMAGES_ORDER_DATE = "dateadded" @@ -1468,14 +1468,14 @@ class Album(_Opus): def __init__(self, artist, title, network, username=None): super(Album, self).__init__(artist, title, network, "album", username) - def get_cover_image(self, size=COVER_EXTRA_LARGE): + def get_cover_image(self, size=SIZE_EXTRA_LARGE): """ Returns a uri to the cover image size can be one of: - COVER_EXTRA_LARGE - COVER_LARGE - COVER_MEDIUM - COVER_SMALL + SIZE_EXTRA_LARGE + SIZE_LARGE + SIZE_MEDIUM + SIZE_SMALL """ return _extract_all( @@ -1575,15 +1575,15 @@ class Artist(_BaseObject, _Taggable): return _extract( self._request(self.ws_prefix + ".getCorrection"), "name") - def get_cover_image(self, size=COVER_MEGA): + def get_cover_image(self, size=SIZE_MEGA): """ Returns a uri to the cover image size can be one of: - COVER_MEGA - COVER_EXTRA_LARGE - COVER_LARGE - COVER_MEDIUM - COVER_SMALL + SIZE_MEGA + SIZE_EXTRA_LARGE + SIZE_LARGE + SIZE_MEDIUM + SIZE_SMALL """ return _extract_all( @@ -2409,14 +2409,14 @@ class User(_BaseObject, _Chartable): return self._get_things( "getTopTracks", "track", Track, params, cacheable) - def get_image(self, size=COVER_EXTRA_LARGE): + def get_image(self, size=SIZE_EXTRA_LARGE): """ Returns the user's avatar size can be one of: - COVER_EXTRA_LARGE - COVER_LARGE - COVER_MEDIUM - COVER_SMALL + SIZE_EXTRA_LARGE + SIZE_LARGE + SIZE_MEDIUM + SIZE_SMALL """ doc = self._request(self.ws_prefix + ".getInfo", True) From 18708393af15ec3412c91c83ac5bcdca8f6342f5 Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Thu, 2 Nov 2017 17:04:24 +0100 Subject: [PATCH 4/9] Added depreciation comment, harmonized image sizes --- pylast/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 8602734..fc49fbc 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -86,6 +86,7 @@ DOMAIN_RUSSIAN = 9 DOMAIN_JAPANESE = 10 DOMAIN_CHINESE = 11 +# COVER_X is deprecated since 2.1.0 and will be removed in a future version SIZE_SMALL = COVER_SMALL = 0 SIZE_MEDIUM = COVER_MEDIUM = 1 SIZE_LARGE = COVER_LARGE = 2 @@ -1575,7 +1576,7 @@ class Artist(_BaseObject, _Taggable): return _extract( self._request(self.ws_prefix + ".getCorrection"), "name") - def get_cover_image(self, size=SIZE_MEGA): + def get_cover_image(self, size=SIZE_EXTRA_LARGE): """ Returns a uri to the cover image size can be one of: From 128afc78623024c8691622a707e28a64fac80579 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 2 Nov 2017 19:03:42 +0200 Subject: [PATCH 5/9] How to install latest development version [CI skip] --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 53b5d12..da7f7a8 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,14 @@ Installation Install via pip: pip install pylast + +Install latest development version: + + pip install -U git+https://github.com/pylast/pylast.git + +Or from requirements.txt: + + -e git://github.com/pylast/pylast.git#egg=pylast Note: From 36ed30cc2bad5c244c72f3f6391dbde0289c9d7a Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Thu, 2 Nov 2017 18:41:15 +0100 Subject: [PATCH 6/9] Return unix timestamp as int --- pylast/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index fc49fbc..de89377 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -2288,8 +2288,8 @@ class User(_BaseObject, _Chartable): doc = self._request(self.ws_prefix + ".getInfo", True) - return doc.getElementsByTagName( - "registered")[0].getAttribute("unixtime") + return int(doc.getElementsByTagName( + "registered")[0].getAttribute("unixtime")) def get_tagged_albums(self, tag, limit=None, cacheable=True): """Returns the albums tagged by a user.""" From 8f515d87795bf2c2c8399ee5dbbc37b696eebf93 Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Thu, 2 Nov 2017 19:24:45 +0100 Subject: [PATCH 7/9] Fixed test in accordance to 36ed30cc2bad5c244c72f3f6391dbde0289c9d7a --- tests/test_pylast_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pylast_user.py b/tests/test_pylast_user.py index 1169f41..40be3b8 100755 --- a/tests/test_pylast_user.py +++ b/tests/test_pylast_user.py @@ -87,7 +87,7 @@ class TestPyLastUser(PyLastTestCase): # Assert # Just check date because of timezones - self.assertEqual(unixtime_registered, u"1037793040") + self.assertEqual(unixtime_registered, 1037793040) def test_get_countryless_user(self): # Arrange From 762167345273039b2028a09e3dc5fd5faf2fd095 Mon Sep 17 00:00:00 2001 From: hugovk Date: Wed, 15 Nov 2017 15:10:31 +0200 Subject: [PATCH 8/9] Require Python 2.7 or 3.4+ --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 2a6ae2a..99fa123 100755 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ setup( "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ], + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', keywords=["Last.fm", "music", "scrobble", "scrobbling"], packages=find_packages(exclude=('tests*',)), license="Apache2" From 9da36d15d7ea5d93a14985a4fe4b33e99687bceb Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 8 Dec 2017 20:48:15 +0200 Subject: [PATCH 9/9] Fix case-sensitive tests --- tests/test_pylast_network.py | 10 +++++----- tests/test_pylast_track.py | 4 ++-- tests/test_pylast_user.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_pylast_network.py b/tests/test_pylast_network.py index 23d2f20..f3d8cb8 100755 --- a/tests/test_pylast_network.py +++ b/tests/test_pylast_network.py @@ -14,7 +14,7 @@ class TestPyLastNetwork(PyLastTestCase): def test_scrobble(self): # Arrange - artist = "Test Artist" + artist = "test artist" title = "test title" timestamp = self.unix_timestamp() lastfm_user = self.network.get_user(self.username) @@ -25,8 +25,8 @@ class TestPyLastNetwork(PyLastTestCase): # Assert # limit=2 to ignore now-playing: last_scrobble = lastfm_user.get_recent_tracks(limit=2)[0] - self.assertEqual(str(last_scrobble.track.artist), str(artist)) - self.assertEqual(str(last_scrobble.track.title), str(title)) + self.assertEqual(str(last_scrobble.track.artist).lower(), artist) + self.assertEqual(str(last_scrobble.track.title).lower(), title) self.assertEqual(str(last_scrobble.timestamp), str(timestamp)) def test_update_now_playing(self): @@ -44,8 +44,8 @@ class TestPyLastNetwork(PyLastTestCase): # Assert current_track = lastfm_user.get_now_playing() self.assertIsNotNone(current_track) - self.assertEqual(str(current_track.title), "test title") - self.assertEqual(str(current_track.artist), "Test Artist") + self.assertEqual(str(current_track.title).lower(), "test title") + self.assertEqual(str(current_track.artist).lower(), "test artist") def test_enable_rate_limiting(self): # Arrange diff --git a/tests/test_pylast_track.py b/tests/test_pylast_track.py index 61ef132..7b0c99a 100755 --- a/tests/test_pylast_track.py +++ b/tests/test_pylast_track.py @@ -23,8 +23,8 @@ class TestPyLastTrack(PyLastTestCase): # Assert loved = lastfm_user.get_loved_tracks(limit=1) - self.assertEqual(str(loved[0].track.artist), "Test Artist") - self.assertEqual(str(loved[0].track.title), "test title") + self.assertEqual(str(loved[0].track.artist).lower(), "test artist") + self.assertEqual(str(loved[0].track.title).lower(), "test title") def test_unlove(self): # Arrange diff --git a/tests/test_pylast_user.py b/tests/test_pylast_user.py index 40be3b8..64494b0 100755 --- a/tests/test_pylast_user.py +++ b/tests/test_pylast_user.py @@ -399,7 +399,7 @@ class TestPyLastUser(PyLastTestCase): title = track.get_title(properly_capitalized=True) # Assert - self.assertEqual(title, "test title") + self.assertEqual(title, "Test Title") def test_track_listener_count(self): # Arrange