This commit is contained in:
2025-09-07 12:34:49 -04:00
parent 5274c06223
commit 3e8774b285
2 changed files with 18 additions and 8 deletions
+17 -7
View File
@@ -264,12 +264,17 @@ class RadarrClient:
url = urljoin(self.base_url, path.lstrip("?").lstrip("/"))
if params:
url = url + ("&" if "?" in url else "?") + urlencode(params)
_log("DEBUG", f"Radarr API Request: {url}")
req = UrlRequest(url, headers={"Accept": "application/json"})
with urlopen(req, timeout=self.timeout) as resp:
data = resp.read().decode("utf-8")
return json.loads(data)
result = json.loads(data)
_log("DEBUG", f"Radarr API Response: {json.dumps(result, indent=2) if isinstance(result, (dict, list)) else result}")
return result
except (URLError, HTTPError, json.JSONDecodeError) as e:
last_err = e
_log("DEBUG", f"Radarr API attempt {attempt + 1} failed: {e}")
time.sleep(min(2 ** attempt, 5))
attempt += 1
_log("WARNING", f"Radarr GET {path} failed after retries: {last_err}")
@@ -893,19 +898,24 @@ def set_movie_file_mtime(movie_dir: Path, dateadded_iso: str):
return
try:
ts = datetime.fromisoformat(dateadded_iso.replace("Z", "+00:00")).timestamp()
video_exts = (".mkv", ".mp4", ".avi", ".mov", ".m4v")
# Update ALL files in the directory to the correct timestamp
files_updated = 0
for f in movie_dir.iterdir():
if f.is_file() and f.suffix.lower() in video_exts:
if f.is_file():
try:
os.utime(f, (ts, ts), follow_symlinks=False)
_log("DEBUG", f"Updated movie file mtime: {f} -> {dateadded_iso}")
files_updated += 1
_log("DEBUG", f"Updated file mtime: {f.name} -> {dateadded_iso}")
except Exception as e:
_log("WARNING", f"Failed to update mtime on {f}: {e}")
_log("WARNING", f"Failed to update mtime on {f.name}: {e}")
# Update directory timestamp
try:
os.utime(movie_dir, (ts, ts), follow_symlinks=False)
_log("DEBUG", f"Updated movie dir mtime: {movie_dir} -> {dateadded_iso}")
_log("INFO", f"Updated {files_updated} files and directory mtime: {movie_dir.name} -> {dateadded_iso}")
except Exception as e:
_log("WARNING", f"Failed to update mtime on {movie_dir}: {e}")
_log("WARNING", f"Failed to update mtime on directory {movie_dir}: {e}")
except Exception as e:
_log("WARNING", f"Bad timestamp for movie mtimes: {dateadded_iso}: {e}")