From 88619b30d4b778586015c82d26541246ac0f272b Mon Sep 17 00:00:00 2001 From: Paddez Date: Mon, 7 Nov 2016 13:18:02 +0000 Subject: [PATCH 1/3] Edit to allow URL to be saved --- pylast/__init__.py | 17 +++++++++++------ setup.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 88039dd..e6c4e85 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1833,9 +1833,12 @@ class Album(_Opus): """An album.""" __hash__ = _Opus.__hash__ - - def __init__(self, artist, title, network, username=None): + cover_image = None + + def __init__(self, artist, title, network, username=None, url=None): super(Album, self).__init__(artist, title, network, "album", username) + if url: + self.cover_image = url def get_release_date(self): """Returns the release date of the album.""" @@ -1852,10 +1855,12 @@ class Album(_Opus): COVER_MEDIUM COVER_SMALL """ - - return _extract_all( - self._request( - self.ws_prefix + ".getInfo", cacheable=True), 'image')[size] + if self.cover_image: + return self.cover_image + else: + return _extract_all( + self._request( + self.ws_prefix + ".getInfo", cacheable=True), 'image')[size] def get_tracks(self): """Returns the list of Tracks on this album.""" diff --git a/setup.py b/setup.py index 1e99522..fcd4e1a 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup( name="pylast", - version="1.6.0", + version="1.6.1", author="Amr Hassan ", install_requires=['six'], tests_require=['mock', 'pytest', 'coverage', 'pep8', 'pyyaml', 'pyflakes'], From f911168a57046ceecb80de9f84e7bf30fae4af45 Mon Sep 17 00:00:00 2001 From: Paddez Date: Mon, 7 Nov 2016 13:20:38 +0000 Subject: [PATCH 2/3] Modify to extract the URL from XML response --- pylast/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index e6c4e85..c683f12 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -4163,8 +4163,9 @@ def _extract_top_albums(doc, network): name = _extract(node, "name") artist = _extract(node, "name", 1) playcount = _extract(node, "playcount") + cover_url = _extract_all(node, "image")[COVER_EXTRA_LARGE] - seq.append(TopItem(Album(artist, name, network), playcount)) + seq.append(TopItem(Album(artist, name, network, url=cover_url), playcount)) return seq From d9b43e6d9c9ca5a513cd4931c42c2070053343e1 Mon Sep 17 00:00:00 2001 From: Paddez Date: Mon, 7 Nov 2016 13:42:42 +0000 Subject: [PATCH 3/3] Return Cover URL with the Album metadata --- pylast/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index c683f12..45c733c 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -32,7 +32,7 @@ import warnings import re import six -__version__ = '1.6.0' +__version__ = '1.6.1' __author__ = 'Amr Hassan, hugovk' __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2016 hugovk" __license__ = "apache2" @@ -1833,12 +1833,12 @@ class Album(_Opus): """An album.""" __hash__ = _Opus.__hash__ - cover_image = None + cover_url = None def __init__(self, artist, title, network, username=None, url=None): super(Album, self).__init__(artist, title, network, "album", username) if url: - self.cover_image = url + self.cover_url = url def get_release_date(self): """Returns the release date of the album.""" @@ -1855,8 +1855,8 @@ class Album(_Opus): COVER_MEDIUM COVER_SMALL """ - if self.cover_image: - return self.cover_image + if self.cover_url: + return self.cover_url else: return _extract_all( self._request(