Compare commits
20 Commits
1edaa2c71d
...
v4.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 10290fd28d | |||
| b26a6a2d0a | |||
| 78ee9ac9da | |||
| cef6886fd2 | |||
| b3fe0fcf24 | |||
| 2484568e5f | |||
| 7f24145dc2 | |||
| 8f626a7737 | |||
| 4c57a3a310 | |||
| 407e27238f | |||
| 961c24a6c6 | |||
| a16db7be01 | |||
| 92db785511 | |||
| 1f3db4dec8 | |||
| 004d227fd1 | |||
| fc15c6fbbe | |||
| 3ba8c86b53 | |||
| 1b15946a55 | |||
| f2b5b184ea | |||
| 70b723b781 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.venv
|
||||
__pycache__/
|
||||
@@ -1,9 +1,10 @@
|
||||
FROM python:3.11-alpine
|
||||
FROM python:3.13-alpine
|
||||
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY VERSION /VERSION
|
||||
COPY /app/ /app/
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
**🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications.
|
||||
|
||||
> [!NOTE]
|
||||
>_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there._
|
||||
>
|
||||
>_LLM used for bugs check and languages files generation._
|
||||
>_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there. LLM used for bugs check and languages files generation._
|
||||
|
||||
## 🖼️ Screenshots
|
||||
|
||||
<div align="center" >
|
||||
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-discord.png?=1" alt="Nvidia Stock Bot - screenshots">
|
||||
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-discord-screenshot.png" alt="Nvidia Stock Bot - screenshots">
|
||||
</div>
|
||||
|
||||
## 📌 Table of Contents
|
||||
@@ -78,7 +76,7 @@ services:
|
||||
| `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free |
|
||||
| `DISCORD_ROLES` | List of Discord roles ID in the same order than `PRODUCT_NAMES` values, found in your discord server settings (with user profile developer mode enabled) | `<@&12345><@&6789>` | @everyone |
|
||||
| `REFRESH_TIME` | Script refresh interval in seconds | `60`, `30`, etc. | `30` |
|
||||
| `API_URL_SKU` | API listing the product. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | An URL | https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia` |
|
||||
| `API_URL_SKU` | API listing the product. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | An URL | `https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia` |
|
||||
| `API_URL_STOCK` | API providing stock data. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | A URL | `https://api.store.nvidia.com/partner/v1/feinventory?locale={locale}&skus=` |
|
||||
| `PRODUCT_URL` | GPU purchase URL. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | A URL | `https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale={locale}&page=1&limit=12&manufacturer=NVIDIA` |
|
||||
| `TEST_MODE` | For testing without sending notifications | `True`, `False` | `False` |
|
||||
|
||||
@@ -4,7 +4,9 @@ import logging
|
||||
import json
|
||||
import sys
|
||||
|
||||
VERSION = "4.0.0"
|
||||
# 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(
|
||||
@@ -79,21 +81,20 @@ else:
|
||||
|
||||
# HTTP headers
|
||||
HEADERS = {
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/131.0.0.0 Safari/537.36",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,"
|
||||
"image/avif,image/webp,image/apng,*/*;q=0.8",
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
|
||||
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||
"Accept-Language": "en-US,en;q=0.5",
|
||||
"Cache-Control": "max-age=0",
|
||||
"Referer": "https://partners.nvidia.com/",
|
||||
"Origin": "https://partners.nvidia.com",
|
||||
"Connection": "keep-alive",
|
||||
"Sec-Fetch-Dest": "document",
|
||||
"Sec-Fetch-Mode": "navigate",
|
||||
"Sec-Fetch-Site": "none",
|
||||
"Sec-Fetch-User": "?1",
|
||||
"Upgrade-Insecure-Requests": "1",
|
||||
"Sec-GPC": "1",
|
||||
"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\"",
|
||||
"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()
|
||||
|
||||
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
@@ -6,8 +6,6 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# Minimal environment variables
|
||||
environment:
|
||||
# Minimal environment variables
|
||||
- PRODUCT_NAMES=${PRODUCT_NAMES}
|
||||
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
|
||||
|
||||
Reference in New Issue
Block a user