Fix NFO API endpoint mismatch in frontend
- Update nfo-manager.js to use correct API routes:
* POST /api/nfo/{id}/create (was /api/nfo/series/{id})
* PUT /api/nfo/{id}/update (was /api/nfo/series/{id})
* GET /api/nfo/{id}/content (was /api/nfo/series/{id})
- Add request body to createNFO with default options
- Fix response handling to check actual API fields
- Remove non-existent getStatistics function
- Fix getSeriesWithoutNFO response structure
- Update instructions.md with fix documentation
This commit is contained in:
@@ -109,3 +109,28 @@ For each task completed:
|
||||
---
|
||||
|
||||
## TODO List:
|
||||
|
||||
<!-- No pending issues -->
|
||||
|
||||
## 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
|
||||
|
||||
---
|
||||
|
||||
@@ -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<object>} 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<Array>} List of series without NFO
|
||||
* @returns {Promise<object>} 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
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user