From 52636b67643ef0066b90dd89f30b0e71fbaa3620 Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 24 Oct 2017 00:04:05 +0300 Subject: [PATCH 1/2] Work around Last.fm's 'Namespace prefix opensearch on totalResults is not defined' XML error --- pylast/__init__.py | 2 +- tests/test_pylast_network.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 3d1a219..1db3d88 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -2483,7 +2483,7 @@ class _Search(_BaseObject): doc = self._request(self._ws_prefix + ".search", True) - return _extract(doc, "opensearch:totalResults") + return _extract(doc, "totalResults") def _retrieve_page(self, page_index): """Returns the node of matches to be processed""" diff --git a/tests/test_pylast_network.py b/tests/test_pylast_network.py index 733a80e..2906b92 100755 --- a/tests/test_pylast_network.py +++ b/tests/test_pylast_network.py @@ -339,6 +339,18 @@ class TestPyLastNetwork(PyLastTestCase): self.assertIsInstance(results, list) self.assertIsInstance(results[0], pylast.Track) + def test_search_get_total_result_count(self): + # Arrange + artist = "Nirvana" + track = "Smells Like Teen Spirit" + search = self.network.search_for_track(artist, track) + + # Act + total = search.get_total_result_count() + + # Assert + self.assertGreater(int(total), 10000) + if __name__ == '__main__': unittest.main(failfast=True) From cb1f7607316dcbf70324089fab96d456093c3ee6 Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 24 Oct 2017 00:11:49 +0300 Subject: [PATCH 2/2] http -> https --- COPYING | 2 +- pylast/__init__.py | 2 +- tests/test_pylast_artist.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/COPYING b/COPYING index eec88ff..c4ff845 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ Apache License Version 2.0, January 2004 -http://www.apache.org/licenses/ +https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION diff --git a/pylast/__init__.py b/pylast/__init__.py index 1db3d88..1dc7547 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -830,7 +830,7 @@ class _Request(object): try: conn.request( - method='POST', url="http://" + HOST_NAME + HOST_SUBDIR, + method='POST', url="https://" + HOST_NAME + HOST_SUBDIR, body=data, headers=headers) except Exception as e: raise NetworkError(self.network, e) diff --git a/tests/test_pylast_artist.py b/tests/test_pylast_artist.py index 0d45f64..66dbb49 100755 --- a/tests/test_pylast_artist.py +++ b/tests/test_pylast_artist.py @@ -213,7 +213,7 @@ class TestPyLastArtist(PyLastTestCase): name_cap = artist1.get_name(properly_capitalized=True) # Assert - self.assertIn("http", image) + self.assertIn("https", image) self.assertGreater(playcount, 1) self.assertTrue(artist1 != artist2) self.assertEqual(name.lower(), name_cap.lower())