Compare commits
4 Commits
v4.0.2
...
10290fd28d
| Author | SHA1 | Date | |
|---|---|---|---|
| 10290fd28d | |||
| b26a6a2d0a | |||
| 78ee9ac9da | |||
| cef6886fd2 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.venv
|
||||
__pycache__/
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user