Imported RoyalRoad chapter checker, changed it to use FastAPI with metrics and uses their RSS feed instead of scraping with the FanFicFare module

This commit is contained in:
florian committed 2025-10-09 21:42:38 +02:00
1 parent 4ebf3c1df8
commit 36a8767349
7 files changed
+263

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import requests
from requests.exceptions import RequestException, Timeout, ConnectionError, HTTPError
from secret_handler import return_credentials
import os
backend_api_url=os.getenv("BACKEND_API_URL","localhost:8101/internal/receive-notifications")
api_key= return_credentials("/etc/secrets/api_key")
def send_notification(title:str,chapter:int, link:str):
headers = {
"X-API-Key-Internal": backend_api_url,
"Content-Type": "application/json"
}
data = {
"receipent_user_id": 1,
"message": {
"title": title,
"info": f"Chapter {chapter} has been released",
"link": link
}}
try:
response = requests.post(backend_api_url, headers=headers, json=data)
response.raise_for_status()
print("Success: Notification sent")
except Timeout:
print("Error: request timed out")
except ConnectionError:
print("Error: connection failed")
except HTTPError as e:
print(f"HTTP error: {e.response.status_code} - {e.response.text}")
except RequestException as e:
print("Request failed:", str(e))