From 178dc8822e650f1b50035cc8e1113f2a7e42b176 Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Sun, 19 Apr 2026 16:14:33 -0300 Subject: [PATCH] Store storefront and language in ItunesApi --- gamdl/api/itunes.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/gamdl/api/itunes.py b/gamdl/api/itunes.py index 98291c0..f95611c 100644 --- a/gamdl/api/itunes.py +++ b/gamdl/api/itunes.py @@ -17,8 +17,14 @@ class ItunesApi: def __init__( self, client: httpx.AsyncClient, + storefront: str, + language: str, + storefront_id: int, ) -> None: self.client = client + self.storefront = storefront + self.language = language + self.storefront_id = storefront_id @staticmethod async def get_storefront_id(storefront: str) -> int: @@ -69,17 +75,15 @@ class ItunesApi: storefront_id = storefront_id or await cls.get_storefront_id(storefront) client = httpx.AsyncClient( - params={ - "country": storefront, - "lang": language, - }, - headers={ - "X-Apple-Store-Front": f"{storefront_id}-1,32 t:music31", - }, timeout=60.0, ) - return cls(client=client) + return cls( + client=client, + storefront=storefront, + language=language, + storefront_id=storefront_id, + ) async def get_lookup_result( self, @@ -94,6 +98,8 @@ class ItunesApi: params={ "id": media_id, "entity": entity, + "country": self.storefront, + "lang": self.language, }, ) response.raise_for_status() @@ -122,7 +128,10 @@ class ItunesApi: try: response = await self.client.get( - ITUNES_PAGE_API_URL.format(media_type=media_type, media_id=media_id) + ITUNES_PAGE_API_URL.format(media_type=media_type, media_id=media_id), + headers={ + "X-Apple-Store-Front": f"{self.storefront_id}-1,32 t:music31", + }, ) response.raise_for_status() itunes_page = response.json()