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/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: diff --git a/pylast/__init__.py b/pylast/__init__.py index 40b9f07..de89377 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -86,11 +86,12 @@ 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 +# 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 +SIZE_EXTRA_LARGE = COVER_EXTRA_LARGE = 3 +SIZE_MEGA = COVER_MEGA = 4 IMAGES_ORDER_POPULARITY = "popularity" IMAGES_ORDER_DATE = "dateadded" @@ -1468,14 +1469,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 +1576,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_EXTRA_LARGE): """ 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( @@ -2287,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.""" @@ -2409,12 +2410,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=SIZE_EXTRA_LARGE): + """ + Returns the user's avatar + size can be one of: + SIZE_EXTRA_LARGE + SIZE_LARGE + SIZE_MEDIUM + SIZE_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. 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" 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 1169f41..64494b0 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 @@ -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 diff --git a/tox.ini b/tox.ini index 6347575..1cfc777 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]