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