From fc983ed4729c16d5ca3d45311a4ce9452b439740 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Wed, 10 Sep 2025 09:04:26 -0400 Subject: [PATCH] Fix private repo authentication and enhance debug endpoint - Add authentication to git clone commands in CI workflows for private repo support - Enhanced debug endpoint to test FULL movie processing pipeline (not just database) - Debug now shows both database result AND final TMDB fallback decision - Will reveal if TMDB API calls are working correctly for rename-first scenarios --- .gitea/workflows/ci-dev.yml | 2 +- .gitea/workflows/ci.yml | 2 +- nfoguard.py | 103 +++++++++++++++++++++++++++--------- 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/ci-dev.yml b/.gitea/workflows/ci-dev.yml index 78ce218..a130e41 100644 --- a/.gitea/workflows/ci-dev.yml +++ b/.gitea/workflows/ci-dev.yml @@ -20,7 +20,7 @@ jobs: # Clone the repository since Gitea runner doesn't auto-checkout echo "Cloning repository (dev branch)..." - git clone -b dev http://192.168.253.221:3000/jskala/NFOguard.git /tmp/repo + git clone -b dev http://${{ secrets.username }}:${{ secrets.token }}@192.168.253.221:3000/jskala/NFOguard.git /tmp/repo cp -r /tmp/repo/* . cp -r /tmp/repo/.* . 2>/dev/null || true rm -rf /tmp/repo diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8a08aee..a81b54d 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: # Clone the repository since Gitea runner doesn't auto-checkout echo "Cloning repository..." - git clone http://192.168.253.221:3000/jskala/NFOguard.git /tmp/repo + git clone http://${{ secrets.username }}:${{ secrets.token }}@192.168.253.221:3000/jskala/NFOguard.git /tmp/repo cp -r /tmp/repo/* . cp -r /tmp/repo/.* . 2>/dev/null || true rm -rf /tmp/repo diff --git a/nfoguard.py b/nfoguard.py index a21798f..829154d 100644 --- a/nfoguard.py +++ b/nfoguard.py @@ -1035,35 +1035,86 @@ async def debug_movie_import_date(imdb_id: str): _log("INFO", f"Found movie: {movie_title} (Radarr ID: {movie_id})") - # Get import date with detailed logging - DATABASE ONLY - import_date, source = radarr_client.get_movie_import_date(movie_id, fallback_to_file_date=True) + # Test the FULL movie processing pipeline (not just database lookup) + _log("INFO", f"=== TESTING FULL MOVIE PROCESSING PIPELINE ===") - # Movie files info - DATABASE ONLY mode (minimal info) - file_info = [] - if import_date: - file_info.append({ - "note": "DATABASE ONLY MODE - File details from database queries", - "import_date_used": import_date, - "source": source - }) + # Create a dummy path for testing the decision logic + from pathlib import Path + dummy_path = Path("/tmp/test") - return { - "imdb_id": imdb_id, - "radarr_configured": True, - "movie_found": True, - "movie_title": movie_title, - "movie_id": movie_id, - "detected_import_date": import_date, - "import_source": source, - "movie_files": file_info, - "debug_info": { - "radarr_url": os.environ.get("RADARR_URL"), - "movie_digital_release": movie_obj.get("digitalRelease"), - "movie_in_cinemas": movie_obj.get("inCinemas"), - "movie_physical_release": movie_obj.get("physicalRelease"), - "movie_folder_path": movie_obj.get("folderPath") + try: + # Get the movie processor instance to test full decision logic + movie_processor = batcher.movie_processor + if movie_processor: + # Test the full decision logic (including TMDB fallback) + final_date, final_source, released = movie_processor._decide_movie_dates( + imdb_id, dummy_path, should_query=True, existing=None + ) + + _log("INFO", f"=== FULL PIPELINE RESULT ===") + _log("INFO", f"Final date: {final_date}") + _log("INFO", f"Final source: {final_source}") + _log("INFO", f"Released (theater): {released}") + + return { + "imdb_id": imdb_id, + "radarr_configured": True, + "movie_found": True, + "movie_title": movie_title, + "movie_id": movie_id, + "full_pipeline_test": { + "final_date": final_date, + "final_source": final_source, + "theater_release": released, + "decision_logic": "✅ TESTED FULL PIPELINE INCLUDING TMDB FALLBACK" + }, + "database_only_test": { + "radarr_db_result": radarr_client.get_movie_import_date(movie_id, fallback_to_file_date=True), + "note": "This is just the database part - fallback happens in full pipeline" + }, + "debug_info": { + "radarr_url": os.environ.get("RADARR_URL"), + "movie_digital_release": movie_obj.get("digitalRelease"), + "movie_in_cinemas": movie_obj.get("inCinemas"), + "movie_physical_release": movie_obj.get("physicalRelease"), + "movie_folder_path": movie_obj.get("folderPath") + } + } + else: + _log("ERROR", "Movie processor not available - testing database only") + # Fallback to database-only testing + import_date, source = radarr_client.get_movie_import_date(movie_id, fallback_to_file_date=True) + return { + "error": "Movie processor not available - only database test performed", + "imdb_id": imdb_id, + "radarr_configured": True, + "movie_found": True, + "movie_title": movie_title, + "movie_id": movie_id, + "detected_import_date": import_date, + "import_source": source, + "debug_info": { + "note": "FULL PIPELINE TEST FAILED - movie processor not initialized" + } + } + + except Exception as pipeline_error: + _log("ERROR", f"Full pipeline test failed: {pipeline_error}") + # Fallback to database-only testing + import_date, source = radarr_client.get_movie_import_date(movie_id, fallback_to_file_date=True) + return { + "pipeline_error": str(pipeline_error), + "imdb_id": imdb_id, + "radarr_configured": True, + "movie_found": True, + "movie_title": movie_title, + "movie_id": movie_id, + "detected_import_date": import_date, + "import_source": source, + "debug_info": { + "note": "FULL PIPELINE TEST FAILED - showing database-only result" + } } - } except Exception as e: _log("ERROR", f"Debug endpoint error for {imdb_id}: {e}")