Compare commits
20 Commits
v4.0
...
fixed-cach
| Author | SHA1 | Date | |
|---|---|---|---|
| df1a60034c | |||
| 7094801549 | |||
| 389d10615e | |||
| 62b16f1dbf | |||
| 09662e656e | |||
| b26a6a2d0a | |||
| cef6886fd2 | |||
| b3fe0fcf24 | |||
| 2484568e5f | |||
| 7f24145dc2 | |||
| 8f626a7737 | |||
| 4c57a3a310 | |||
| 407e27238f | |||
| 961c24a6c6 | |||
| a16db7be01 | |||
| 92db785511 | |||
| 1f3db4dec8 | |||
| 1edaa2c71d | |||
| 004d227fd1 | |||
| 40d83cad12 |
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
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY VERSION /VERSION
|
||||||
COPY /app/ /app/
|
COPY /app/ /app/
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -11,9 +11,13 @@
|
|||||||
**🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications.
|
**🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
>_The code was partially written and structured using a generative AI._
|
>_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._
|
## 🖼️ Screenshots
|
||||||
|
|
||||||
|
<div align="center" >
|
||||||
|
<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
|
## 📌 Table of Contents
|
||||||
|
|
||||||
@@ -21,8 +25,8 @@
|
|||||||
- [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick)
|
- [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick)
|
||||||
- [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo)
|
- [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo)
|
||||||
- [🐍 Python Installation (developer)](#-python-installation)
|
- [🐍 Python Installation (developer)](#-python-installation)
|
||||||
- [🖼️ Screenshots](#-screenshots)
|
|
||||||
- [🐞 Common issues](#-common-issues)
|
- [🐞 Common issues](#-common-issues)
|
||||||
|
- [❓ How it works](#-how-it-works)
|
||||||
- [🧑💻 Contributors](#-contributors)
|
- [🧑💻 Contributors](#-contributors)
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
@@ -68,12 +72,11 @@ services:
|
|||||||
|---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
|
|---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
|
||||||
| `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | |
|
| `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | |
|
||||||
| `DISCORD_WEBHOOK_URL` | Your Discord webhook URL | A valid URL | |
|
| `DISCORD_WEBHOOK_URL` | Your Discord webhook URL | A valid URL | |
|
||||||
| `COUNTRY` | Your country (only one). API localization, Discord notification currency and language will be set accordingly | `GB`, `US`, `CA`, `BE`, `NL`, `DK`, `DE`, `ES`, `FR`, `IT`, `NO`, `AT`, `PL`, `FI`, `SE`, `KR`, `JP`
|
| `COUNTRY` | Your country (only one). API localization, Discord notification currency and language will be set accordingly | `GB`, `US`, `CA`, `BE`, `NL`, `DK`, `DE`, `ES`, `FR`, `IT`, `NO`, `AT`, `PL`, `FI`, `SE`, `KR`, `JP` | `US` |
|
||||||
| `US` |
|
|
||||||
| `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free |
|
| `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 |
|
| `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` |
|
| `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=` |
|
| `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` |
|
| `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` |
|
| `TEST_MODE` | For testing without sending notifications | `True`, `False` | `False` |
|
||||||
@@ -151,7 +154,7 @@ git clone https://git.djeex.fr/Djeex/nvidia-stock-bot.git
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
export DISCORD_WEBHOOK_URL="https://your_discord_url"
|
export DISCORD_WEBHOOK_URL="https://your_discord_url"
|
||||||
export COUNTRY=€
|
export COUNTRY=US
|
||||||
export PRODUCT_NAMES=RTX 5080, RTX 5090
|
export PRODUCT_NAMES=RTX 5080, RTX 5090
|
||||||
export DISCORD_ROLES=<@&12345>, <@&6789>
|
export DISCORD_ROLES=<@&12345>, <@&6789>
|
||||||
export REFRESH_TIME="60"
|
export REFRESH_TIME="60"
|
||||||
@@ -165,19 +168,19 @@ export PYTHONUNBUFFERED=1
|
|||||||
python nvidia-stock-bot.py
|
python nvidia-stock-bot.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🖼️ Screenshots
|
|
||||||
|
|
||||||
<div align="center" >
|
|
||||||
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-discord.png" alt="Nvidia Stock Bot - screenshots">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## 🐞 Common issues
|
## 🐞 Common issues
|
||||||
|
|
||||||
Error when trying to reach product API url :
|
Error when trying to reach product API url :
|
||||||
- `API_SKU_URL` may be wrong
|
- Custom `API_SKU_URL` may be wrong
|
||||||
- Your IP may be blacklisted by nvidia. Try to use a VPN.
|
- Your IP may be blacklisted by nvidia. Try to use a VPN.
|
||||||
- nvidia API may be down
|
- nvidia API may be down
|
||||||
|
|
||||||
|
## ❓ How it works
|
||||||
|
|
||||||
|
<div align="center" >
|
||||||
|
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-scheme.svg" alt="Nvidia Stock Bot - screenshots">
|
||||||
|
</div>
|
||||||
|
|
||||||
## 🧑💻 Contributors
|
## 🧑💻 Contributors
|
||||||
|
|
||||||
Thanks for their contributions:
|
Thanks for their contributions:
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import logging
|
|||||||
import json
|
import json
|
||||||
import sys
|
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
|
# Logger setup
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@@ -77,23 +79,23 @@ if match:
|
|||||||
else:
|
else:
|
||||||
wh_masked_url = "[Invalid webhook URL]"
|
wh_masked_url = "[Invalid webhook URL]"
|
||||||
|
|
||||||
# HTTP headers
|
# HTTP headers - Firefox working set
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0",
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||||
"Chrome/131.0.0.0 Safari/537.36",
|
"Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,"
|
|
||||||
"image/avif,image/webp,image/apng,*/*;q=0.8",
|
|
||||||
"Accept-Encoding": "gzip, deflate, br, zstd",
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||||
"Accept-Language": "en-US,en;q=0.5",
|
"Cache-Control": "no-cache",
|
||||||
"Cache-Control": "max-age=0",
|
"Pragma": "no-cache",
|
||||||
|
"Sec-GPC": "1",
|
||||||
"Connection": "keep-alive",
|
"Connection": "keep-alive",
|
||||||
|
"Upgrade-Insecure-Requests": "1",
|
||||||
"Sec-Fetch-Dest": "document",
|
"Sec-Fetch-Dest": "document",
|
||||||
"Sec-Fetch-Mode": "navigate",
|
"Sec-Fetch-Mode": "navigate",
|
||||||
"Sec-Fetch-Site": "none",
|
"Sec-Fetch-Site": "none",
|
||||||
"Sec-Fetch-User": "?1",
|
"Sec-Fetch-User": "?1",
|
||||||
"Upgrade-Insecure-Requests": "1",
|
"Priority": "u=0, i",
|
||||||
"Sec-GPC": "1",
|
"TE": "trailers"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load country setting and localization config
|
# Load country setting and localization config
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
import random
|
||||||
from env_config import HEADERS, PRODUCT_NAMES, API_URL_SKU, API_URL_STOCK, PRODUCT_URL
|
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 notifier import send_discord_notification, send_out_of_stock_notification, send_sku_change_notification
|
||||||
from requests.adapters import HTTPAdapter, Retry
|
from requests.adapters import HTTPAdapter, Retry
|
||||||
|
|
||||||
# HTTP session
|
# HTTP session with stealth configuration
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
|
retries = Retry(total=2, backoff_factor=3, status_forcelist=[500, 502, 503, 504, 429])
|
||||||
session.mount('https://', HTTPAdapter(max_retries=retries))
|
adapter = HTTPAdapter(max_retries=retries, pool_connections=1, pool_maxsize=1)
|
||||||
|
session.mount('https://', adapter)
|
||||||
|
session.headers.update(HEADERS)
|
||||||
|
|
||||||
# Keeping memory of last run
|
# Keeping memory of last run
|
||||||
last_sku_dict = {}
|
last_sku_dict = {}
|
||||||
@@ -18,12 +22,53 @@ first_run_dict = {name: True for name in PRODUCT_NAMES}
|
|||||||
def check_rtx_50_founders():
|
def check_rtx_50_founders():
|
||||||
global last_sku_dict, global_stock_status_dict, first_run_dict
|
global last_sku_dict, global_stock_status_dict, first_run_dict
|
||||||
|
|
||||||
|
# First get Akamai cookie by visiting main site
|
||||||
|
try:
|
||||||
|
logging.info("Getting Akamai protection cookie...")
|
||||||
|
session.get("https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/", timeout=10)
|
||||||
|
time.sleep(1) # Let the session establish
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning(f"Failed to get initial cookie: {e}")
|
||||||
|
|
||||||
# Fetching nvidia API data
|
# Fetching nvidia API data
|
||||||
try:
|
try:
|
||||||
response = session.get(API_URL_SKU, headers=HEADERS, timeout=10)
|
sku_url = API_URL_SKU
|
||||||
|
|
||||||
|
response = session.get(sku_url, timeout=10)
|
||||||
logging.info(f"SKU API response: {response.status_code}")
|
logging.info(f"SKU API response: {response.status_code}")
|
||||||
|
if response.status_code == 429:
|
||||||
|
logging.warning("Rate limited, waiting longer...")
|
||||||
|
time.sleep(random.uniform(10, 20))
|
||||||
|
return
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# Debug response content
|
||||||
|
logging.info(f"Content-Type: {response.headers.get('Content-Type')}")
|
||||||
|
logging.info(f"Content-Length: {response.headers.get('Content-Length')}")
|
||||||
|
logging.info(f"Response text length: {len(response.text)}")
|
||||||
|
logging.info(f"Response content (first 300 chars): {response.text[:300]}")
|
||||||
|
|
||||||
|
# Check if content looks like JSON
|
||||||
|
if not response.text.strip().startswith('{'):
|
||||||
|
logging.error("Response doesn't start with '{' - not JSON!")
|
||||||
|
logging.error(f"Full response: {response.text}")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"JSON decode error: {e}")
|
||||||
|
logging.error(f"Full response text: {response.text}")
|
||||||
|
return
|
||||||
|
except requests.exceptions.ReadTimeout:
|
||||||
|
logging.error("Read timeout - IP may be rate limited/blocked. Try changing IP or wait several hours.")
|
||||||
|
return
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
if "Failed to resolve" in str(e):
|
||||||
|
logging.error("DNS resolution failed - IP may be DNS blacklisted. Try VPN or different DNS servers.")
|
||||||
|
else:
|
||||||
|
logging.error(f"Connection error: {e}")
|
||||||
|
return
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logging.error(f"SKU API error: {e}")
|
logging.error(f"SKU API error: {e}")
|
||||||
return
|
return
|
||||||
@@ -34,12 +79,17 @@ def check_rtx_50_founders():
|
|||||||
for product_name in PRODUCT_NAMES:
|
for product_name in PRODUCT_NAMES:
|
||||||
product_details = None
|
product_details = None
|
||||||
for p in all_products:
|
for p in all_products:
|
||||||
if p.get("gpu", "").strip() == product_name:
|
gpu_name = p.get("gpu", "").strip()
|
||||||
|
# Flexible matching: exact match or partial match
|
||||||
|
if gpu_name == product_name or product_name in gpu_name:
|
||||||
product_details = p
|
product_details = p
|
||||||
break
|
break
|
||||||
|
|
||||||
if not product_details:
|
if not product_details:
|
||||||
logging.warning(f"⚠️ No product with GPU '{product_name}' found.")
|
logging.warning(f"⚠️ No product with GPU '{product_name}' found.")
|
||||||
|
# Debug: show available GPU names for troubleshooting
|
||||||
|
available_gpus = set(p.get("gpu", "") for p in all_products if p.get("gpu"))
|
||||||
|
logging.info(f"Available GPUs: {sorted(list(available_gpus))[:10]}") # Show first 10
|
||||||
continue
|
continue
|
||||||
|
|
||||||
product_sku = product_details['productSKU']
|
product_sku = product_details['productSKU']
|
||||||
@@ -57,12 +107,15 @@ def check_rtx_50_founders():
|
|||||||
first_run_dict[product_name] = False
|
first_run_dict[product_name] = False
|
||||||
|
|
||||||
# Check product availability in API_URL_STOCK for each SKU
|
# Check product availability in API_URL_STOCK for each SKU
|
||||||
api_stock_url = API_URL_STOCK + product_sku
|
api_stock_url = f"{API_URL_STOCK}{product_sku}"
|
||||||
logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
|
logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
|
||||||
|
|
||||||
try:
|
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}")
|
logging.info(f"[{product_name}] Stock API response: {response.status_code}")
|
||||||
|
if response.status_code == 429:
|
||||||
|
logging.warning(f"[{product_name}] Rate limited, skipping...")
|
||||||
|
continue
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
stock_data = response.json()
|
stock_data = response.json()
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
|
|||||||
BIN
assets/img/nvidia-stock-bot-discord-screenshot.png
Normal file
BIN
assets/img/nvidia-stock-bot-discord-screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 257 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 95 KiB |
5
assets/img/nvidia-stock-bot-scheme.svg
Normal file
5
assets/img/nvidia-stock-bot-scheme.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 739 KiB |
@@ -1,5 +1,3 @@
|
|||||||
PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090")
|
PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090")
|
||||||
DISCORD_WEBHOOK_URL= # Your Discord webhook URL
|
DISCORD_WEBHOOK_URL= # Your Discord webhook URL
|
||||||
API_URL_SKU= # API listing the product for your country
|
COUNTRY= # Set your country (e.g. 'US')
|
||||||
API_URL_STOCK= # API providing stock data for your country
|
|
||||||
PRODUCT_URL= # GPU purchase URL for your country
|
|
||||||
@@ -7,10 +7,7 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
# Minimal environment variables
|
# Minimal environment variables
|
||||||
- PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090")
|
- PRODUCT_NAMES=${PRODUCT_NAMES}
|
||||||
- DISCORD_WEBHOOK_URL= # Your Discord webhook URL
|
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
|
||||||
- DISCORD_NOTIFICATION_CURRENCY= # Set your country currency
|
- COUNTRY=${COUNTRY}
|
||||||
- API_URL_SKU= # API listing the product for your country
|
- PYTHONUNBUFFERED=1
|
||||||
- API_URL_STOCK= # API providing stock data for your country
|
|
||||||
- PRODUCT_URL= # GPU purchase URL for your country
|
|
||||||
- PYTHONUNBUFFERED=1 # Enables real-time log output
|
|
||||||
Reference in New Issue
Block a user