This commit is contained in:
@@ -1068,6 +1068,15 @@ def register_routes(app, dependencies: dict):
|
|||||||
"""Get available date options for an episode"""
|
"""Get available date options for an episode"""
|
||||||
return await get_episode_date_options(dependencies, imdb_id, season, episode)
|
return await get_episode_date_options(dependencies, imdb_id, season, episode)
|
||||||
|
|
||||||
|
@app.get("/api/debug/movie/{imdb_id}/raw")
|
||||||
|
async def _debug_movie_raw(imdb_id: str):
|
||||||
|
"""Debug endpoint to see raw movie database data"""
|
||||||
|
db = dependencies["db"]
|
||||||
|
movie = db.get_movie_dates(imdb_id)
|
||||||
|
if not movie:
|
||||||
|
raise HTTPException(status_code=404, detail="Movie not found")
|
||||||
|
return {"raw_data": dict(movie), "imdb_id": imdb_id}
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# Static Web Interface
|
# Static Web Interface
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|||||||
@@ -449,6 +449,13 @@ async def get_movie_date_options(dependencies: dict, imdb_id: str):
|
|||||||
if not movie:
|
if not movie:
|
||||||
raise HTTPException(status_code=404, detail="Movie not found")
|
raise HTTPException(status_code=404, detail="Movie not found")
|
||||||
|
|
||||||
|
# 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')}")
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
|
|
||||||
# Option 1: Current dateadded (if exists and is different from released)
|
# Option 1: Current dateadded (if exists and is different from released)
|
||||||
|
|||||||
+2
-2
@@ -133,8 +133,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>IMDb ID</th>
|
<th>IMDb ID</th>
|
||||||
<th>Released</th>
|
<th>Movie Released</th>
|
||||||
<th>Date Added</th>
|
<th>Date Added to Library</th>
|
||||||
<th>Source</th>
|
<th>Source</th>
|
||||||
<th>Date Type</th>
|
<th>Date Type</th>
|
||||||
<th>Video File</th>
|
<th>Video File</th>
|
||||||
|
|||||||
+102
-7
@@ -245,6 +245,9 @@ function updateMoviesTable(data) {
|
|||||||
<button class="btn btn-sm btn-primary" onclick="editMovie('${movie.imdb_id}', '${dateadded}', '${movie.source || ''}')">
|
<button class="btn btn-sm btn-primary" onclick="editMovie('${movie.imdb_id}', '${dateadded}', '${movie.source || ''}')">
|
||||||
<i class="fas fa-edit"></i> Edit
|
<i class="fas fa-edit"></i> Edit
|
||||||
</button>
|
</button>
|
||||||
|
<button class="btn btn-sm btn-secondary" onclick="debugMovie('${movie.imdb_id}')" title="Debug Data">
|
||||||
|
<i class="fas fa-bug"></i>
|
||||||
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
@@ -591,7 +594,13 @@ function closeSmartFixModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function applySmartFix(mediaType, options) {
|
async function applySmartFix(mediaType, options) {
|
||||||
const selectedIndex = document.querySelector('input[name="date-option"]:checked').value;
|
const selectedRadio = document.querySelector('input[name="date-option"]:checked');
|
||||||
|
if (!selectedRadio) {
|
||||||
|
showToast('Please select a date option', 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedIndex = selectedRadio.value;
|
||||||
const selectedOption = options.options[selectedIndex];
|
const selectedOption = options.options[selectedIndex];
|
||||||
|
|
||||||
let dateadded = selectedOption.date;
|
let dateadded = selectedOption.date;
|
||||||
@@ -601,11 +610,37 @@ async function applySmartFix(mediaType, options) {
|
|||||||
if (selectedOption.type === 'manual') {
|
if (selectedOption.type === 'manual') {
|
||||||
const manualDateInput = document.getElementById(`manual-date-${selectedIndex}`);
|
const manualDateInput = document.getElementById(`manual-date-${selectedIndex}`);
|
||||||
if (manualDateInput && manualDateInput.value) {
|
if (manualDateInput && manualDateInput.value) {
|
||||||
dateadded = new Date(manualDateInput.value).toISOString();
|
try {
|
||||||
|
dateadded = new Date(manualDateInput.value).toISOString();
|
||||||
|
} catch (e) {
|
||||||
|
showToast('Invalid date format', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showToast('Please enter a date for manual option', 'warning');
|
showToast('Please enter a date for manual option', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (dateadded) {
|
||||||
|
// Fix date format for non-manual options
|
||||||
|
try {
|
||||||
|
let dateValue = dateadded;
|
||||||
|
|
||||||
|
// Handle timezone offsets
|
||||||
|
if (dateValue.includes('+00:00')) {
|
||||||
|
dateValue = dateValue.replace('+00:00', 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = new Date(dateValue);
|
||||||
|
if (isNaN(date.getTime())) {
|
||||||
|
showToast('Invalid date from server', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dateadded = date.toISOString();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Date conversion error:', e, dateadded);
|
||||||
|
showToast('Date conversion error', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -617,6 +652,7 @@ async function applySmartFix(mediaType, options) {
|
|||||||
closeSmartFixModal();
|
closeSmartFixModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Smart fix failed:', error);
|
console.error('Smart fix failed:', error);
|
||||||
|
showToast('Smart fix failed: ' + error.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,11 +868,26 @@ function updateEditDateFromOption(optionIndex, option) {
|
|||||||
const sourceSelect = document.getElementById('edit-source');
|
const sourceSelect = document.getElementById('edit-source');
|
||||||
|
|
||||||
if (option.date) {
|
if (option.date) {
|
||||||
// Convert to datetime-local format
|
// Convert to datetime-local format with better date parsing
|
||||||
try {
|
try {
|
||||||
const date = new Date(option.date);
|
let dateValue = option.date;
|
||||||
dateInput.value = date.toISOString().slice(0, 16);
|
|
||||||
|
// Handle timezone offsets by converting to local time
|
||||||
|
if (dateValue.includes('+00:00') || dateValue.includes('Z')) {
|
||||||
|
dateValue = dateValue.replace('+00:00', 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = new Date(dateValue);
|
||||||
|
if (isNaN(date.getTime())) {
|
||||||
|
console.error('Invalid date:', dateValue);
|
||||||
|
dateInput.value = '';
|
||||||
|
} else {
|
||||||
|
// Convert to local datetime-local format
|
||||||
|
const localDateTime = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
|
||||||
|
dateInput.value = localDateTime.toISOString().slice(0, 16);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error('Date parsing error:', e, option.date);
|
||||||
dateInput.value = '';
|
dateInput.value = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -857,8 +908,19 @@ async function handleEnhancedEditSubmit(event) {
|
|||||||
const dateadded = document.getElementById('edit-dateadded').value;
|
const dateadded = document.getElementById('edit-dateadded').value;
|
||||||
const source = document.getElementById('edit-source').value;
|
const source = document.getElementById('edit-source').value;
|
||||||
|
|
||||||
// Convert datetime-local to ISO string
|
if (!dateadded) {
|
||||||
const isoDateadded = dateadded ? new Date(dateadded).toISOString() : null;
|
showToast('Please enter a date', 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert datetime-local to ISO string with error handling
|
||||||
|
let isoDateadded = null;
|
||||||
|
try {
|
||||||
|
isoDateadded = new Date(dateadded).toISOString();
|
||||||
|
} catch (e) {
|
||||||
|
showToast('Invalid date format', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mediaType === 'movie') {
|
if (mediaType === 'movie') {
|
||||||
@@ -870,6 +932,7 @@ async function handleEnhancedEditSubmit(event) {
|
|||||||
closeModal();
|
closeModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Enhanced edit failed:', error);
|
console.error('Enhanced edit failed:', error);
|
||||||
|
showToast('Update failed: ' + error.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1025,3 +1088,35 @@ function showToast(message, type = 'info') {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug function
|
||||||
|
async function debugMovie(imdbId) {
|
||||||
|
try {
|
||||||
|
const data = await apiCall(`/api/debug/movie/${imdbId}/raw`);
|
||||||
|
|
||||||
|
const debugInfo = `
|
||||||
|
DEBUG INFO for ${imdbId}:
|
||||||
|
|
||||||
|
Raw Database Data:
|
||||||
|
- imdb_id: ${data.raw_data.imdb_id}
|
||||||
|
- path: ${data.raw_data.path}
|
||||||
|
- released: ${data.raw_data.released}
|
||||||
|
- dateadded: ${data.raw_data.dateadded}
|
||||||
|
- source: ${data.raw_data.source}
|
||||||
|
- has_video_file: ${data.raw_data.has_video_file}
|
||||||
|
- last_updated: ${data.raw_data.last_updated}
|
||||||
|
|
||||||
|
Analysis:
|
||||||
|
- Movie Released: ${data.raw_data.released || 'Not set'}
|
||||||
|
- Library Import Date: ${data.raw_data.dateadded || 'Not set'}
|
||||||
|
- Date Source: ${data.raw_data.source || 'Unknown'}
|
||||||
|
`;
|
||||||
|
|
||||||
|
alert(debugInfo);
|
||||||
|
console.log('🔍 Debug data for', imdbId, data);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Debug failed:', error);
|
||||||
|
showToast('Debug failed: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user