feat: use marka api in all apis
This commit is contained in:
@@ -3,10 +3,9 @@ import { json } from "@lib/helpers.ts";
|
||||
import * as tmdb from "@lib/tmdb.ts";
|
||||
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
|
||||
import { isString, safeFileName } from "@lib/string.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
import { AccessDeniedError } from "@lib/errors.ts";
|
||||
import { Series } from "@lib/resource/series.ts";
|
||||
import { fetchResource } from "@lib/marka.ts";
|
||||
import { createResource, fetchResource } from "@lib/marka.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(_, ctx) {
|
||||
@@ -39,7 +38,7 @@ export const handler: Handlers = {
|
||||
|
||||
finalPath = `Media/series/images/${safeFileName(name)
|
||||
}_cover.${extension}`;
|
||||
await createDocument(finalPath, poster);
|
||||
await createResource(finalPath, poster);
|
||||
}
|
||||
|
||||
const metadata = { tmdbId } as Series["meta"];
|
||||
@@ -71,7 +70,7 @@ export const handler: Handlers = {
|
||||
meta: metadata,
|
||||
};
|
||||
|
||||
await createSeries(name, series);
|
||||
await createResource(`series/${safeFileName(name)}.md`, series);
|
||||
|
||||
return json(series);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FreshContext, Handlers } from "$fresh/server.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
import { FreshContext, Handlers } from "$fresh/server.ts";
|
||||
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
|
||||
import * as tmdb from "@lib/tmdb.ts";
|
||||
import { safeFileName } from "@lib/string.ts";
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
BadRequestError,
|
||||
NotFoundError,
|
||||
} from "@lib/errors.ts";
|
||||
import { createResource, fetchResource } from "@lib/marka.ts";
|
||||
|
||||
const isString = (input: string | undefined): input is string => {
|
||||
return typeof input === "string";
|
||||
@@ -30,7 +31,7 @@ const POST = async (
|
||||
throw new BadRequestError();
|
||||
}
|
||||
|
||||
const series = await getSeries(ctx.params.name);
|
||||
const series = await fetchResource(`series/${ctx.params.name}`);
|
||||
if (!series) {
|
||||
throw new NotFoundError();
|
||||
}
|
||||
@@ -63,15 +64,15 @@ const POST = async (
|
||||
|
||||
let finalPath = "";
|
||||
if (posterPath && !series.meta?.image) {
|
||||
// const poster = await tmdb.getMoviePoster(posterPath);
|
||||
const poster = await tmdb.getMoviePoster(posterPath);
|
||||
const extension = fileExtension(posterPath);
|
||||
|
||||
finalPath = `Media/series/images/${safeFileName(name)}_cover.${extension}`;
|
||||
// await createDocument(finalPath, poster);
|
||||
await createResource(finalPath, poster);
|
||||
series.meta = series.meta || {};
|
||||
series.meta.image = finalPath;
|
||||
}
|
||||
// await createSeries(series.id, series);
|
||||
await createResource(`series/${safeFileName(series.id)}.md`, series);
|
||||
|
||||
return json(series);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { fetchResource } from "@lib/marka.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET() {
|
||||
const series = await fetchResource("series");
|
||||
return json(series);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user