This commit is contained in:
+17
-10
@@ -14,6 +14,7 @@ from core.database import NFOGuardDatabase
|
||||
from core.nfo_manager import NFOManager
|
||||
from core.path_mapper import PathMapper
|
||||
from core.logging import _log
|
||||
from core.fs_cache import fs_cache, parse_episode_from_filename, extract_imdb_from_path
|
||||
from clients.sonarr_client import SonarrClient
|
||||
from clients.external_clients import ExternalClientManager
|
||||
from config.settings import config
|
||||
@@ -123,7 +124,10 @@ class TVProcessor:
|
||||
disk_episodes = {}
|
||||
video_exts = (".mkv", ".mp4", ".avi", ".mov", ".m4v")
|
||||
|
||||
for season_dir in series_path.iterdir():
|
||||
# Use cached directory listing
|
||||
season_dirs = fs_cache.get_directory_contents(series_path)
|
||||
|
||||
for season_dir in season_dirs:
|
||||
if not (season_dir.is_dir() and season_dir.name.lower().startswith(config.tv_season_dir_pattern)):
|
||||
continue
|
||||
|
||||
@@ -140,15 +144,18 @@ class TVProcessor:
|
||||
except (ValueError, IndexError):
|
||||
continue
|
||||
|
||||
for video_file in season_dir.iterdir():
|
||||
if video_file.is_file() and video_file.suffix.lower() in video_exts:
|
||||
match = re.search(r"S(\d{2})E(\d{2})", video_file.name, re.IGNORECASE)
|
||||
if match:
|
||||
file_season, file_episode = int(match.group(1)), int(match.group(2))
|
||||
key = (season_num, file_episode) # Use directory season number
|
||||
if key not in disk_episodes:
|
||||
disk_episodes[key] = []
|
||||
disk_episodes[key].append(video_file)
|
||||
# Use cached video file discovery
|
||||
video_files = fs_cache.find_video_files(season_dir)
|
||||
|
||||
for video_file in video_files:
|
||||
# Use cached episode parsing
|
||||
episode_info = parse_episode_from_filename(video_file.name)
|
||||
if episode_info:
|
||||
file_season, file_episode = episode_info
|
||||
key = (season_num, file_episode) # Use directory season number
|
||||
if key not in disk_episodes:
|
||||
disk_episodes[key] = []
|
||||
disk_episodes[key].append(video_file)
|
||||
|
||||
return disk_episodes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user