4 Commits

Author SHA1 Message Date
10290fd28d Merge pull request 'Better versionning' (#25) from fixed-cache into main
Reviewed-on: #25
2025-12-05 16:55:42 +01:00
b26a6a2d0a Better versionning 2025-12-05 16:46:44 +01:00
78ee9ac9da Merge pull request 'fixed cache issues' (#24) from fixed-cache into main
Reviewed-on: #24
2025-12-05 16:26:57 +01:00
cef6886fd2 fixed cache issues 2025-12-05 16:20:42 +01:00
5 changed files with 20 additions and 5 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.venv
__pycache__/

View File

@@ -4,6 +4,7 @@ RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY VERSION /VERSION
COPY /app/ /app/
RUN pip install --no-cache-dir -r requirements.txt

1
VERSION Normal file
View File

@@ -0,0 +1 @@
4.0.3

View File

@@ -4,7 +4,9 @@ import logging
import json
import sys
VERSION = "4.0.2"
# Read version from VERSION file
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "VERSION"), "r", encoding="utf-8") as f:
VERSION = f.read().strip()
# Logger setup
logging.basicConfig(
@@ -89,7 +91,10 @@ HEADERS = {
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not.A/Brand\";v=\"24\"",
"Sec-Ch-Ua-Platform": "\"macOS\""
"Sec-Ch-Ua-Platform": "\"macOS\"",
"Cache-Control": "no-cache, no-store, must-revalidate",
"Pragma": "no-cache",
"Expires": "0"
}
# Load country setting and localization config

View File

@@ -1,5 +1,6 @@
import requests
import logging
import time
from env_config import HEADERS, PRODUCT_NAMES, API_URL_SKU, API_URL_STOCK, PRODUCT_URL
from notifier import send_discord_notification, send_out_of_stock_notification, send_sku_change_notification
from requests.adapters import HTTPAdapter, Retry
@@ -8,6 +9,7 @@ from requests.adapters import HTTPAdapter, Retry
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
session.mount('https://', HTTPAdapter(max_retries=retries))
session.headers.update(HEADERS)
# Keeping memory of last run
last_sku_dict = {}
@@ -20,7 +22,10 @@ def check_rtx_50_founders():
# Fetching nvidia API data
try:
response = session.get(API_URL_SKU, headers=HEADERS, timeout=10)
cache_buster = int(time.time() * 1000)
sku_url = f"{API_URL_SKU}&_t={cache_buster}"
response = session.get(sku_url, timeout=10)
logging.info(f"SKU API response: {response.status_code}")
response.raise_for_status()
data = response.json()
@@ -57,11 +62,12 @@ def check_rtx_50_founders():
first_run_dict[product_name] = False
# Check product availability in API_URL_STOCK for each SKU
api_stock_url = API_URL_STOCK + product_sku
cache_buster = int(time.time() * 1000)
api_stock_url = f"{API_URL_STOCK}{product_sku}&_t={cache_buster}"
logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
try:
response = session.get(api_stock_url, headers=HEADERS, timeout=10)
response = session.get(api_stock_url, timeout=10)
logging.info(f"[{product_name}] Stock API response: {response.status_code}")
response.raise_for_status()
stock_data = response.json()