This commit is contained in:
+22
-19
@@ -2300,10 +2300,11 @@ def register_routes(app, dependencies: dict):
|
|||||||
# Scan episodes
|
# Scan episodes
|
||||||
print("📺 Scanning episodes for missing dateadded elements")
|
print("📺 Scanning episodes for missing dateadded elements")
|
||||||
episode_query = """
|
episode_query = """
|
||||||
SELECT DISTINCT imdb_id, season, episode, series_name, episode_name, dateadded
|
SELECT DISTINCT e.imdb_id, e.season, e.episode, s.path as series_path, e.dateadded
|
||||||
FROM episodes
|
FROM episodes e
|
||||||
WHERE dateadded IS NOT NULL
|
JOIN series s ON e.imdb_id = s.imdb_id
|
||||||
ORDER BY imdb_id, season, episode
|
WHERE e.dateadded IS NOT NULL
|
||||||
|
ORDER BY e.imdb_id, e.season, e.episode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with db.get_connection() as conn:
|
with db.get_connection() as conn:
|
||||||
@@ -2314,10 +2315,10 @@ def register_routes(app, dependencies: dict):
|
|||||||
print(f"📊 Found {len(episodes)} episodes in database")
|
print(f"📊 Found {len(episodes)} episodes in database")
|
||||||
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# Build NFO path
|
# Build NFO path using series path
|
||||||
|
series_name = os.path.basename(episode["series_path"])
|
||||||
nfo_path = os.path.join(
|
nfo_path = os.path.join(
|
||||||
config.tv_library_path,
|
episode["series_path"],
|
||||||
episode["series_name"],
|
|
||||||
f"Season {episode['season']:02d}",
|
f"Season {episode['season']:02d}",
|
||||||
f"S{episode['season']:02d}E{episode['episode']:02d}.nfo"
|
f"S{episode['season']:02d}E{episode['episode']:02d}.nfo"
|
||||||
)
|
)
|
||||||
@@ -2334,8 +2335,8 @@ def register_routes(app, dependencies: dict):
|
|||||||
"imdb_id": episode["imdb_id"],
|
"imdb_id": episode["imdb_id"],
|
||||||
"season": episode["season"],
|
"season": episode["season"],
|
||||||
"episode": episode["episode"],
|
"episode": episode["episode"],
|
||||||
"series_name": episode["series_name"],
|
"series_name": series_name,
|
||||||
"episode_name": episode["episode_name"],
|
"series_path": episode["series_path"],
|
||||||
"dateadded": episode["dateadded"],
|
"dateadded": episode["dateadded"],
|
||||||
"nfo_path": nfo_path
|
"nfo_path": nfo_path
|
||||||
})
|
})
|
||||||
@@ -2345,8 +2346,8 @@ def register_routes(app, dependencies: dict):
|
|||||||
"imdb_id": episode["imdb_id"],
|
"imdb_id": episode["imdb_id"],
|
||||||
"season": episode["season"],
|
"season": episode["season"],
|
||||||
"episode": episode["episode"],
|
"episode": episode["episode"],
|
||||||
"series_name": episode["series_name"],
|
"series_name": series_name,
|
||||||
"episode_name": episode["episode_name"],
|
"series_path": episode["series_path"],
|
||||||
"dateadded": episode["dateadded"],
|
"dateadded": episode["dateadded"],
|
||||||
"nfo_path": nfo_path,
|
"nfo_path": nfo_path,
|
||||||
"error": f"Parse error: {str(e)}"
|
"error": f"Parse error: {str(e)}"
|
||||||
@@ -2355,10 +2356,10 @@ def register_routes(app, dependencies: dict):
|
|||||||
# Scan movies
|
# Scan movies
|
||||||
print("🎬 Scanning movies for missing dateadded elements")
|
print("🎬 Scanning movies for missing dateadded elements")
|
||||||
movie_query = """
|
movie_query = """
|
||||||
SELECT DISTINCT imdb_id, title, dateadded
|
SELECT DISTINCT imdb_id, path, dateadded
|
||||||
FROM movies
|
FROM movies
|
||||||
WHERE dateadded IS NOT NULL
|
WHERE dateadded IS NOT NULL
|
||||||
ORDER BY title
|
ORDER BY path
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with db.get_connection() as conn:
|
with db.get_connection() as conn:
|
||||||
@@ -2369,11 +2370,11 @@ def register_routes(app, dependencies: dict):
|
|||||||
print(f"📊 Found {len(movies)} movies in database")
|
print(f"📊 Found {len(movies)} movies in database")
|
||||||
|
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
# Build NFO path
|
# Build NFO path using movie path
|
||||||
|
movie_title = os.path.basename(movie["path"])
|
||||||
nfo_path = os.path.join(
|
nfo_path = os.path.join(
|
||||||
config.movie_library_path,
|
movie["path"],
|
||||||
movie["title"],
|
f"{movie_title}.nfo"
|
||||||
f"{movie['title']}.nfo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if NFO file exists and has dateadded
|
# Check if NFO file exists and has dateadded
|
||||||
@@ -2386,7 +2387,8 @@ def register_routes(app, dependencies: dict):
|
|||||||
if dateadded_elem is None or not dateadded_elem.text:
|
if dateadded_elem is None or not dateadded_elem.text:
|
||||||
missing_items["movies"].append({
|
missing_items["movies"].append({
|
||||||
"imdb_id": movie["imdb_id"],
|
"imdb_id": movie["imdb_id"],
|
||||||
"title": movie["title"],
|
"title": movie_title,
|
||||||
|
"path": movie["path"],
|
||||||
"dateadded": movie["dateadded"],
|
"dateadded": movie["dateadded"],
|
||||||
"nfo_path": nfo_path
|
"nfo_path": nfo_path
|
||||||
})
|
})
|
||||||
@@ -2394,7 +2396,8 @@ def register_routes(app, dependencies: dict):
|
|||||||
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||||
missing_items["movies"].append({
|
missing_items["movies"].append({
|
||||||
"imdb_id": movie["imdb_id"],
|
"imdb_id": movie["imdb_id"],
|
||||||
"title": movie["title"],
|
"title": movie_title,
|
||||||
|
"path": movie["path"],
|
||||||
"dateadded": movie["dateadded"],
|
"dateadded": movie["dateadded"],
|
||||||
"nfo_path": nfo_path,
|
"nfo_path": nfo_path,
|
||||||
"error": f"Parse error: {str(e)}"
|
"error": f"Parse error: {str(e)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user