From ed3d7e903ce3722f1ac841c519da33ad015cfe69 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Sun, 26 Oct 2025 15:54:01 -0400 Subject: [PATCH] nfo: improvments --- api/routes.py | 34 +++++++++++++++--- api/web_routes.py | 8 +++-- nfoguard-web/static/css/styles.css | 57 ++++++++++++++++++++++++++++++ nfoguard-web/static/js/app.js | 34 ++++++++++++++---- 4 files changed, 121 insertions(+), 12 deletions(-) diff --git a/api/routes.py b/api/routes.py index cd33c43..cede28e 100644 --- a/api/routes.py +++ b/api/routes.py @@ -2725,17 +2725,43 @@ def register_routes(app, dependencies: dict): print(f" Episodes: {episodes_with_dates}/{total_episodes} found in DB, {episodes_missing_db} missing from DB") print(f" Movies: {movies_with_dates}/{total_movies} found in DB, {movies_missing_db} missing from DB") - total_missing = len(missing_items["episodes"]) + len(missing_items["movies"]) - print(f"✅ NFO repair scan complete: {total_missing} items missing dateadded elements") + # Calculate comprehensive statistics + total_nfo_files_missing = len(missing_tv_nfo_files) + len(missing_movie_nfo_files) + total_with_imdb_and_db = len(missing_items["episodes"]) + len(missing_items["movies"]) + + print(f"✅ NFO repair scan complete:") + print(f" 📄 {total_nfo_files_missing} NFO files missing dateadded elements") + print(f" 🎬 {len(missing_tv_nfo_files)} TV episodes, {len(missing_movie_nfo_files)} movies") + print(f" 🔍 {total_with_imdb_and_db} items with IMDb IDs found in database (can be fixed)") return { "status": "success", - "total_missing": total_missing, + "total_missing": total_with_imdb_and_db, # Items that can be fixed + "total_nfo_files_missing": total_nfo_files_missing, # All NFO files missing dateadded "episodes_missing": len(missing_items["episodes"]), "movies_missing": len(missing_items["movies"]), + "tv_nfo_files_missing": len(missing_tv_nfo_files), + "movie_nfo_files_missing": len(missing_movie_nfo_files), "total_tv_files_checked": total_tv_files_checked, "total_movie_files_checked": total_movie_files_checked, - "missing_items": missing_items + "missing_items": missing_items, + "statistics": { + "nfo_files_scanned": { + "tv": total_tv_files_checked, + "movies": total_movie_files_checked, + "total": total_tv_files_checked + total_movie_files_checked + }, + "nfo_files_missing_dateadded": { + "tv": len(missing_tv_nfo_files), + "movies": len(missing_movie_nfo_files), + "total": total_nfo_files_missing + }, + "items_with_imdb_and_database": { + "tv": len(missing_items["episodes"]), + "movies": len(missing_items["movies"]), + "total": total_with_imdb_and_db + } + } } except Exception as e: diff --git a/api/web_routes.py b/api/web_routes.py index e311934..c6ddc12 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -1597,14 +1597,18 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict): "total_episodes_checked": result.get('total_tv_files_checked', 0), "total_movies_checked": result.get('total_movie_files_checked', 0), "total_items_checked": result.get('total_tv_files_checked', 0) + result.get('total_movie_files_checked', 0), - "missing_dateadded_count": result['total_missing'], + "missing_dateadded_count": result['total_missing'], # Items that can be fixed + "total_nfo_files_missing": result.get('total_nfo_files_missing', result['total_missing']), # All NFO files missing dateadded + "tv_nfo_files_missing": result.get('tv_nfo_files_missing', 0), + "movie_nfo_files_missing": result.get('movie_nfo_files_missing', 0), "items": all_missing[:50], # Limit display to first 50 "debug_info": { "scan_method": "core_container_filesystem", "core_container_response": "success", "episodes_missing": result['episodes_missing'], "movies_missing": result['movies_missing'], - "core_response_keys": list(result.keys()) + "core_response_keys": list(result.keys()), + "statistics": result.get('statistics', {}) } } else: diff --git a/nfoguard-web/static/css/styles.css b/nfoguard-web/static/css/styles.css index 5c46bb4..678e734 100644 --- a/nfoguard-web/static/css/styles.css +++ b/nfoguard-web/static/css/styles.css @@ -1249,6 +1249,63 @@ textarea { min-width: auto; } +/* NFO Statistics Styling */ +.nfo-stats-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 1rem; + margin: 1rem 0; +} + +.stat-box { + background-color: var(--bg-secondary); + border: 1px solid var(--border-color); + border-radius: 8px; + padding: 1rem; + text-align: center; +} + +.stat-number { + font-size: 2rem; + font-weight: 700; + color: var(--primary-color); + margin-bottom: 0.5rem; +} + +.stat-label { + font-size: 0.875rem; + color: var(--text-secondary); + font-weight: 500; +} + +.recommendation-box { + background-color: #fff3cd; + border: 1px solid #ffeaa7; + border-radius: 8px; + padding: 1rem; + margin: 1rem 0; +} + +.recommendation-box ul { + margin: 0.5rem 0 0 1rem; + padding: 0; +} + +.recommendation-box li { + margin-bottom: 0.5rem; +} + +.success-box { + background-color: #d4edda; + border: 1px solid #c3e6cb; + color: #155724; + border-radius: 8px; + padding: 1rem; + margin: 1rem 0; + text-align: center; + font-weight: 600; +} + /* Responsive adjustments for admin tools */ @media (max-width: 768px) { .table-container { diff --git a/nfoguard-web/static/js/app.js b/nfoguard-web/static/js/app.js index 6eb5b3d..09dbeeb 100644 --- a/nfoguard-web/static/js/app.js +++ b/nfoguard-web/static/js/app.js @@ -2013,13 +2013,35 @@ async function showEpisodesMissingNFODateadded() { const response = await apiCall('/api/admin/nfo/missing-dateadded'); if (response.success) { + const totalFiles = response.total_nfo_files_missing || response.missing_dateadded_count; + const fixableItems = response.missing_dateadded_count; + const tvFiles = response.tv_nfo_files_missing || 0; + const movieFiles = response.movie_nfo_files_missing || 0; + const html = ` -

Episodes Missing NFO dateadded

-

Found: ${response.missing_dateadded_count} episodes missing dateadded in NFO files

-

Total checked: ${response.total_episodes_checked} episodes

- ${response.missing_dateadded_count > 0 ? - '

Recommendation: Use the "NFO File Repair" tool to fix these issues.

' : - '

✅ All NFO files are properly maintained!

' +

NFO Files Missing dateadded Elements

+
+
+
${totalFiles}
+
Total NFO Files Missing dateadded
+
+
+
${fixableItems}
+
Can Be Fixed Automatically
+
+
+

Breakdown: ${tvFiles} TV episodes, ${movieFiles} movies

+

Scanned: ${response.total_episodes_checked} TV NFO files, ${response.total_movies_checked} movie NFO files

+ ${totalFiles > 0 ? ` +
+

📋 Action Required:

+ +
+ ` : + '
✅ All NFO files are properly maintained!
' } `; resultsContent.innerHTML = html;