This commit is contained in:
+35
-16
@@ -326,6 +326,11 @@ async def update_movie_date(dependencies: dict, imdb_id: str, dateadded: Optiona
|
|||||||
"""Update dateadded for a specific movie"""
|
"""Update dateadded for a specific movie"""
|
||||||
db = dependencies["db"]
|
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
|
# Validate movie exists
|
||||||
movie = db.get_movie_dates(imdb_id)
|
movie = db.get_movie_dates(imdb_id)
|
||||||
if not movie:
|
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
|
# Debug logging to understand the data issue
|
||||||
print(f"🔍 DEBUG: Movie data for {imdb_id}:")
|
print(f"🔍 DEBUG: Movie data for {imdb_id}:")
|
||||||
print(f" - released: {movie.get('released')}")
|
print(f" - released: {repr(movie.get('released'))}")
|
||||||
print(f" - dateadded: {movie.get('dateadded')}")
|
print(f" - dateadded: {repr(movie.get('dateadded'))}")
|
||||||
print(f" - source: {movie.get('source')}")
|
print(f" - source: {repr(movie.get('source'))}")
|
||||||
print(f" - path: {movie.get('path')}")
|
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 = []
|
options = []
|
||||||
|
|
||||||
@@ -486,18 +493,26 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Option 2: Released date as digital release (if different from current)
|
# Option 2: Released date as digital release (if different from current)
|
||||||
if movie.get('released'):
|
if movie.get('released') and movie['released'].strip():
|
||||||
release_date = f"{movie['released']}T00:00:00"
|
try:
|
||||||
# Only add if it's different from current dateadded
|
release_date = f"{movie['released']}T00:00:00"
|
||||||
current_dateadded = movie.get('dateadded', '')
|
# Validate the date format
|
||||||
if not current_dateadded or not current_dateadded.startswith(movie['released']):
|
from datetime import datetime
|
||||||
options.append({
|
datetime.fromisoformat(release_date.replace('Z', '+00:00'))
|
||||||
"type": "digital_release",
|
|
||||||
"label": "Use Actual Release Date",
|
# Only add if it's different from current dateadded
|
||||||
"date": release_date,
|
current_dateadded = movie.get('dateadded', '')
|
||||||
"source": "digital_release",
|
if not current_dateadded or not current_dateadded.startswith(movie['released']):
|
||||||
"description": f"Use the movie's actual release date: {movie['released']} (instead of download date)"
|
options.append({
|
||||||
})
|
"type": "digital_release",
|
||||||
|
"label": "Use Actual Release Date",
|
||||||
|
"date": release_date,
|
||||||
|
"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
|
# Option 3: Manual entry
|
||||||
options.append({
|
options.append({
|
||||||
@@ -516,6 +531,10 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(f"🔍 DEBUG: Generated {len(options)} options for {imdb_id}:")
|
||||||
|
for i, option in enumerate(options):
|
||||||
|
print(f" Option {i}: {option}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"imdb_id": imdb_id,
|
"imdb_id": imdb_id,
|
||||||
"current_data": movie,
|
"current_data": movie,
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -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 {
|
try {
|
||||||
if (mediaType === 'movie') {
|
if (mediaType === 'movie') {
|
||||||
await updateMovieDate(options.imdb_id, dateadded, source);
|
await updateMovieDate(options.imdb_id, dateadded, source);
|
||||||
|
|||||||
Reference in New Issue
Block a user