Update [releaseId].ts

This commit is contained in:
2024-09-01 21:40:28 +05:00
committed by GitHub
parent 16c3bf5f26
commit 7e753e206e

View File

@@ -14,39 +14,24 @@ interface EpisodeResponse {
view_count: number;
pinned: boolean;
}>;
sources?: Array<{
'@id': number;
id: number;
type: {
'@id': number;
id: number;
name: string;
icon: string | null;
workers: string;
is_sub: boolean;
episodes_count: number;
view_count: number;
pinned: boolean;
};
name: string;
episodes_count: number;
}>;
}
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { releaseId, typeId } = req.query;
const anixartAPI = `https://api.anixart.tv/episode/${releaseId}/${typeId}`;
const seeleAPI = `https://seeleme.github.io/anixart/extension/api/${releaseId}/${typeId}.json`;
const { releaseId } = req.query;
const anixartAPI = `https://api.anixart.tv/episode/${releaseId}`;
const seeleAPI = `https://seeleme.github.io/anixart/extension/api/episode/${releaseId}.json`;
try {
const anixartRes = await axios.get<EpisodeResponse>(anixartAPI);
const anixartResData = anixartRes.data;
const modifyedData = modifyData(anixartRes.data);
if (!modifyedData.types || modifyedData.types.length === 0) {
const seeleRes = await axios.get(seeleAPI);
if (anixartResData.code === 0 && (!anixartResData.sources || anixartResData.sources.length === 0)) {
const seeleRes = await axios.get<EpisodeResponse>(seeleAPI);
res.json({ is_blocked: true, ...modifyData(seeleRes.data) });
} else {
res.json(modifyData(anixartResData));
res.json(anixartResData);
}
} catch (error) {
console.error('Error fetching data from Anixart API:', error);
@@ -59,8 +44,8 @@ function modifyData(data: EpisodeResponse): EpisodeResponse {
data.types = data.types.map(type => {
return {
...type,
workers: 'Отображается благодаря расширению «MD Seele»' // Изменение значения workers на 'MD Seele'
};
workers: 'Отображается благодаря расширению «MD Seele»' // Изменение значения workers на 'MD Sele'
}
});
}