diff --git a/docs/instructions.md b/docs/instructions.md index e37ff86..aaa032a 100644 --- a/docs/instructions.md +++ b/docs/instructions.md @@ -109,3 +109,28 @@ For each task completed: --- ## TODO List: + + + +## Recently Fixed Issues + +### 1. NFO API Endpoint Mismatch (Fixed: 2026-01-16) + +**Issue**: Frontend JavaScript was calling incorrect NFO API endpoints causing 404 errors. + +**Root Cause**: +- Frontend was using `/api/nfo/series/{key}` pattern +- Backend API uses `/api/nfo/{serie_id}/create`, `/api/nfo/{serie_id}/update`, `/api/nfo/{serie_id}/content` + +**Changes Made**: +- Updated [nfo-manager.js](../src/server/web/static/js/index/nfo-manager.js): + - Fixed `createNFO()`: Now calls `POST /api/nfo/{key}/create` with proper request body + - Fixed `refreshNFO()`: Now calls `PUT /api/nfo/{key}/update` + - Fixed `viewNFO()`: Now calls `GET /api/nfo/{key}/content` + - Updated response handling to check for actual API response fields (e.g., `message`, `content`) + - Removed non-existent `getStatistics()` function + - Fixed `getSeriesWithoutNFO()` to use correct endpoint and response structure + +**Status**: ✅ Fixed and tested + +--- diff --git a/src/server/web/static/js/index/nfo-manager.js b/src/server/web/static/js/index/nfo-manager.js index 36e2a91..54f2abb 100644 --- a/src/server/web/static/js/index/nfo-manager.js +++ b/src/server/web/static/js/index/nfo-manager.js @@ -20,17 +20,23 @@ AniWorld.NFOManager = (function() { AniWorld.UI.showLoading('Creating NFO metadata...'); const response = await AniWorld.ApiClient.request( - `/api/nfo/series/${encodeURIComponent(seriesKey)}`, + `/api/nfo/${encodeURIComponent(seriesKey)}/create`, { - method: 'POST' + method: 'POST', + body: JSON.stringify({ + overwrite_existing: false, + download_poster: true, + download_logo: true, + download_fanart: true + }) } ); - if (response && response.status === 'success') { - AniWorld.UI.showToast('NFO creation started', 'success'); + if (response && response.message) { + AniWorld.UI.showToast(response.message || 'NFO created successfully', 'success'); return response; } else { - throw new Error(response?.message || 'Failed to create NFO'); + throw new Error('Failed to create NFO'); } } catch (error) { console.error('Error creating NFO:', error); @@ -54,17 +60,17 @@ AniWorld.NFOManager = (function() { AniWorld.UI.showLoading('Refreshing NFO metadata...'); const response = await AniWorld.ApiClient.request( - `/api/nfo/series/${encodeURIComponent(seriesKey)}`, + `/api/nfo/${encodeURIComponent(seriesKey)}/update`, { method: 'PUT' } ); - if (response && response.status === 'success') { - AniWorld.UI.showToast('NFO refresh started', 'success'); + if (response && response.message) { + AniWorld.UI.showToast(response.message || 'NFO updated successfully', 'success'); return response; } else { - throw new Error(response?.message || 'Failed to refresh NFO'); + throw new Error('Failed to refresh NFO'); } } catch (error) { console.error('Error refreshing NFO:', error); @@ -88,11 +94,11 @@ AniWorld.NFOManager = (function() { AniWorld.UI.showLoading('Loading NFO data...'); const response = await AniWorld.ApiClient.request( - `/api/nfo/series/${encodeURIComponent(seriesKey)}` + `/api/nfo/${encodeURIComponent(seriesKey)}/content` ); - if (response && response.data) { - return response.data; + if (response && response.content) { + return response; } else { throw new Error('No NFO data available'); } @@ -186,38 +192,16 @@ AniWorld.NFOManager = (function() { return html; } - /** - * Get NFO statistics - * @returns {Promise} Statistics data - */ - async function getStatistics() { - try { - const response = await AniWorld.ApiClient.request('/api/nfo/statistics'); - - if (response && response.data) { - return response.data; - } else { - throw new Error('Failed to get NFO statistics'); - } - } catch (error) { - console.error('Error getting NFO statistics:', error); - throw error; - } - } - /** * Get series without NFO - * @param {number} limit - Maximum number of results - * @returns {Promise} List of series without NFO + * @returns {Promise} Response with series list and statistics */ - async function getSeriesWithoutNFO(limit = 10) { + async function getSeriesWithoutNFO() { try { - const response = await AniWorld.ApiClient.request( - `/api/nfo/missing?limit=${limit}` - ); + const response = await AniWorld.ApiClient.request('/api/nfo/missing'); - if (response && response.data) { - return response.data; + if (response && response.series) { + return response; } else { throw new Error('Failed to get series without NFO'); } @@ -233,7 +217,6 @@ AniWorld.NFOManager = (function() { refreshNFO: refreshNFO, viewNFO: viewNFO, showNFOModal: showNFOModal, - getStatistics: getStatistics, getSeriesWithoutNFO: getSeriesWithoutNFO }; })();