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:
|
## 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...');
|
AniWorld.UI.showLoading('Creating NFO metadata...');
|
||||||
|
|
||||||
const response = await AniWorld.ApiClient.request(
|
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') {
|
if (response && response.message) {
|
||||||
AniWorld.UI.showToast('NFO creation started', 'success');
|
AniWorld.UI.showToast(response.message || 'NFO created successfully', 'success');
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response?.message || 'Failed to create NFO');
|
throw new Error('Failed to create NFO');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating NFO:', error);
|
console.error('Error creating NFO:', error);
|
||||||
@@ -54,17 +60,17 @@ AniWorld.NFOManager = (function() {
|
|||||||
AniWorld.UI.showLoading('Refreshing NFO metadata...');
|
AniWorld.UI.showLoading('Refreshing NFO metadata...');
|
||||||
|
|
||||||
const response = await AniWorld.ApiClient.request(
|
const response = await AniWorld.ApiClient.request(
|
||||||
`/api/nfo/series/${encodeURIComponent(seriesKey)}`,
|
`/api/nfo/${encodeURIComponent(seriesKey)}/update`,
|
||||||
{
|
{
|
||||||
method: 'PUT'
|
method: 'PUT'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response && response.status === 'success') {
|
if (response && response.message) {
|
||||||
AniWorld.UI.showToast('NFO refresh started', 'success');
|
AniWorld.UI.showToast(response.message || 'NFO updated successfully', 'success');
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response?.message || 'Failed to refresh NFO');
|
throw new Error('Failed to refresh NFO');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error refreshing NFO:', error);
|
console.error('Error refreshing NFO:', error);
|
||||||
@@ -88,11 +94,11 @@ AniWorld.NFOManager = (function() {
|
|||||||
AniWorld.UI.showLoading('Loading NFO data...');
|
AniWorld.UI.showLoading('Loading NFO data...');
|
||||||
|
|
||||||
const response = await AniWorld.ApiClient.request(
|
const response = await AniWorld.ApiClient.request(
|
||||||
`/api/nfo/series/${encodeURIComponent(seriesKey)}`
|
`/api/nfo/${encodeURIComponent(seriesKey)}/content`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response && response.data) {
|
if (response && response.content) {
|
||||||
return response.data;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('No NFO data available');
|
throw new Error('No NFO data available');
|
||||||
}
|
}
|
||||||
@@ -186,38 +192,16 @@ AniWorld.NFOManager = (function() {
|
|||||||
return html;
|
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
|
* Get series without NFO
|
||||||
* @param {number} limit - Maximum number of results
|
* @returns {Promise<object>} Response with series list and statistics
|
||||||
* @returns {Promise<Array>} List of series without NFO
|
|
||||||
*/
|
*/
|
||||||
async function getSeriesWithoutNFO(limit = 10) {
|
async function getSeriesWithoutNFO() {
|
||||||
try {
|
try {
|
||||||
const response = await AniWorld.ApiClient.request(
|
const response = await AniWorld.ApiClient.request('/api/nfo/missing');
|
||||||
`/api/nfo/missing?limit=${limit}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response && response.data) {
|
if (response && response.series) {
|
||||||
return response.data;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to get series without NFO');
|
throw new Error('Failed to get series without NFO');
|
||||||
}
|
}
|
||||||
@@ -233,7 +217,6 @@ AniWorld.NFOManager = (function() {
|
|||||||
refreshNFO: refreshNFO,
|
refreshNFO: refreshNFO,
|
||||||
viewNFO: viewNFO,
|
viewNFO: viewNFO,
|
||||||
showNFOModal: showNFOModal,
|
showNFOModal: showNFOModal,
|
||||||
getStatistics: getStatistics,
|
|
||||||
getSeriesWithoutNFO: getSeriesWithoutNFO
|
getSeriesWithoutNFO: getSeriesWithoutNFO
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user