diff --git a/app.py b/app.py index 39ffeb8..6d4b533 100644 --- a/app.py +++ b/app.py @@ -1021,6 +1021,8 @@ def start_scan(source, force=False, rows_snapshot=None, series_snapshot=None): future.result() with job_lock: jobs[source]["done"] += 1 with job_lock: jobs[source]["state"] = "done" + # Publish the newly scanned metadata immediately to the cache. + refresh_library_cache() except Exception as exc: log.error("%s-Scan fehlgeschlagen: %s", source, error_summary(exc)); jobs[source]["error"] = str(exc); jobs[source]["state"] = "error" executor.submit(work) @@ -1054,7 +1056,14 @@ def refresh_library_cache(): start_scan("radarr", force=True, rows_snapshot=rows) if series and any(row.get("pending") for group in series for row in group["episodes"]): start_scan("sonarr", force=True, series_snapshot=series) - if rows or series: + needs_missing_scan = any( + row.get("local_path") != "—" and is_german_review_candidate(row) and not has_german_track(row) + for row in rows + ) or any( + episode.get("local_path") != "—" and is_german_review_candidate(episode) and not has_german_track(episode) + for group in series for episode in group["episodes"] + ) + if needs_missing_scan: start_scan("missing", force=True, rows_snapshot=rows, series_snapshot=series) log.info("Bibliotheks-Sync abgeschlossen: %s Filme, %s Serien", len(rows), len(series)) @@ -1079,10 +1088,12 @@ def index(): rows = list(library_cache["rows"]) series = list(library_cache["series"]) error = library_cache["error"] - missing_german_movies = [row for row in rows if is_german_review_candidate(row) and not has_german_track(row)] + # Unscanned files have no language information yet and must not be shown + # as missing German while the background scanner is still processing them. + missing_german_movies = [row for row in rows if is_german_review_candidate(row) and not row.get("pending") and not has_german_track(row)] missing_german_series = [] for group in series: - episodes = [episode for episode in group["episodes"] if is_german_review_candidate(episode) and not has_german_track(episode)] + episodes = [episode for episode in group["episodes"] if is_german_review_candidate(episode) and not episode.get("pending") and not has_german_track(episode)] if episodes: missing_german_series.append({**group, "episodes": episodes}) series_categories = [