mirror of
https://github.com/plexguide/Huntarr-Sonarr.git
synced 2025-12-19 21:30:19 -06:00
update for api timeout
This commit is contained in:
@@ -1,30 +1,24 @@
|
||||
FROM python:3.9-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application files
|
||||
COPY main.py config.py api.py state.py ./
|
||||
COPY missing.py upgrade.py ./
|
||||
COPY utils/ ./utils/
|
||||
|
||||
# Create state directory
|
||||
RUN mkdir -p /tmp/huntarr-state
|
||||
|
||||
# Default environment variables
|
||||
ENV API_KEY="your-api-key" \
|
||||
API_URL="http://your-sonarr-address:8989" \
|
||||
API_TIMEOUT="60" \
|
||||
HUNT_MISSING_SHOWS=1 \
|
||||
HUNT_UPGRADE_EPISODES=5 \
|
||||
SLEEP_DURATION=900 \
|
||||
STATE_RESET_INTERVAL_HOURS=168 \
|
||||
RANDOM_SELECTION="true" \
|
||||
MONITORED_ONLY="true" \
|
||||
HUNT_MODE="both" \
|
||||
DEBUG_MODE="false"
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "main.py"]
|
||||
6
api.py
6
api.py
@@ -7,7 +7,7 @@ Handles all communication with the Sonarr API
|
||||
import requests
|
||||
from typing import List, Dict, Any, Optional, Union
|
||||
from utils.logger import logger, debug_log
|
||||
from config import API_KEY, API_URL
|
||||
from config import API_KEY, API_URL, API_TIMEOUT
|
||||
|
||||
# Create a session for reuse
|
||||
session = requests.Session()
|
||||
@@ -25,9 +25,9 @@ def sonarr_request(endpoint: str, method: str = "GET", data: Dict = None) -> Opt
|
||||
|
||||
try:
|
||||
if method.upper() == "GET":
|
||||
response = session.get(url, headers=headers, timeout=30)
|
||||
response = session.get(url, headers=headers, timeout=API_TIMEOUT)
|
||||
elif method.upper() == "POST":
|
||||
response = session.post(url, headers=headers, json=data, timeout=30)
|
||||
response = session.post(url, headers=headers, json=data, timeout=API_TIMEOUT)
|
||||
else:
|
||||
logger.error(f"Unsupported HTTP method: {method}")
|
||||
return None
|
||||
|
||||
@@ -11,6 +11,13 @@ import logging
|
||||
API_KEY = os.environ.get("API_KEY", "your-api-key")
|
||||
API_URL = os.environ.get("API_URL", "http://your-sonarr-address:8989")
|
||||
|
||||
# API timeout in seconds
|
||||
try:
|
||||
API_TIMEOUT = int(os.environ.get("API_TIMEOUT", "60"))
|
||||
except ValueError:
|
||||
API_TIMEOUT = 60
|
||||
print(f"Warning: Invalid API_TIMEOUT value, using default: {API_TIMEOUT}")
|
||||
|
||||
# Missing Content Settings
|
||||
try:
|
||||
HUNT_MISSING_SHOWS = int(os.environ.get("HUNT_MISSING_SHOWS", "1"))
|
||||
@@ -53,6 +60,7 @@ def log_configuration(logger):
|
||||
"""Log the current configuration settings"""
|
||||
logger.info("=== Huntarr [Sonarr Edition] Starting ===")
|
||||
logger.info(f"API URL: {API_URL}")
|
||||
logger.info(f"API Timeout: {API_TIMEOUT}s")
|
||||
logger.info(f"Missing Content Configuration: HUNT_MISSING_SHOWS={HUNT_MISSING_SHOWS}")
|
||||
logger.info(f"Upgrade Configuration: HUNT_UPGRADE_EPISODES={HUNT_UPGRADE_EPISODES}")
|
||||
logger.info(f"State Reset Interval: {STATE_RESET_INTERVAL_HOURS} hours")
|
||||
|
||||
Reference in New Issue
Block a user