Add multi-country ITAD deals, configurable currency, and per-source filtering
- ITAD deals can now be fetched from multiple countries simultaneously via ITAD_COUNTRIES (e.g. US,CA,GB,DE). Deals are merged across regions and deduplicated by game+shop, with the first country taking priority. - Prices from non-USD regions are normalised to USD using exchange rates so filtering (max price) works consistently across countries. - ITAD results are now sorted by newest deals first (client-side by timestamp) instead of only by highest discount, reducing missed deals. - Default fetch limit raised from 20 to 100 to capture more deals. - Display currency is now configurable: DEFAULT_CURRENCY sets the primary currency shown first, EXTRA_CURRENCIES sets additional ones. All Frankfurter-supported currencies are available with proper symbols. - Filtering is now per-source with dedicated env vars: CHEAPSHARK_MIN_DISCOUNT, CHEAPSHARK_MIN_RATING, CHEAPSHARK_MAX_PRICE, ITAD_MIN_DISCOUNT, ITAD_MAX_PRICE, ITAD_DEALS_LIMIT. Shared fallbacks (MIN_DISCOUNT_PERCENT, MAX_PRICE) are still supported. Legacy MAX_PRICE_USD and MIN_DEAL_RATING continue to work as fallbacks. https://claude.ai/code/session_01EfPjktyrF24DBNHWsY1KBP
This commit is contained in:
@@ -20,10 +20,47 @@ class Config:
|
||||
s.strip().lower() for s in raw_sources.split(",") if s.strip()
|
||||
]
|
||||
|
||||
# Deal filtering
|
||||
self.min_deal_rating = float(os.environ.get("MIN_DEAL_RATING", "8.0"))
|
||||
self.min_discount_percent = int(os.environ.get("MIN_DISCOUNT_PERCENT", "50"))
|
||||
self.max_price_usd = float(os.environ.get("MAX_PRICE_USD", "20"))
|
||||
# ITAD countries: comma-separated ISO 3166-1 alpha-2 country codes
|
||||
# Deals are fetched for each country and merged (first country has priority
|
||||
# when the same game appears in multiple regions).
|
||||
raw_countries = os.environ.get("ITAD_COUNTRIES", "US")
|
||||
self.itad_countries: list[str] = [
|
||||
c.strip().upper() for c in raw_countries.split(",") if c.strip()
|
||||
]
|
||||
|
||||
# Currency display
|
||||
self.default_currency = os.environ.get("DEFAULT_CURRENCY", "USD").upper()
|
||||
raw_extra = os.environ.get("EXTRA_CURRENCIES", "CAD,EUR,GBP")
|
||||
self.extra_currencies: list[str] = [
|
||||
c.strip().upper() for c in raw_extra.split(",") if c.strip()
|
||||
]
|
||||
|
||||
# Shared filter fallbacks (support legacy env vars)
|
||||
_max_price = os.environ.get(
|
||||
"MAX_PRICE", os.environ.get("MAX_PRICE_USD", "20")
|
||||
)
|
||||
_min_discount = os.environ.get("MIN_DISCOUNT_PERCENT", "50")
|
||||
_min_rating = os.environ.get("MIN_DEAL_RATING", "8.0")
|
||||
|
||||
# CheapShark-specific filtering (falls back to shared values)
|
||||
self.cheapshark_min_discount = int(
|
||||
os.environ.get("CHEAPSHARK_MIN_DISCOUNT", _min_discount)
|
||||
)
|
||||
self.cheapshark_min_rating = float(
|
||||
os.environ.get("CHEAPSHARK_MIN_RATING", _min_rating)
|
||||
)
|
||||
self.cheapshark_max_price = float(
|
||||
os.environ.get("CHEAPSHARK_MAX_PRICE", _max_price)
|
||||
)
|
||||
|
||||
# ITAD-specific filtering (falls back to shared values)
|
||||
self.itad_min_discount = int(
|
||||
os.environ.get("ITAD_MIN_DISCOUNT", _min_discount)
|
||||
)
|
||||
self.itad_max_price = float(
|
||||
os.environ.get("ITAD_MAX_PRICE", _max_price)
|
||||
)
|
||||
self.itad_deals_limit = int(os.environ.get("ITAD_DEALS_LIMIT", "100"))
|
||||
|
||||
# Intro message on startup
|
||||
self.send_intro_message = os.environ.get(
|
||||
|
||||
Reference in New Issue
Block a user