fix: digital realease date
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-14 15:46:07 -04:00
parent 249b55964e
commit 6fae41aef5
3 changed files with 107 additions and 16 deletions
+24 -5
View File
@@ -326,6 +326,11 @@ async def update_movie_date(dependencies: dict, imdb_id: str, dateadded: Optiona
"""Update dateadded for a specific movie"""
db = dependencies["db"]
# Debug logging to track the issue
print(f"🔍 UPDATE_MOVIE_DATE: imdb_id={imdb_id}, dateadded={dateadded}, source={source}")
print(f" - dateadded type: {type(dateadded)}")
print(f" - dateadded repr: {repr(dateadded)}")
# Validate movie exists
movie = db.get_movie_dates(imdb_id)
if not movie:
@@ -451,10 +456,12 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
# Debug logging to understand the data issue
print(f"🔍 DEBUG: Movie data for {imdb_id}:")
print(f" - released: {movie.get('released')}")
print(f" - dateadded: {movie.get('dateadded')}")
print(f" - source: {movie.get('source')}")
print(f" - path: {movie.get('path')}")
print(f" - released: {repr(movie.get('released'))}")
print(f" - dateadded: {repr(movie.get('dateadded'))}")
print(f" - source: {repr(movie.get('source'))}")
print(f" - path: {repr(movie.get('path'))}")
print(f" - has_video_file: {repr(movie.get('has_video_file'))}")
print(f" - last_updated: {repr(movie.get('last_updated'))}")
options = []
@@ -486,8 +493,13 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
})
# Option 2: Released date as digital release (if different from current)
if movie.get('released'):
if movie.get('released') and movie['released'].strip():
try:
release_date = f"{movie['released']}T00:00:00"
# Validate the date format
from datetime import datetime
datetime.fromisoformat(release_date.replace('Z', '+00:00'))
# Only add if it's different from current dateadded
current_dateadded = movie.get('dateadded', '')
if not current_dateadded or not current_dateadded.startswith(movie['released']):
@@ -498,6 +510,9 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
"source": "digital_release",
"description": f"Use the movie's actual release date: {movie['released']} (instead of download date)"
})
except Exception as e:
print(f"⚠️ Invalid released date format for {imdb_id}: {movie.get('released')} - {e}")
# Don't add this option if the date is invalid
# Option 3: Manual entry
options.append({
@@ -516,6 +531,10 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
except Exception:
pass
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id}:")
for i, option in enumerate(options):
print(f" Option {i}: {option}")
return {
"imdb_id": imdb_id,
"current_data": movie,
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""
Debug script to check specific movie data in NFOGuard database
"""
import os
import sys
from pathlib import Path
# Add the project root to the path
sys.path.insert(0, str(Path(__file__).parent))
from core.database import NFOGuardDatabase
def debug_movie(imdb_id: str):
"""Debug a specific movie's data"""
print(f"🔍 DEBUG MOVIE: {imdb_id}")
print("=" * 50)
# Initialize database
db = NFOGuardDatabase()
# Get movie data
movie = db.get_movie_dates(imdb_id)
if not movie:
print(f"❌ Movie {imdb_id} not found in database")
return
print("📊 RAW MOVIE DATA:")
for key, value in movie.items():
print(f" {key}: {repr(value)}")
print("\n🎬 FORMATTED MOVIE DATA:")
print(f" Title/Path: {movie.get('path', 'Unknown')}")
print(f" Released: {movie.get('released', 'None')}")
print(f" Date Added: {movie.get('dateadded', 'None')}")
print(f" Source: {movie.get('source', 'None')}")
print(f" Has Video: {movie.get('has_video_file', False)}")
print(f" Last Updated: {movie.get('last_updated', 'None')}")
# Check if released date is valid
released = movie.get('released')
if released and released.strip():
try:
from datetime import datetime
test_date = f"{released}T00:00:00"
parsed = datetime.fromisoformat(test_date.replace('Z', '+00:00'))
print(f"\n✅ Released date is valid: {parsed}")
except Exception as e:
print(f"\n❌ Released date is INVALID: {e}")
else:
print(f"\n⚠️ Released date is empty or None")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python debug_movie.py <imdb_id>")
sys.exit(1)
imdb_id = sys.argv[1]
if not imdb_id.startswith('tt'):
imdb_id = f'tt{imdb_id}'
debug_movie(imdb_id)
+10
View File
@@ -643,6 +643,16 @@ async function applySmartFix(mediaType, options) {
}
}
// Debug logging
console.log('🔍 SMART FIX DEBUG:', {
mediaType,
imdb_id: options.imdb_id,
selectedOption,
dateadded,
source,
originalDate: selectedOption.date
});
try {
if (mediaType === 'movie') {
await updateMovieDate(options.imdb_id, dateadded, source);