From 152853164369fb308efc613e6f29c5ec16dfb91d Mon Sep 17 00:00:00 2001 From: Jarian Cottingham Date: Wed, 18 Feb 2026 21:59:32 -0600 Subject: [PATCH] Further refine TVDB API show details implementation with better error handling --- main.js | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index c46cf0c..ca624e9 100644 --- a/main.js +++ b/main.js @@ -217,9 +217,9 @@ ipcMain.handle('get-show-details', async (event, showId) => { throw new Error('Failed to authenticate with TVDB API: ' + loginError.message); } - // Make API request to get show extended details including seasons - // Using the correct endpoint structure from the API documentation - const response = await axios.get(`https://api4.thetvdb.com/v4/series/${showId}`, { + // Make API request to get show details + // Let's try a different approach - first get the show by ID using the slug or direct ID approach + const response = await axios.get(`https://api4.thetvdb.com/v4/series/${showId}?apikey=${apiKey}`, { headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json', @@ -260,6 +260,39 @@ ipcMain.handle('get-show-details', async (event, showId) => { console.error('Error status:', error.response?.status); console.error('Error data:', error.response?.data); + // Try a fallback approach - get the show using search by ID + try { + const searchResponse = await axios.get(`https://api4.thetvdb.com/v4/search`, { + headers: { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + params: { + id: showId + } + }); + + if (searchResponse.data && searchResponse.data.data && searchResponse.data.data.length > 0) { + const showData = searchResponse.data.data[0]; + return { + success: true, + data: { + id: showData.id, + name: showData.name, + status: showData.status?.name, + firstAired: showData.firstAired, + overview: showData.overview, + image: showData.image, + slug: showData.slug, + seasons: [] // We'll need to fetch seasons separately if this approach works + } + }; + } + } catch (fallbackError) { + console.error('Fallback approach also failed:', fallbackError.message); + } + return { success: false, error: 'Failed to fetch show details from TVDB API: ' + error.message }; } });