From 6fe9aa632b2147eaf7278230def9ea735eb73f4e Mon Sep 17 00:00:00 2001 From: Koen van Zuijlen Date: Sat, 2 Jan 2021 00:48:32 +0100 Subject: [PATCH 1/2] Fix for user play count and user loved --- src/pylast/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 05c0361..20a087c 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -888,6 +888,9 @@ class _Request: if self.network.limit_rate: self.network._delay_call() + username = self.params.pop("username", None) + username = f"?username={username}" if username is not None else "" + data = [] for name in self.params.keys(): data.append("=".join((name, quote_plus(_string(self.params[name]))))) @@ -911,7 +914,7 @@ class _Request: try: conn.request( method="POST", - url="https://" + host_name + host_subdir, + url=f"https://{host_name}{host_subdir}{username}", body=data, headers=headers, ) @@ -922,7 +925,7 @@ class _Request: conn = HTTPSConnection(context=SSL_CONTEXT, host=host_name) try: - conn.request(method="POST", url=host_subdir, body=data, headers=headers) + conn.request(method="POST", url=f'{host_subdir}{username}', body=data, headers=headers) except Exception as e: raise NetworkError(self.network, e) @@ -1494,7 +1497,7 @@ class _Opus(_Taggable): self.artist = Artist(artist, self.network) self.title = title - self.username = username + self.username = username if username else network.username # Default to current user self.info = info def __repr__(self): From 0c546976b9c640c1c38acc57ec27dbebb29127a6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 2 Jan 2021 00:06:15 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pylast/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 20a087c..bec13d5 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -925,7 +925,12 @@ class _Request: conn = HTTPSConnection(context=SSL_CONTEXT, host=host_name) try: - conn.request(method="POST", url=f'{host_subdir}{username}', body=data, headers=headers) + conn.request( + method="POST", + url=f"{host_subdir}{username}", + body=data, + headers=headers, + ) except Exception as e: raise NetworkError(self.network, e) @@ -1497,7 +1502,9 @@ class _Opus(_Taggable): self.artist = Artist(artist, self.network) self.title = title - self.username = username if username else network.username # Default to current user + self.username = ( + username if username else network.username + ) # Default to current user self.info = info def __repr__(self):