Update [releaseId].ts
This commit is contained in:
@@ -23,48 +23,31 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const anixartRes = await axios.get<EpisodeResponse>(anixartAPI);
|
const anixartRes = await axios.get<EpisodeResponse>(anixartAPI);
|
||||||
let modifyedData = modifyData(anixartRes.data);
|
const anixartResData = anixartRes.data;
|
||||||
|
const modifyedData = modifyData(anixartRes.data);
|
||||||
|
|
||||||
if (!modifyedData.types || modifyedData.types.length === 0) {
|
if (!modifyedData.types || modifyedData.types.length === 0) {
|
||||||
const seeleRes = await axios.get<EpisodeResponse>(seeleAPI);
|
const seeleRes = await axios.get(seeleAPI);
|
||||||
modifyedData = modifyData(seeleRes.data);
|
|
||||||
|
|
||||||
if (!modifyedData.types || modifyedData.types.length === 0) {
|
res.json({ is_blocked: true, ...modifyData(seeleRes.data) });
|
||||||
// Если ни 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 {
|
} else {
|
||||||
return res.json({ is_blocked: true, ...modifyedData });
|
res.json(anixartResData);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return res.json(modifyedData);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} 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' });
|
res.status(500).json({ message: 'Internal Server Error' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyData(data: EpisodeResponse): EpisodeResponse {
|
function modifyData(data: EpisodeResponse): EpisodeResponse {
|
||||||
if (data.types && data.types.length) {
|
if (data.types && data.types.length) {
|
||||||
data.types = data.types.map(type => ({
|
data.types = data.types.map(type => {
|
||||||
|
return {
|
||||||
...type,
|
...type,
|
||||||
workers: 'источник: seele.su (元一S2)' // Изменение значения workers
|
workers: 'источник: seele.su (元一S2)' // Изменение значения workers на 'MD Sele'
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user