From 952aca3de57f0331ff9a364c39d9ce50db4459b1 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 15 Jul 2026 15:31:53 +0530 Subject: [PATCH] feat(amazon): add marketplace locale mapping --- .../proprietary/platforms/amazon/locale.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 surfsense_backend/app/proprietary/platforms/amazon/locale.py diff --git a/surfsense_backend/app/proprietary/platforms/amazon/locale.py b/surfsense_backend/app/proprietary/platforms/amazon/locale.py new file mode 100644 index 000000000..1e8b7b880 --- /dev/null +++ b/surfsense_backend/app/proprietary/platforms/amazon/locale.py @@ -0,0 +1,33 @@ +"""Marketplace locale helpers for Amazon fetch routing. + +Only proxy countries verified against the configured DataImpulse plan are mapped +here. Unmapped marketplaces fall back to the default proxy exit. +""" + +_MARKETPLACE_COUNTRY = { + "com": "us", + "co.uk": "gb", + "de": "de", + "fr": "fr", + "it": "it", + "es": "es", +} + +_MARKETPLACE_LANGUAGE = { + "com": "en-US", + "co.uk": "en-GB", + "de": "de-DE", + "fr": "fr-FR", + "it": "it-IT", + "es": "es-ES", +} + + +def proxy_country_for(marketplace: str | None) -> str | None: + """Return a confirmed proxy exit country for one Amazon marketplace.""" + return _MARKETPLACE_COUNTRY.get((marketplace or "").lower()) + + +def accept_language_for(marketplace: str | None) -> str: + """Return the browser language header that matches the marketplace UI.""" + return _MARKETPLACE_LANGUAGE.get((marketplace or "").lower(), "en-US")