From cbf2066ee57111a2e5a3f7c28fa0ce2110c1e477 Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 7 Sep 2015 18:25:32 +0300 Subject: [PATCH 1/7] Failing test for #146 --- tests/test_pylast.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index abe9917..e013811 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1972,5 +1972,15 @@ class TestPyLast(unittest.TestCase): # Assert self.assertEqual(corrected_track_name, "Mr. Brownstone") + def test_track_with_no_mbid(self): + # Arrange + track = pylast.Track("Static-X", "Set It Off", self.network) + + # Act + mbid = track.get_mbid() + + # Assert + self.assertEqual(mbid, None) + if __name__ == '__main__': unittest.main(failfast=True) From f090876c0aa3c8641f79d9acd10f5fa578eaed0f Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 7 Sep 2015 23:57:36 +0300 Subject: [PATCH 2/7] Fix for #146: only get the top-level --- pylast/__init__.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 4382337..4c5e28f 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1809,8 +1809,21 @@ class _Opus(_BaseObject, _Taggable): def get_mbid(self): """Returns the MusicBrainz ID of the album or track.""" - return _extract( - self._request(self.ws_prefix + ".getInfo", cacheable=True), "mbid") + doc = self._request(self.ws_prefix + ".getInfo", cacheable=True) + + try: + lfm = doc.getElementsByTagName('lfm')[0] + opus = self._get_children_by_tag_name(lfm, self.ws_prefix).next() + mbid = self._get_children_by_tag_name(opus, "mbid").next() + return mbid.firstChild.nodeValue + except StopIteration: + return None + + def _get_children_by_tag_name(self, node, tag_name): + for child in node.childNodes: + if (child.nodeType == child.ELEMENT_NODE and + (tag_name == '*' or child.tagName == tag_name)): + yield child class Album(_Opus): From 63eb4de06b3960898c76020c5a78c3df20f5267d Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 7 Sep 2015 15:07:35 +0300 Subject: [PATCH 3/7] Release 1.4.2 --- pylast/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index f621266..4382337 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -32,7 +32,7 @@ import warnings import re import six -__version__ = '1.4.1' +__version__ = '1.4.2' __author__ = 'Amr Hassan, hugovk' __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2015 hugovk" __license__ = "apache2" diff --git a/setup.py b/setup.py index 5a29c34..3fb0404 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup( name="pylast", - version="1.4.1", + version="1.4.2", author="Amr Hassan ", install_requires=['six'], tests_require=['mock', 'pytest', 'coverage', 'pep8', 'pyyaml', 'pyflakes'], From 6382853b45a006c07f7d9823fa18fdbf6fe71411 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 7 Sep 2015 15:41:30 +0300 Subject: [PATCH 4/7] Check installation sooner [CI skip] --- RELEASING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index e4ed249..b395aaa 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -17,6 +17,7 @@ git tag -a 1.5.0 -m "Release 1.5.0" python setup.py register python setup.py sdist --format=gztar upload ``` +* [ ] Check installation: `pip install -U pylast` * [ ] Push: `git push` * [ ] Push tags: `git push --tags` * [ ] Create new GitHub release: https://github.com/pylast/pylast/releases/new @@ -28,4 +29,4 @@ git checkout develop git merge master --ff-only git push ``` - * [ ] Check installation: `pip install -U pylast` + From 53be0e5f062786349d3a0a8b193bb2ad8be1ef2d Mon Sep 17 00:00:00 2001 From: Kaushik Ganesh Date: Tue, 1 Dec 2015 19:20:34 +0530 Subject: [PATCH 5/7] Fix album.get_tracks() --- pylast/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 4c5e28f..ca65067 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1857,9 +1857,9 @@ class Album(_Opus): def get_tracks(self): """Returns the list of Tracks on this album.""" - uri = 'lastfm://playlist/album/%s' % self.get_id() - - return XSPF(uri, self.network).get_tracks() + return _extract_tracks( + self._request( + self.ws_prefix + ".getInfo", cacheable=True), "tracks") def get_url(self, domain_name=DOMAIN_ENGLISH): """Returns the URL of the album or track page on the network. From 5bb98a35411c2a1f15cd350e8136eae1de702be5 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 10 Dec 2015 00:44:17 +0200 Subject: [PATCH 6/7] Fix tox==2.1.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2cfaab8..9a32908 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: - TOXENV=pypy3 sudo: false install: -- travis_retry pip install tox +- travis_retry pip install tox==2.1.1 - travis_retry pip install coveralls script: tox after_success: From 42e881824bb603d022a503f25a6cc170e8ed1ee0 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 10 Dec 2015 09:06:25 +0200 Subject: [PATCH 7/7] Add YAML rules [CI skip] --- .editorconfig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index de5533f..b71c07e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# top-most EditorConfig file +# Top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file @@ -7,7 +7,13 @@ end_of_line = lf insert_final_newline = true charset = utf-8 -# 4 space indentation +# Four-space indentation [*.py] indent_size = 4 indent_style = space + +trim_trailing_whitespace = true + +# Two-space indentation +[*.yml] +indent_size = 2