This commit is contained in:
+36
-8
@@ -2300,10 +2300,10 @@ def register_routes(app, dependencies: dict):
|
||||
# Scan episodes
|
||||
print("📺 Scanning episodes for missing dateadded elements")
|
||||
episode_query = """
|
||||
SELECT DISTINCT e.imdb_id, e.season, e.episode, s.path as series_path, e.dateadded
|
||||
SELECT DISTINCT e.imdb_id, e.season, e.episode, s.path as series_path, e.dateadded, e.has_video_file
|
||||
FROM episodes e
|
||||
JOIN series s ON e.imdb_id = s.imdb_id
|
||||
WHERE e.dateadded IS NOT NULL
|
||||
WHERE e.has_video_file = TRUE
|
||||
ORDER BY e.imdb_id, e.season, e.episode
|
||||
"""
|
||||
|
||||
@@ -2330,7 +2330,8 @@ def register_routes(app, dependencies: dict):
|
||||
root = tree.getroot()
|
||||
dateadded_elem = root.find("dateadded")
|
||||
|
||||
if dateadded_elem is None or not dateadded_elem.text:
|
||||
# NFO file is missing dateadded element
|
||||
if dateadded_elem is None or not dateadded_elem.text or not dateadded_elem.text.strip():
|
||||
missing_items["episodes"].append({
|
||||
"imdb_id": episode["imdb_id"],
|
||||
"season": episode["season"],
|
||||
@@ -2338,7 +2339,8 @@ def register_routes(app, dependencies: dict):
|
||||
"series_name": series_name,
|
||||
"series_path": episode["series_path"],
|
||||
"dateadded": episode["dateadded"],
|
||||
"nfo_path": nfo_path
|
||||
"nfo_path": nfo_path,
|
||||
"reason": "NFO missing dateadded element"
|
||||
})
|
||||
except ET.ParseError as e:
|
||||
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
@@ -2352,13 +2354,26 @@ def register_routes(app, dependencies: dict):
|
||||
"nfo_path": nfo_path,
|
||||
"error": f"Parse error: {str(e)}"
|
||||
})
|
||||
else:
|
||||
# NFO file doesn't exist at all
|
||||
if episode["has_video_file"]:
|
||||
missing_items["episodes"].append({
|
||||
"imdb_id": episode["imdb_id"],
|
||||
"season": episode["season"],
|
||||
"episode": episode["episode"],
|
||||
"series_name": series_name,
|
||||
"series_path": episode["series_path"],
|
||||
"dateadded": episode["dateadded"],
|
||||
"nfo_path": nfo_path,
|
||||
"reason": "NFO file does not exist"
|
||||
})
|
||||
|
||||
# Scan movies
|
||||
print("🎬 Scanning movies for missing dateadded elements")
|
||||
movie_query = """
|
||||
SELECT DISTINCT imdb_id, path, dateadded
|
||||
SELECT DISTINCT imdb_id, path, dateadded, has_video_file
|
||||
FROM movies
|
||||
WHERE dateadded IS NOT NULL
|
||||
WHERE has_video_file = TRUE
|
||||
ORDER BY path
|
||||
"""
|
||||
|
||||
@@ -2384,13 +2399,15 @@ def register_routes(app, dependencies: dict):
|
||||
root = tree.getroot()
|
||||
dateadded_elem = root.find("dateadded")
|
||||
|
||||
if dateadded_elem is None or not dateadded_elem.text:
|
||||
# NFO file is missing dateadded element
|
||||
if dateadded_elem is None or not dateadded_elem.text or not dateadded_elem.text.strip():
|
||||
missing_items["movies"].append({
|
||||
"imdb_id": movie["imdb_id"],
|
||||
"title": movie_title,
|
||||
"path": movie["path"],
|
||||
"dateadded": movie["dateadded"],
|
||||
"nfo_path": nfo_path
|
||||
"nfo_path": nfo_path,
|
||||
"reason": "NFO missing dateadded element"
|
||||
})
|
||||
except ET.ParseError as e:
|
||||
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
@@ -2402,6 +2419,17 @@ def register_routes(app, dependencies: dict):
|
||||
"nfo_path": nfo_path,
|
||||
"error": f"Parse error: {str(e)}"
|
||||
})
|
||||
else:
|
||||
# NFO file doesn't exist at all
|
||||
if movie["has_video_file"]:
|
||||
missing_items["movies"].append({
|
||||
"imdb_id": movie["imdb_id"],
|
||||
"title": movie_title,
|
||||
"path": movie["path"],
|
||||
"dateadded": movie["dateadded"],
|
||||
"nfo_path": nfo_path,
|
||||
"reason": "NFO file does not exist"
|
||||
})
|
||||
|
||||
total_missing = len(missing_items["episodes"]) + len(missing_items["movies"])
|
||||
print(f"✅ NFO repair scan complete: {total_missing} items missing dateadded elements")
|
||||
|
||||
Reference in New Issue
Block a user