From 0f25db7a75a6a2548e47ddbc6206e007f9e8826a Mon Sep 17 00:00:00 2001 From: dotX12 Date: Sun, 25 Feb 2024 04:04:28 +0300 Subject: [PATCH 1/2] override max_timeout retry 60sec, and added logic for override retry condition. --- examples/recognize_song.py | 7 +++++++ pyproject.toml | 2 +- setup.py | 2 +- shazamio/__init__.py | 3 ++- shazamio/api.py | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/recognize_song.py b/examples/recognize_song.py index 2604fec..ef37d21 100644 --- a/examples/recognize_song.py +++ b/examples/recognize_song.py @@ -12,6 +12,13 @@ async def main(): + # shazam = Shazam( + # http_client=HTTPClient( + # retry_options=ExponentialRetry(attempts=12, max_timeout=204.8, statuses={500, 502, 503, 504, 429}), + # ), + # ) + # if u need override retry option... + shazam = Shazam() # pass path (deprecated) diff --git a/pyproject.toml b/pyproject.toml index b9dbcd5..1fbb22f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "shazamio" -version = "0.5.0" +version = "0.5.1" description = "Is a asynchronous framework from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp." authors = ["dotX12"] license = "MIT License" diff --git a/setup.py b/setup.py index 45a0a83..25b278f 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="shazamio", - version="0.5.0", + version="0.5.1", author="dotX12", description="Is a FREE asynchronous library from reverse engineered Shazam API written in Python 3.6+ with asyncio and aiohttp. Includes all the methods that Shazam has, including searching for a song by file.", long_description=long_description, diff --git a/shazamio/__init__.py b/shazamio/__init__.py index f04f8e2..ec9198c 100644 --- a/shazamio/__init__.py +++ b/shazamio/__init__.py @@ -2,5 +2,6 @@ from .api import Shazam from .converter import GeoService from .enums import GenreMusic +from .client import HTTPClient -__all__ = ("Serialize", "Shazam", "GeoService", "GenreMusic") +__all__ = ("Serialize", "Shazam", "GeoService", "GenreMusic", "HTTPClient") diff --git a/shazamio/api.py b/shazamio/api.py index 82dfc05..fca7a59 100644 --- a/shazamio/api.py +++ b/shazamio/api.py @@ -39,7 +39,7 @@ def __init__( self.endpoint_country = endpoint_country self.http_client = http_client or HTTPClient( - retry_options=ExponentialRetry(attempts=20, statuses={500, 502, 503, 504, 429}), + retry_options=ExponentialRetry(attempts=20, max_timeout=60, statuses={500, 502, 503, 504, 429}), ) self.geo_service = GeoService(self.http_client) From 89f9375e69a4aa310d5858852f43b23e9dfeab9f Mon Sep 17 00:00:00 2001 From: autoblack Date: Sun, 25 Feb 2024 01:07:18 +0000 Subject: [PATCH 2/2] fixup: Format Python code with Black --- shazamio/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shazamio/api.py b/shazamio/api.py index fca7a59..d31b811 100644 --- a/shazamio/api.py +++ b/shazamio/api.py @@ -39,7 +39,9 @@ def __init__( self.endpoint_country = endpoint_country self.http_client = http_client or HTTPClient( - retry_options=ExponentialRetry(attempts=20, max_timeout=60, statuses={500, 502, 503, 504, 429}), + retry_options=ExponentialRetry( + attempts=20, max_timeout=60, statuses={500, 502, 503, 504, 429} + ), ) self.geo_service = GeoService(self.http_client)