fix: db not filling in .nfo data
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-15 07:56:56 -04:00
parent 66ba17991e
commit 0dfc296bf4
7 changed files with 231 additions and 15 deletions
+26 -1
View File
@@ -4,6 +4,7 @@ Handles TV series processing and episode management with async I/O support
"""
import os
import re
import time
import asyncio
from pathlib import Path
from typing import Optional, Dict, List, Set, Tuple, Any
@@ -71,9 +72,12 @@ class TVProcessor:
# Get episode dates
episode_dates = self._gather_episode_dates(series_path, imdb_id, disk_episodes)
# Process episodes
# Process episodes with periodic yielding for non-blocking operation
episode_count = 0
for (season, episode), (aired, dateadded, source) in episode_dates.items():
if (season, episode) in disk_episodes:
episode_count += 1
# Create NFO
if config.manage_nfo:
season_dir = series_path / config.tv_season_dir_format.format(season=season)
@@ -90,6 +94,12 @@ class TVProcessor:
# Save to database
self.db.upsert_episode_date(imdb_id, season, episode, aired, dateadded, source, True)
# Yield control every 10 episodes to allow other requests (webhooks, web interface)
if episode_count % 10 == 0:
# Note: Since this is sync method, we can't use asyncio.sleep()
# This will require making process_series async or adding yield points in caller
pass
# Skip season.nfo and tvshow.nfo creation - focus only on episode NFOs
pass
@@ -238,6 +248,7 @@ class TVProcessor:
episode_map = {}
api_calls_made = 0
episodes_processed = 0
for episode in episodes:
season = episode.get('seasonNumber', 0)
@@ -248,6 +259,8 @@ class TVProcessor:
continue
if season > 0 and episode_num > 0:
episodes_processed += 1
# Get basic episode info
episode_data = {
'airDate': episode.get('airDate'),
@@ -262,6 +275,12 @@ class TVProcessor:
if import_date:
episode_data['dateAdded'] = import_date
_log("DEBUG", f"Got import date from history for S{season:02d}E{episode_num:02d}: {import_date}")
# Yield control every 5 API calls to allow other requests
if api_calls_made % 5 == 0:
import time
time.sleep(0.01) # 10ms yield to other processes
_log("DEBUG", f"Yielded after {api_calls_made} Sonarr API calls to allow other requests...")
# Fallback to episodeFile.dateAdded if history didn't work
if not episode_data['dateAdded'] and episode.get('hasFile'):
@@ -271,6 +290,12 @@ class TVProcessor:
_log("DEBUG", f"Got file date for S{season:02d}E{episode_num:02d}: {file_date}")
episode_map[(season, episode_num)] = episode_data
# Also yield control every 20 episodes processed to prevent blocking
if episodes_processed % 20 == 0:
import time
time.sleep(0.01) # 10ms yield for large episode lists
_log("DEBUG", f"Processed {episodes_processed} episodes, yielding to allow other requests...")
if filter_set:
_log("DEBUG", f"Made {api_calls_made} Sonarr history API calls for filtered episodes (instead of all episodes)")