feat: get author on series
This commit is contained in:
parent
9058e192ba
commit
d8f7ac38f1
@ -56,6 +56,8 @@ export function createDocument(
|
||||
|
||||
log.info("creating document", { name });
|
||||
|
||||
typesense.synchronize();
|
||||
|
||||
return fetch(SILVERBULLET_SERVER + "/" + name, {
|
||||
body: content,
|
||||
method: "PUT",
|
||||
@ -73,6 +75,8 @@ export async function getDocument(name: string): Promise<string> {
|
||||
|
||||
cache.setDocument(name, text);
|
||||
|
||||
typesense.synchronize();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -100,3 +100,7 @@ const resourcePrefixes = Object.values(resources).map((v) => v.prefix).filter(
|
||||
);
|
||||
export const isLocalImage = (src: string) =>
|
||||
resourcePrefixes.some((p) => src.startsWith(p));
|
||||
|
||||
export const isString = (input: string | undefined): input is string => {
|
||||
return typeof input === "string";
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ import { createMovie, getMovie, Movie } from "@lib/resource/movies.ts";
|
||||
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 { safeFileName } from "@lib/string.ts";
|
||||
import { isString, safeFileName } from "@lib/string.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
import { AccessDeniedError } from "@lib/errors.ts";
|
||||
|
||||
@ -52,12 +52,21 @@ export const handler: Handlers = {
|
||||
metadata.author = director.name;
|
||||
}
|
||||
|
||||
const tags: string[] = [];
|
||||
if (movieDetails.genres) {
|
||||
tags.push(
|
||||
...movieDetails.genres.map((g) => g.name?.toLowerCase()).filter(
|
||||
isString,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const movie: Movie = {
|
||||
id: name,
|
||||
name: name,
|
||||
type: "movie",
|
||||
description: "",
|
||||
tags: [],
|
||||
tags,
|
||||
meta: metadata,
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { createDocument } from "@lib/documents.ts";
|
||||
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
|
||||
import { createMovie, getMovie } from "@lib/resource/movies.ts";
|
||||
import * as tmdb from "@lib/tmdb.ts";
|
||||
import { safeFileName } from "@lib/string.ts";
|
||||
import { isString, safeFileName } from "@lib/string.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import {
|
||||
AccessDeniedError,
|
||||
@ -12,10 +12,6 @@ import {
|
||||
} from "@lib/errors.ts";
|
||||
import * as cache from "@lib/cache/cache.ts";
|
||||
|
||||
const isString = (input: string | undefined): input is string => {
|
||||
return typeof input === "string";
|
||||
};
|
||||
|
||||
const POST = async (
|
||||
req: Request,
|
||||
ctx: HandlerContext,
|
||||
|
@ -2,7 +2,7 @@ import { Handlers } from "$fresh/server.ts";
|
||||
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 { safeFileName } from "@lib/string.ts";
|
||||
import { isString, safeFileName } from "@lib/string.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
import { AccessDeniedError } from "@lib/errors.ts";
|
||||
import { createSeries, getSeries, Series } from "@lib/resource/series.ts";
|
||||
@ -26,7 +26,8 @@ export const handler: Handlers = {
|
||||
const releaseDate = seriesDetails.first_air_date;
|
||||
const posterPath = seriesDetails.poster_path;
|
||||
const director =
|
||||
seriesCredits?.crew?.filter?.((person) => person.job === "Director")[0];
|
||||
seriesCredits?.crew?.filter?.((person) => person.job === "Director")[0] ||
|
||||
seriesDetails.created_by?.[0];
|
||||
|
||||
let finalPath = "";
|
||||
const name = seriesDetails.name || seriesDetails.original_name ||
|
||||
@ -52,12 +53,21 @@ export const handler: Handlers = {
|
||||
metadata.author = director.name;
|
||||
}
|
||||
|
||||
const tags: string[] = [];
|
||||
if (seriesDetails.genres) {
|
||||
tags.push(
|
||||
...seriesDetails.genres.map((g) => g.name?.toLowerCase()).filter(
|
||||
isString,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const series: Series = {
|
||||
id: name,
|
||||
name: name,
|
||||
tags,
|
||||
type: "series",
|
||||
description: "",
|
||||
tags: [],
|
||||
meta: metadata,
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,8 @@ const POST = async (
|
||||
}
|
||||
const posterPath = seriesDetails.poster_path;
|
||||
const director = seriesCredits &&
|
||||
seriesCredits.crew?.filter?.((person) => person.job === "Director")[0];
|
||||
seriesCredits.crew?.filter?.((person) => person.job === "Director")[0] ||
|
||||
seriesDetails?.created_by?.[0];
|
||||
if (director && director.name && !series.meta.author) {
|
||||
series.meta.author = director.name;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user