15 Commits

Author SHA1 Message Date
dfa3a5e19c In english 2025-03-26 15:38:46 +00:00
cdbb1be864 Minor change 2025-03-26 12:01:31 +00:00
3ed38e7aa3 badge license 2025-03-26 12:01:12 +00:00
c392efce35 Ajout license 2025-03-26 11:55:09 +00:00
2761a9dacb License 2025-03-26 11:53:23 +00:00
006531aacc Maj intro 2025-03-14 15:12:40 +00:00
a8d4c05c81 Fix python section 2025-03-14 15:08:30 +00:00
280e8d0347 Maj schema 2025-03-14 15:05:06 +00:00
53c46b1d2f WIP to MAIN 2025-03-14 12:02:54 +00:00
5b1e180c6f Minor changes 2025-03-14 11:51:48 +00:00
7872f8aa00 Fixed sku notif 2025-03-14 11:33:50 +00:00
23b2f375fc Minor fixes 2025-03-14 11:21:56 +00:00
62bc725a1c Fixed coma 2025-03-14 11:04:57 +00:00
b381efd257 Readme 2025-03-14 10:55:41 +00:00
037f5bebf8 SKU changes & better notif 2025-03-14 10:53:59 +00:00
5 changed files with 129 additions and 17 deletions

14
LICENSE Normal file
View File

@ -0,0 +1,14 @@
Non-Profit Open Software License 3.0 (NPOSL-3.0)
Copyright (C) 2025 Djeex - Nvidia Stock Bot
The NPOSL-3.0 is a free and open-source license, but it has restrictions.
You are allowed to:
- Use, copy, and modify the software for non-commercial purposes.
- Distribute the software, provided it remains free and non-commercial.
You are not allowed to:
- Use the software for commercial purposes.
- Modify the software and redistribute it under another license.
Full text of the license can be found at: https://sourceforge.net/p/npdl/wiki/NPOSL_3_0/

View File

@ -1,9 +1,13 @@
# Nvidia Stock Bot # Nvidia Stock Bot
Par KevOut & Djeex Par KevOut & Djeex
[![](https://img.shields.io/badge/JV%20hardware-rejoindre-green?style=flat-square&logo=discord&logoColor=%23fff&label=JV%20hardware&link=https%3A%2F%2Fdiscord.gg%2Fgxffg3GA96)](https://discord.gg/gxffg3GA96) *Ce projet est protégé par la license Non-Profit Open Software License 3.0 (NPOSL-3.0)*
[![](https://img.shields.io/badge/JV%20hardware-rejoindre-green?style=flat-square&logo=discord&logoColor=%23fff&label=JV%20hardware&link=https%3A%2F%2Fdiscord.gg%2Fgxffg3GA96)](https://discord.gg/gxffg3GA96) ![Licence: NPOSL-3.0](https://img.shields.io/badge/license-NPOSL--3.0-blue?style=flat-square&)
Bot qui permet d'être alerté des stocks de Nvidia RTX FE.
Ce robot : Ce robot :
- Appelle l'API de Nvidia listant le produit (par défaut toutes les 60s) - Appelle l'API de Nvidia listant le produit (par défaut toutes les 60s)
- Récupère le SKU du produit concerné - Récupère le SKU du produit concerné
@ -11,6 +15,7 @@ Ce robot :
- Si du stock est trouvé, envoie une notification discord via le webhook paramétré - Si du stock est trouvé, envoie une notification discord via le webhook paramétré
- Si le produit était déjà en stock, il n'envoie plus de notification - Si le produit était déjà en stock, il n'envoie plus de notification
- Si le produit était en stock mais ne l'est plus, envoie une notification discord signifiant la fin du stock - Si le produit était en stock mais ne l'est plus, envoie une notification discord signifiant la fin du stock
- Si le SKU change, une notification est envoyée alertant de l'éventuelle imminence du drop
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvbot.png" align="center"> <img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvbot.png" align="center">
@ -77,6 +82,8 @@ services:
- REFRESH_TIME= # Durée de rafraichissement du script en secondes - REFRESH_TIME= # Durée de rafraichissement du script en secondes
- API_URL_SKU= # API listant le produit par exemple https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205090 - API_URL_SKU= # API listant le produit par exemple https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205090
- API_URL_STOCK= # API appelant le stock sans préciser la valeur du sku, par exemple https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus= - API_URL_STOCK= # API appelant le stock sans préciser la valeur du sku, par exemple https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=
- PRODUCT_URL= # URL d'achat du GPU
- PRODUCT_NAME= #Le nom du GPU qui s'affiche dans les notifications
- TEST_MODE= #true pour tester les notifications discord. false par défaut. - TEST_MODE= #true pour tester les notifications discord. false par défaut.
- PYTHONUNBUFFERED=1 # Permet d'afficher les logs en temps réel - PYTHONUNBUFFERED=1 # Permet d'afficher les logs en temps réel
command: python nvidia-stock-bot.py # Lance le script Python au démarrage du conteneur command: python nvidia-stock-bot.py # Lance le script Python au démarrage du conteneur
@ -105,8 +112,10 @@ Vous trouverez ci-dessous comment exécuter directement le script Python. Avec c
```sh ```sh
export DISCORD_WEBHOOK_URL="https://votre_url_discord" export DISCORD_WEBHOOK_URL="https://votre_url_discord"
export REFRESH_TIME="60" export REFRESH_TIME="60"
export API_URL_SKU="https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205090" export API_URL_SKU="https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205080"
export API_URL_STOCK="https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=" export API_URL_STOCK="https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus="
export PRODUCT_URL= "https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205080&manufacturer=NVIDIA"
export PRODUCT_NAME="RTX 5080"
export TEST_MODE=false export TEST_MODE=false
``` ```
- Lancez le script - Lancez le script

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 4.8 MiB

View File

@ -2,3 +2,5 @@ DS_HOOK= #votre url du webhook Discord
FREQ= #frequence de rafraichissement en secondes FREQ= #frequence de rafraichissement en secondes
API_URL_SKU= # API listant le produit par exemple https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205090 API_URL_SKU= # API listant le produit par exemple https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205090
API_URL_STOCK= # API appelant le stock sans préciser la valeur du sku, par exemple https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus= API_URL_STOCK= # API appelant le stock sans préciser la valeur du sku, par exemple https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=
PRODUCT_URL= # URL d'achat du GPU
PRODUCT_NAME= #Le nom du GPU qui s'affiche dans les notifications

View File

@ -19,6 +19,8 @@ try:
API_URL_STOCK = os.environ['API_URL_STOCK'] API_URL_STOCK = os.environ['API_URL_STOCK']
REFRESH_TIME = int(os.environ['REFRESH_TIME']) # Convertir en entier REFRESH_TIME = int(os.environ['REFRESH_TIME']) # Convertir en entier
TEST_MODE = os.environ.get('TEST_MODE', 'False').lower() == 'true' TEST_MODE = os.environ.get('TEST_MODE', 'False').lower() == 'true'
PRODUCT_URL = os.environ['PRODUCT_URL']
PRODUCT_NAME = os.environ['PRODUCT_NAME']
# Regex pour extraire l'ID et le token # Regex pour extraire l'ID et le token
match = re.search(r'/(\d+)/(.*)', DISCORD_WEBHOOK_URL) match = re.search(r'/(\d+)/(.*)', DISCORD_WEBHOOK_URL)
@ -43,12 +45,15 @@ except ValueError:
exit(1) exit(1)
# Affichage des URLs et configurations # Affichage des URLs et configurations
logging.info(f"GPU: {PRODUCT_NAME}")
logging.info(f"URL Webhook Discord: {wh_masked_url}") logging.info(f"URL Webhook Discord: {wh_masked_url}")
logging.info(f"URL API SKU: {API_URL_SKU}") logging.info(f"URL API SKU: {API_URL_SKU}")
logging.info(f"URL API Stock: {API_URL_STOCK}") logging.info(f"URL API Stock: {API_URL_STOCK}")
logging.info(f"URL produit: {PRODUCT_URL}")
logging.info(f"Temps d'actualisation: {REFRESH_TIME} secondes") logging.info(f"Temps d'actualisation: {REFRESH_TIME} secondes")
logging.info(f"Mode Test: {TEST_MODE}") logging.info(f"Mode Test: {TEST_MODE}")
# Entêtes HTTP # Entêtes HTTP
HEADERS = { HEADERS = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
@ -76,19 +81,26 @@ session.mount('https://', HTTPAdapter(max_retries=retries))
# Stockage de l'état des stocks # Stockage de l'état des stocks
global_stock_status = {} global_stock_status = {}
# Stocke le dernier SKU connu
last_sku = None
first_run = True # Before calling check_rtx_50_founders
# Notifications Discord # Notifications Discord
def send_discord_notification(gpu_name: str, product_link: str, products_price: str): def send_discord_notification(gpu_name: str, product_link: str, products_price: str):
# Récupérer le timestamp UNIX actuel
timestamp_unix = int(time.time())
if TEST_MODE: if TEST_MODE:
logging.info(f"[TEST MODE] Notification Discord: {gpu_name} disponible !") logging.info(f"[TEST MODE] Notification Discord: {gpu_name} disponible !")
return return
embed = { embed = {
"title": f"🚀 {gpu_name} EN STOCK !", "title": f"🚀 {PRODUCT_NAME} EN STOCK !",
"color": 3066993, "color": 3066993,
"thumbnail": { "thumbnail": {
"url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg" "url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
}, },
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
"author": { "author": {
"name": "Nvidia Founder Editions" "name": "Nvidia Founder Editions"
}, },
@ -96,11 +108,17 @@ def send_discord_notification(gpu_name: str, product_link: str, products_price:
"fields": [ "fields": [
{ {
"name": "Prix", "name": "Prix",
"value": f"`{products_price} €`", "value": f"`{products_price}€`",
"inline": True "inline": True
} },
{
"name": "Heure",
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
},
], ],
"description": "**:point_right: [Acheter maintenant](https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205090,RTX%205080)**", "description": f"**:point_right: [Acheter maintenant]({product_link})**",
"footer": { "footer": {
"text": "Par KevOut & Djeex" "text": "Par KevOut & Djeex"
} }
@ -116,25 +134,35 @@ def send_discord_notification(gpu_name: str, product_link: str, products_price:
logging.error(f"🚨 Erreur lors de l'envoi du webhook : {e}") logging.error(f"🚨 Erreur lors de l'envoi du webhook : {e}")
def send_out_of_stock_notification(gpu_name: str, product_link: str, products_price: str): def send_out_of_stock_notification(gpu_name: str, product_link: str, products_price: str):
# Récupérer le timestamp UNIX actuel
timestamp_unix = int(time.time())
if TEST_MODE: if TEST_MODE:
logging.info(f"[TEST MODE] Notification Discord: {gpu_name} hors stock !") logging.info(f"[TEST MODE] Notification Discord: {gpu_name} hors stock !")
return return
embed = { embed = {
"title": f"{gpu_name} n'est plus en stock", "title": f"{PRODUCT_NAME} n'est plus en stock",
"description": f":disappointed_relieved:",
"color": 15158332, # Rouge pour hors stock "color": 15158332, # Rouge pour hors stock
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
"thumbnail": { "thumbnail": {
"url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg" "url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
}, },
"url": "https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205090,RTX%205080", "url": f"{product_link}",
"author": { "author": {
"name": "Nvidia Founder Editions" "name": "Nvidia Founder Editions"
}, },
"footer": { "footer": {
"text": "Par KevOut & Djeex" "text": "Par KevOut & Djeex"
} },
"fields": [
{
"name": "Heure",
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
}
]
} }
payload = {"username": "NviBot", "avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000_pp.jpg", "embeds": [embed]} payload = {"username": "NviBot", "avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000_pp.jpg", "embeds": [embed]}
try: try:
@ -146,20 +174,79 @@ def send_out_of_stock_notification(gpu_name: str, product_link: str, products_pr
except Exception as e: except Exception as e:
logging.error(f"🚨 Erreur lors de l'envoi du webhook : {e}") logging.error(f"🚨 Erreur lors de l'envoi du webhook : {e}")
def send_sku_change_notification(old_sku: str, new_sku: str, product_link: str):
# Récupérer le timestamp UNIX actuel
timestamp_unix = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] Changement de SKU détecté : {old_sku}{new_sku}")
return
embed = {
"title": f"🔄 {PRODUCT_NAME} Changement de SKU détecté",
"url": f"{product_link}",
"description": f"**Ancien SKU** : `{old_sku}`\n**Nouveau SKU** : `{new_sku}`",
"color": 16776960, # Jaune
"footer": {
"text": "Par KevOut & Djeex"
},
"fields": [
{
"name": "Heure",
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
}
]
}
payload = {
"content": "@everyone ⚠️ Potentiel drop imminent !",
"username": "NviBot",
"avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000_pp.jpg",
"embeds": [embed]
}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ Notification de changement de SKU envoyée sur Discord.")
else:
logging.error(f"❌ Erreur Webhook : {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Erreur lors de l'envoi du webhook : {e}")
# Recherche du stock # Recherche du stock
def check_rtx_50_founders(): def check_rtx_50_founders():
global global_stock_status global global_stock_status, last_sku, first_run
# Appel vers l'API produit pour récupérer le sku et l'upc # Appel vers l'API produit pour récupérer le sku et l'upc
try: try:
response = session.get(API_URL_SKU, headers=HEADERS, timeout=10) response = session.get(API_URL_SKU, headers=HEADERS, timeout=10)
logging.info(f"Réponse de l'API : {response.status_code}") logging.info(f"Réponse de l'API SKU : {response.status_code}")
response.raise_for_status() response.raise_for_status()
data = response.json() data = response.json()
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
logging.error(f"Erreur API SKU : {e}") logging.error(f"Erreur API SKU : {e}")
return return
product_details = data['searchedProducts']['productDetails'][0]
product_sku = product_details['productSKU']
# Vérifier si c'est la première exécution
if last_sku is not None and product_sku != last_sku:
if not first_run: # Évite d'envoyer une notification au premier appel
product_link = PRODUCT_URL
logging.warning(f"⚠️ SKU modifié : {last_sku}{product_sku}")
send_sku_change_notification(last_sku, product_sku, product_link)
# Mettre à jour le SKU stocké
last_sku = product_sku
first_run = False # Désactive la protection après la première exécution
product_details = data['searchedProducts']['productDetails'][0] product_details = data['searchedProducts']['productDetails'][0]
product_sku = product_details['productSKU'] product_sku = product_details['productSKU']
product_upc = product_details.get('productUPC', "") product_upc = product_details.get('productUPC', "")
@ -207,12 +294,12 @@ def check_rtx_50_founders():
previously_in_stock = global_stock_status.get(gpu_upper, False) previously_in_stock = global_stock_status.get(gpu_upper, False)
if currently_in_stock and not previously_in_stock: if currently_in_stock and not previously_in_stock:
product_link = "https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205090,RTX%205080" product_link = PRODUCT_URL
send_discord_notification(gpu_upper, product_link, products_price) send_discord_notification(gpu_upper, product_link, products_price)
global_stock_status[gpu_upper] = True global_stock_status[gpu_upper] = True
logging.info(f"{gpu} est maintenant en stock!") logging.info(f"{gpu} est maintenant en stock!")
elif not currently_in_stock and previously_in_stock: elif not currently_in_stock and previously_in_stock:
product_link = "https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205090,RTX%205080" product_link = PRODUCT_URL
send_out_of_stock_notification(gpu_upper, product_link, products_price) send_out_of_stock_notification(gpu_upper, product_link, products_price)
global_stock_status[gpu_upper] = False global_stock_status[gpu_upper] = False
logging.info(f"{gpu} n'est plus en stock.") logging.info(f"{gpu} n'est plus en stock.")