✨ feat(aniwatch): Improves title matching logic
- Enhances title matching accuracy when fetching Aniwatch IDs. - Prioritizes user-preferred titles and falls back to English titles. - Ensures only one fetch call is made per title if both english and userPreferred title are same. - Adds a score threshold to filter low-quality matches. - Fixes a bug where the episode list was not being returned.
This commit is contained in:
@@ -81,18 +81,23 @@ export function fetchEpisodes(
|
||||
app.openapi(route, async (c) => {
|
||||
const aniListId = Number(c.req.param("aniListId"));
|
||||
|
||||
const { result: episodes, errorOccurred } = await fetchEpisodes(
|
||||
const { result, errorOccurred } = await fetchEpisodes(
|
||||
aniListId,
|
||||
env(c, "workerd"),
|
||||
);
|
||||
|
||||
if (errorOccurred) {
|
||||
if (errorOccurred || !result) {
|
||||
return c.json(ErrorResponse, { status: 500 });
|
||||
}
|
||||
|
||||
const { episodes, providerId } = result;
|
||||
if (!episodes || episodes.length === 0) {
|
||||
return c.json(ErrorResponse, { status: 404 });
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: true,
|
||||
result: episodes ?? [],
|
||||
result: { providerId, episodes },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user