From 90534ee13a41ec125fa8c0b2b7b2b81bc26d8a80 Mon Sep 17 00:00:00 2001 From: Owais Aamir Date: Mon, 9 Dec 2024 11:47:05 +0000 Subject: [PATCH] Fixed language code getting added to URL query parameter --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- speechmatics/client.py | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1a1fda..a44d80f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0.1] - 2024-12-09 + +### Fixed + +- Language code getting added to URL query parameter + ## [3.0.0] - 2024-11-12 ### Changed diff --git a/VERSION b/VERSION index 4a36342..cb2b00e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0 +3.0.1 diff --git a/speechmatics/client.py b/speechmatics/client.py index 042cc11..842883b 100644 --- a/speechmatics/client.py +++ b/speechmatics/client.py @@ -472,20 +472,26 @@ async def run( extra_headers["Authorization"] = token url = self.connection_settings.url - if not url.endswith(self.transcription_config.language.strip()): - if url.endswith("/"): - url += self.transcription_config.language.strip() - else: - url += f"/{self.transcription_config.language.strip()}" # Extend connection url with sdk version information cli = "-cli" if from_cli is True else "" version = get_version() parsed_url = urlparse(url) + query_params = dict(parse_qsl(parsed_url.query)) query_params["sm-sdk"] = f"python{cli}-{version}" updated_query = urlencode(query_params) - updated_url = urlunparse(parsed_url._replace(query=updated_query)) + + url_path = parsed_url.path + if not url_path.endswith(self.transcription_config.language.strip()): + if url_path.endswith("/"): + url_path += self.transcription_config.language.strip() + else: + url_path += f"/{self.transcription_config.language.strip()}" + + updated_url = urlunparse( + parsed_url._replace(path=url_path, query=updated_query) + ) try: async with websockets.connect( # pylint: disable=no-member