diff --git a/src/pages/api/extension/episode/[releaseId].ts b/src/pages/api/extension/episode/[releaseId].ts index 8743564..aee348a 100644 --- a/src/pages/api/extension/episode/[releaseId].ts +++ b/src/pages/api/extension/episode/[releaseId].ts @@ -23,48 +23,31 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) try { const anixartRes = await axios.get(anixartAPI); - let modifyedData = modifyData(anixartRes.data); + const anixartResData = anixartRes.data; + const modifyedData = modifyData(anixartRes.data); if (!modifyedData.types || modifyedData.types.length === 0) { - const seeleRes = await axios.get(seeleAPI); - modifyedData = modifyData(seeleRes.data); + const seeleRes = await axios.get(seeleAPI); - if (!modifyedData.types || modifyedData.types.length === 0) { - // Если ни Anixart, ни Seele API не вернули данные - return res.json({ - code: 0, - types: [ - { - '@id': 1, - id: 1, - name: 'Это аниме недоступно!', - icon: null, - workers: 'Это аниме было полностью удалено с серверов anixart или вообще не было там изначально!', - is_sub: false, - episodes_count: 0, - view_count: 0, - pinned: false - } - ] - }); - } else { - return res.json({ is_blocked: true, ...modifyedData }); - } + res.json({ is_blocked: true, ...modifyData(seeleRes.data) }); } else { - return res.json(modifyedData); + res.json(anixartResData); } } catch (error) { - console.error('Error fetching data from Anixart or Seele API:', error); + console.error('Error fetching data from Anixart API:', error); res.status(500).json({ message: 'Internal Server Error' }); } } function modifyData(data: EpisodeResponse): EpisodeResponse { if (data.types && data.types.length) { - data.types = data.types.map(type => ({ - ...type, - workers: 'источник: seele.su (元一S2)' // Изменение значения workers - })); + data.types = data.types.map(type => { + return { + ...type, + workers: 'источник: seele.su (元一S2)' // Изменение значения workers на 'MD Sele' + } + }); } + return data; }