Update [releaseId].ts
This commit is contained in:
@@ -14,39 +14,24 @@ interface EpisodeResponse {
|
|||||||
view_count: number;
|
view_count: number;
|
||||||
pinned: boolean;
|
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) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const { releaseId, typeId } = req.query;
|
const { releaseId } = req.query;
|
||||||
const anixartAPI = `https://api.anixart.tv/episode/${releaseId}/${typeId}`;
|
const anixartAPI = `https://api.anixart.tv/episode/${releaseId}`;
|
||||||
const seeleAPI = `https://seeleme.github.io/anixart/extension/api/${releaseId}/${typeId}.json`;
|
const seeleAPI = `https://seeleme.github.io/anixart/extension/api/episode/${releaseId}.json`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const anixartRes = await axios.get<EpisodeResponse>(anixartAPI);
|
const anixartRes = await axios.get<EpisodeResponse>(anixartAPI);
|
||||||
const anixartResData = anixartRes.data;
|
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) });
|
res.json({ is_blocked: true, ...modifyData(seeleRes.data) });
|
||||||
} else {
|
} else {
|
||||||
res.json(modifyData(anixartResData));
|
res.json(anixartResData);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data from Anixart API:', 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 => {
|
data.types = data.types.map(type => {
|
||||||
return {
|
return {
|
||||||
...type,
|
...type,
|
||||||
workers: 'Отображается благодаря расширению «MD Seele»' // Изменение значения workers на 'MD Seele'
|
workers: 'Отображается благодаря расширению «MD Seele»' // Изменение значения workers на 'MD Sele'
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user