feat: some shit
This commit is contained in:
@ -3,6 +3,7 @@ import { addMovieInfos } from "@islands/KMenu/commands/add_movie_infos.ts";
|
||||
import { createNewMovie } from "@islands/KMenu/commands/create_movie.ts";
|
||||
import { createNewArticle } from "@islands/KMenu/commands/create_article.ts";
|
||||
import { getCookie } from "@lib/string.ts";
|
||||
import { addSeriesInfo } from "@islands/KMenu/commands/add_series_infos.ts";
|
||||
|
||||
export const menus: Record<string, Menu> = {
|
||||
main: {
|
||||
@ -54,6 +55,7 @@ export const menus: Record<string, Menu> = {
|
||||
return !!getCookie("session_cookie");
|
||||
},
|
||||
},
|
||||
addSeriesInfo,
|
||||
createNewArticle,
|
||||
createNewMovie,
|
||||
addMovieInfos,
|
||||
|
@ -46,7 +46,6 @@ export const addMovieInfos: MenuEntry = {
|
||||
const loc = globalThis["location"];
|
||||
if (!getCookie("session_cookie")) return false;
|
||||
return (loc?.pathname?.includes("movie") &&
|
||||
!loc.pathname.endsWith("movies")) ||
|
||||
(loc?.pathname?.includes("series") && !loc.pathname.endsWith("series"));
|
||||
!loc.pathname.endsWith("movies"));
|
||||
},
|
||||
};
|
||||
|
@ -1,39 +1,43 @@
|
||||
import { MenuEntry } from "@islands/KMenu/types.ts";
|
||||
import { TMDBMovie } from "@lib/types.ts";
|
||||
import { TMDBSeries } from "@lib/types.ts";
|
||||
import { getCookie } from "@lib/string.ts";
|
||||
import { Series } from "@lib/resource/series.ts";
|
||||
|
||||
export const addMovieInfos: MenuEntry = {
|
||||
title: "Add Movie infos",
|
||||
export const addSeriesInfo: MenuEntry = {
|
||||
title: "Add Series infos",
|
||||
meta: "",
|
||||
icon: "IconReportSearch",
|
||||
cb: async (state, context) => {
|
||||
console.log({ state, context });
|
||||
state.activeState.value = "loading";
|
||||
const movie = context as Series;
|
||||
const series = context as Series;
|
||||
|
||||
const query = movie.name;
|
||||
const query = series.name;
|
||||
|
||||
const response = await fetch(
|
||||
`/api/tmdb/query?q=${encodeURIComponent(query)}&type=serie`,
|
||||
);
|
||||
|
||||
const json = await response.json() as TMDBMovie[];
|
||||
const json = await response.json() as TMDBSeries[];
|
||||
|
||||
const menuID = `result/${movie.name}`;
|
||||
console.log({ json });
|
||||
|
||||
const menuID = `result/${series.name}`;
|
||||
|
||||
state.menus[menuID] = {
|
||||
title: "Select",
|
||||
entries: json.map((m) => ({
|
||||
title: `${m.title} released ${m.release_date}`,
|
||||
title: `${m.name || m.original_name} released ${m.first_air_date}`,
|
||||
cb: async () => {
|
||||
state.activeState.value = "loading";
|
||||
await fetch(`/api/movies/enhance/${movie.name}/`, {
|
||||
console.log({ m });
|
||||
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();
|
||||
//window.location.reload();
|
||||
},
|
||||
})),
|
||||
};
|
||||
@ -45,8 +49,7 @@ export const addMovieInfos: MenuEntry = {
|
||||
visible: () => {
|
||||
const loc = globalThis["location"];
|
||||
if (!getCookie("session_cookie")) return false;
|
||||
return (loc?.pathname?.includes("movie") &&
|
||||
!loc.pathname.endsWith("movies")) ||
|
||||
(loc?.pathname?.includes("series") && !loc.pathname.endsWith("series"));
|
||||
return (loc?.pathname?.includes("series") &&
|
||||
!loc.pathname.endsWith("series"));
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user