feat: fallback to unsplash cover when article contains no image

This commit is contained in:
Max Richter
2025-11-09 23:52:53 +01:00
parent 6c6b69a46a
commit 655fc648e6
27 changed files with 687 additions and 224 deletions

View File

@@ -8,39 +8,53 @@ export const addSeriesInfo: MenuEntry = {
meta: "",
icon: "IconReportSearch",
cb: async (state, context) => {
state.activeState.value = "loading";
const series = context as ReviewResource;
try {
state.activeState.value = "loading";
const series = context as ReviewResource;
const query = series.name;
const query = series.name;
const response = await fetch(
`/api/tmdb/query?q=${encodeURIComponent(query)}&type=serie`,
);
const response = await fetch(
`/api/tmdb/query?q=${encodeURIComponent(query)}&type=serie`,
);
const json = await response.json() as TMDBSeries[];
if (!response.ok) {
throw new Error(await response.text());
}
const menuID = `result/${series.name}`;
const json = await response.json() as TMDBSeries[];
state.menus[menuID] = {
title: "Select",
entries: json.map((m) => ({
title: `${m.name || m.original_name} released ${m.first_air_date}`,
cb: async () => {
state.activeState.value = "loading";
await fetch(`/api/series/enhance/${series.name}/`, {
method: "POST",
body: JSON.stringify({ tmdbId: m.id }),
});
state.visible.value = false;
state.activeState.value = "normal";
//window.location.reload();
},
})),
};
const menuID = `result/${series.name}`;
state.commandInput.value = "";
state.activeMenu.value = menuID;
state.activeState.value = "normal";
state.menus[menuID] = {
title: "Select",
entries: json.map((m) => ({
title: `${m.name || m.original_name} released ${m.first_air_date}`,
cb: async () => {
try {
state.activeState.value = "loading";
await fetch(`/api/series/enhance/${series.name}/`, {
method: "POST",
body: JSON.stringify({ tmdbId: m.id }),
});
state.visible.value = false;
state.activeState.value = "normal";
//window.location.reload();
} catch (e) {
state.activeState.value = "error";
state.loadingText.value = e.message;
}
},
})),
};
state.commandInput.value = "";
state.activeMenu.value = menuID;
state.activeState.value = "normal";
} catch (e) {
state.activeState.value = "error";
state.loadingText.value = e.message;
}
},
visible: () => {
const loc = globalThis["location"];