Use trailer instead of trailerUrl on seed, allow seasonNumber = 0

This commit is contained in:
Zoe Roux 2025-05-26 00:33:36 +02:00
parent 791bbf275a
commit 953ac5ffa8
No known key found for this signature in database
14 changed files with 72 additions and 33 deletions

View File

@ -47,7 +47,7 @@ export const insertEntries = async (
items: (SeedEntry | SeedExtra)[], items: (SeedEntry | SeedExtra)[],
onlyExtras = false, onlyExtras = false,
) => { ) => {
if (!items) return []; if (!items.length) return [];
const retEntries = await db.transaction(async (tx) => { const retEntries = await db.transaction(async (tx) => {
const vals: EntryI[] = await Promise.all( const vals: EntryI[] = await Promise.all(

View File

@ -12,13 +12,18 @@ export const insertSeasons = async (
show: { pk: number; slug: string }, show: { pk: number; slug: string },
items: SeedSeason[], items: SeedSeason[],
) => { ) => {
if (!items.length) return [];
return db.transaction(async (tx) => { return db.transaction(async (tx) => {
const vals: SeasonI[] = items.map((x) => { const vals: SeasonI[] = items.map((x) => {
const { translations, ...season } = x; const { translations, ...season } = x;
return { return {
...season, ...season,
showPk: show.pk, showPk: show.pk,
slug: `${show.slug}-s${season.seasonNumber}`, slug:
season.seasonNumber === 0
? `${show.slug}-specials`
: `${show.slug}-s${season.seasonNumber}`,
nextRefresh: guessNextRefresh(season.startAir ?? new Date()), nextRefresh: guessNextRefresh(season.startAir ?? new Date()),
}; };
}); });

View File

@ -12,6 +12,7 @@ export const bubbleVideo: Video = {
title: "bubble", title: "bubble",
years: [2022], years: [2022],
from: "guessit", from: "guessit",
history: [],
}, },
createdAt: "2024-11-23T15:01:24.968Z", createdAt: "2024-11-23T15:01:24.968Z",
updatedAt: "2024-11-23T15:01:24.968Z", updatedAt: "2024-11-23T15:01:24.968Z",
@ -33,7 +34,7 @@ export const bubble: SeedMovie = {
"https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg", "https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg",
banner: null, banner: null,
logo: "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png", logo: "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png",
trailerUrl: "https://www.youtube.com/watch?v=vs7zsyIZkMM", trailer: "https://www.youtube.com/watch?v=vs7zsyIZkMM",
}, },
ja: { ja: {
name: "バブル2022", name: "バブル2022",
@ -47,7 +48,7 @@ export const bubble: SeedMovie = {
thumbnail: "https://image.tmdb.org/t/p/original/jp.jpg", thumbnail: "https://image.tmdb.org/t/p/original/jp.jpg",
banner: null, banner: null,
logo: null, logo: null,
trailerUrl: "https://www.youtube.com/watch?v=vs7zsyIZkMM", trailer: "https://www.youtube.com/watch?v=vs7zsyIZkMM",
}, },
}, },
genres: ["animation", "adventure", "science-fiction", "fantasy"], genres: ["animation", "adventure", "science-fiction", "fantasy"],

View File

@ -12,6 +12,7 @@ export const dune1984Video: Video = {
title: "dune", title: "dune",
years: [1984], years: [1984],
from: "guessit", from: "guessit",
history: [],
}, },
createdAt: "2024-12-02T11:45:12.968Z", createdAt: "2024-12-02T11:45:12.968Z",
updatedAt: "2024-12-02T11:45:12.968Z", updatedAt: "2024-12-02T11:45:12.968Z",
@ -33,7 +34,7 @@ export const dune1984: SeedMovie = {
"https://image.tmdb.org/t/p/original/pCHV6BntWLO2H6wQOj4LwzAWqpa.jpg", "https://image.tmdb.org/t/p/original/pCHV6BntWLO2H6wQOj4LwzAWqpa.jpg",
banner: null, banner: null,
logo: "https://image.tmdb.org/t/p/original/olbKnk2VvFcM2STl0dJAf6kfydo.png", logo: "https://image.tmdb.org/t/p/original/olbKnk2VvFcM2STl0dJAf6kfydo.png",
trailerUrl: "https://www.youtube.com/watch?v=vczYTLQ6oiE", trailer: "https://www.youtube.com/watch?v=vczYTLQ6oiE",
}, },
}, },
genres: ["adventure", "drama", "science-fiction"], genres: ["adventure", "drama", "science-fiction"],

View File

@ -12,6 +12,7 @@ export const duneVideo: Video = {
title: "dune", title: "dune",
years: [2021], years: [2021],
from: "guessit", from: "guessit",
history: [],
}, },
createdAt: "2024-12-02T10:10:24.968Z", createdAt: "2024-12-02T10:10:24.968Z",
updatedAt: "2024-12-02T10:10:24.968Z", updatedAt: "2024-12-02T10:10:24.968Z",
@ -33,7 +34,7 @@ export const dune: SeedMovie = {
"https://image.tmdb.org/t/p/original/k2ocXnNkmvE6rJomRkExIStFq3v.jpg", "https://image.tmdb.org/t/p/original/k2ocXnNkmvE6rJomRkExIStFq3v.jpg",
banner: null, banner: null,
logo: "https://image.tmdb.org/t/p/original/5nDsd3u1c6kDphbtIqkHseLg7HL.png", logo: "https://image.tmdb.org/t/p/original/5nDsd3u1c6kDphbtIqkHseLg7HL.png",
trailerUrl: "https://www.youtube.com/watch?v=n9xhJrPXop4", trailer: "https://www.youtube.com/watch?v=n9xhJrPXop4",
}, },
}, },
genres: ["adventure", "drama", "science-fiction", "action"], genres: ["adventure", "drama", "science-fiction", "action"],

View File

@ -12,6 +12,7 @@ export const madeInAbyssVideo: Video = {
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
kind: "episode", kind: "episode",
from: "guessit", from: "guessit",
history: [],
}, },
createdAt: "2024-11-23T15:01:24.968Z", createdAt: "2024-11-23T15:01:24.968Z",
updatedAt: "2024-11-23T15:01:24.968Z", updatedAt: "2024-11-23T15:01:24.968Z",
@ -56,7 +57,7 @@ export const madeInAbyss = {
"https://image.tmdb.org/t/p/original/Df9XrvZFIeQfLKfu8evRmzvRsd.jpg", "https://image.tmdb.org/t/p/original/Df9XrvZFIeQfLKfu8evRmzvRsd.jpg",
logo: "https://image.tmdb.org/t/p/original/7hY3Q4GhkiYPBfn4UoVg0AO4Zgk.png", logo: "https://image.tmdb.org/t/p/original/7hY3Q4GhkiYPBfn4UoVg0AO4Zgk.png",
banner: null, banner: null,
trailerUrl: "https://www.youtube.com/watch?v=ePOyy6Wlk4s", trailer: "https://www.youtube.com/watch?v=ePOyy6Wlk4s",
}, },
ja: { ja: {
name: "メイドインアビス", name: "メイドインアビス",
@ -90,7 +91,7 @@ export const madeInAbyss = {
"https://image.tmdb.org/t/p/original/Df9XrvZFIeQfLKfu8evRmzvRsd.jpg", "https://image.tmdb.org/t/p/original/Df9XrvZFIeQfLKfu8evRmzvRsd.jpg",
logo: "https://image.tmdb.org/t/p/original/7hY3Q4GhkiYPBfn4UoVg0AO4Zgk.png", logo: "https://image.tmdb.org/t/p/original/7hY3Q4GhkiYPBfn4UoVg0AO4Zgk.png",
banner: null, banner: null,
trailerUrl: "https://www.youtube.com/watch?v=ePOyy6Wlk4s", trailer: "https://www.youtube.com/watch?v=ePOyy6Wlk4s",
}, },
}, },
genres: [ genres: [

View File

@ -80,12 +80,19 @@ export const SeedMovie = t.Composite([
}), }),
translations: TranslationRecord( translations: TranslationRecord(
t.Composite([ t.Composite([
t.Omit(MovieTranslation, ["poster", "thumbnail", "banner", "logo"]), t.Omit(MovieTranslation, [
"poster",
"thumbnail",
"banner",
"logo",
"trailerUrl",
]),
t.Object({ t.Object({
poster: t.Nullable(SeedImage), poster: t.Nullable(SeedImage),
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),
banner: t.Nullable(SeedImage), banner: t.Nullable(SeedImage),
logo: t.Nullable(SeedImage), logo: t.Nullable(SeedImage),
trailer: t.Nullable(SeedImage),
latinName: t.Optional(Original.properties.latinName), latinName: t.Optional(Original.properties.latinName),
}), }),
]), ]),

View File

@ -8,7 +8,7 @@ import { TranslationRecord } from "./utils/language";
import { Resource } from "./utils/resource"; import { Resource } from "./utils/resource";
export const BaseSeason = t.Object({ export const BaseSeason = t.Object({
seasonNumber: t.Integer({ minimum: 1 }), seasonNumber: t.Integer({ minimum: 0 }),
startAir: t.Nullable(t.String({ format: "date" })), startAir: t.Nullable(t.String({ format: "date" })),
endAir: t.Nullable(t.String({ format: "date" })), endAir: t.Nullable(t.String({ format: "date" })),

View File

@ -96,12 +96,19 @@ export const SeedSerie = t.Composite([
}), }),
translations: TranslationRecord( translations: TranslationRecord(
t.Composite([ t.Composite([
t.Omit(SerieTranslation, ["poster", "thumbnail", "banner", "logo"]), t.Omit(SerieTranslation, [
"poster",
"thumbnail",
"banner",
"logo",
"trailerUrl",
]),
t.Object({ t.Object({
poster: t.Nullable(SeedImage), poster: t.Nullable(SeedImage),
thumbnail: t.Nullable(SeedImage), thumbnail: t.Nullable(SeedImage),
banner: t.Nullable(SeedImage), banner: t.Nullable(SeedImage),
logo: t.Nullable(SeedImage), logo: t.Nullable(SeedImage),
trailer: t.Nullable(SeedImage),
latinName: t.Optional(Original.properties.latinName), latinName: t.Optional(Original.properties.latinName),
}), }),
]), ]),

View File

@ -21,7 +21,7 @@ describe("with a null value", () => {
// instead we just make a new file for those /shrug // instead we just make a new file for those /shrug
// see: https://github.com/oven-sh/bun/issues/5738 // see: https://github.com/oven-sh/bun/issues/5738
beforeAll(async () => { beforeAll(async () => {
await createMovie({ const [ret, body] = await createMovie({
slug: "no-air-date", slug: "no-air-date",
translations: { translations: {
en: { en: {
@ -34,7 +34,7 @@ describe("with a null value", () => {
tagline: null, tagline: null,
tags: [], tags: [],
thumbnail: null, thumbnail: null,
trailerUrl: null, trailer: null,
}, },
}, },
genres: [], genres: [],
@ -46,6 +46,7 @@ describe("with a null value", () => {
externalId: {}, externalId: {},
studios: [], studios: [],
}); });
expectStatus(ret, body).toBe(201);
}); });
it("sort by dates desc with a null value", async () => { it("sort by dates desc with a null value", async () => {

View File

@ -49,7 +49,7 @@ describe("Movie seeding", () => {
thumbnail: null, thumbnail: null,
banner: null, banner: null,
logo: null, logo: null,
trailerUrl: null, trailer: null,
}, },
}, },
}); });
@ -154,7 +154,7 @@ describe("Movie seeding", () => {
poster: null, poster: null,
thumbnail: null, thumbnail: null,
logo: null, logo: null,
trailerUrl: null, trailer: null,
}, },
}, },
}); });
@ -180,7 +180,7 @@ describe("Movie seeding", () => {
poster: null, poster: null,
thumbnail: null, thumbnail: null,
logo: null, logo: null,
trailerUrl: null, trailer: null,
}, },
}, },
}); });
@ -308,7 +308,7 @@ describe("Movie seeding", () => {
part: null, part: null,
version: 1, version: 1,
rendering: "oeunhtoeuth", rendering: "oeunhtoeuth",
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
}); });
expectStatus(vresp, video).toBe(201); expectStatus(vresp, video).toBe(201);
@ -334,7 +334,7 @@ describe("Movie seeding", () => {
part: null, part: null,
version: 2, version: 2,
rendering: "oeunhtoeuth", rendering: "oeunhtoeuth",
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
}); });
expectStatus(vresp, video).toBe(201); expectStatus(vresp, video).toBe(201);
@ -359,7 +359,7 @@ describe("Movie seeding", () => {
part: 1, part: 1,
version: 2, version: 2,
rendering: "oaoeueunhtoeuth", rendering: "oaoeueunhtoeuth",
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
}); });
expectStatus(vresp, video).toBe(201); expectStatus(vresp, video).toBe(201);
@ -385,14 +385,14 @@ describe("Movie seeding", () => {
part: null, part: null,
version: 1, version: 1,
rendering: "oeunhtoeuthoeu", rendering: "oeunhtoeuthoeu",
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
}, },
{ {
path: "/video/bubble4.mkv", path: "/video/bubble4.mkv",
part: null, part: null,
version: 1, version: 1,
rendering: "aoeuaoeu", rendering: "aoeuaoeu",
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
}, },
]); ]);
expectStatus(vresp, video).toBe(201); expectStatus(vresp, video).toBe(201);

View File

@ -27,6 +27,7 @@ beforeAll(async () => {
title: "mia", title: "mia",
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s1e13.mkv", path: "/video/mia s1e13.mkv",
@ -40,6 +41,7 @@ beforeAll(async () => {
episodes: [{ season: 2, episode: 1 }], episodes: [{ season: 2, episode: 1 }],
years: [2017], years: [2017],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia 2017 s2e1.mkv", path: "/video/mia 2017 s2e1.mkv",
@ -48,7 +50,7 @@ beforeAll(async () => {
for: [{ slug: `${madeInAbyss.slug}-s2e1` }], for: [{ slug: `${madeInAbyss.slug}-s2e1` }],
}, },
{ {
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
part: null, part: null,
path: "/video/bubble.mkv", path: "/video/bubble.mkv",
rendering: "sha5", rendering: "sha5",
@ -110,6 +112,7 @@ describe("Video get/deletion", () => {
title: "mia", title: "mia",
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s1e13 unknown test.mkv", path: "/video/mia s1e13 unknown test.mkv",
@ -148,6 +151,7 @@ describe("Video get/deletion", () => {
title: "mia", title: "mia",
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s1e13 mismatch.mkv", path: "/video/mia s1e13 mismatch.mkv",

View File

@ -18,7 +18,7 @@ beforeAll(async () => {
describe("Video seeding", () => { describe("Video seeding", () => {
it("Can create a video without entry", async () => { it("Can create a video without entry", async () => {
const [resp, body] = await createVideo({ const [resp, body] = await createVideo({
guess: { title: "unknown", from: "test" }, guess: { title: "unknown", from: "test", history: [] },
part: null, part: null,
path: "/video/unknown s1e13.mkv", path: "/video/unknown s1e13.mkv",
rendering: "sha", rendering: "sha",
@ -50,6 +50,7 @@ describe("Video seeding", () => {
title: "mia", title: "mia",
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s1e13.mkv", path: "/video/mia s1e13.mkv",
@ -82,7 +83,7 @@ describe("Video seeding", () => {
it("With movie", async () => { it("With movie", async () => {
const [resp, body] = await createVideo({ const [resp, body] = await createVideo({
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
part: null, part: null,
path: "/video/bubble.mkv", path: "/video/bubble.mkv",
rendering: "sha3", rendering: "sha3",
@ -114,7 +115,7 @@ describe("Video seeding", () => {
it("Conflicting path", async () => { it("Conflicting path", async () => {
const [resp, body] = await createVideo({ const [resp, body] = await createVideo({
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
part: null, part: null,
path: "/video/bubble.mkv", path: "/video/bubble.mkv",
rendering: "sha4", rendering: "sha4",
@ -150,6 +151,7 @@ describe("Video seeding", () => {
title: "mia", title: "mia",
episodes: [{ season: 2, episode: 1 }], episodes: [{ season: 2, episode: 1 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s2e1.mkv", path: "/video/mia s2e1.mkv",
@ -192,6 +194,7 @@ describe("Video seeding", () => {
title: "mia", title: "mia",
episodes: [{ season: 0, episode: 3 }], episodes: [{ season: 0, episode: 3 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia sp3.mkv", path: "/video/mia sp3.mkv",
@ -233,6 +236,7 @@ describe("Video seeding", () => {
title: "mia", title: "mia",
episodes: [{ season: 0, episode: 3 }], episodes: [{ season: 0, episode: 3 }],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia 13.5.mkv", path: "/video/mia 13.5.mkv",
@ -274,6 +278,7 @@ describe("Video seeding", () => {
title: "mia", title: "mia",
episodes: [{ season: 1, episode: 13 }], episodes: [{ season: 1, episode: 13 }],
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "72636", themoviedatabase: "72636",
}, },
@ -318,6 +323,7 @@ describe("Video seeding", () => {
guess: { guess: {
title: "bubble", title: "bubble",
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "912598", themoviedatabase: "912598",
}, },
@ -359,7 +365,7 @@ describe("Video seeding", () => {
it("Different path, same sha", async () => { it("Different path, same sha", async () => {
const [resp, body] = await createVideo({ const [resp, body] = await createVideo({
guess: { title: "bubble", from: "test" }, guess: { title: "bubble", from: "test", history: [] },
part: null, part: null,
path: "/video/bubble invalid-sha.mkv", path: "/video/bubble invalid-sha.mkv",
rendering: "sha", rendering: "sha",
@ -377,6 +383,7 @@ describe("Video seeding", () => {
guess: { guess: {
title: "bubble", title: "bubble",
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "912598", themoviedatabase: "912598",
}, },
@ -423,6 +430,7 @@ describe("Video seeding", () => {
guess: { guess: {
title: "bubble", title: "bubble",
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "912598", themoviedatabase: "912598",
}, },
@ -470,6 +478,7 @@ describe("Video seeding", () => {
guess: { guess: {
title: "bubble", title: "bubble",
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "912598", themoviedatabase: "912598",
}, },
@ -491,6 +500,7 @@ describe("Video seeding", () => {
guess: { guess: {
title: "bubble", title: "bubble",
from: "test", from: "test",
history: [],
externalId: { externalId: {
themoviedatabase: "912598", themoviedatabase: "912598",
}, },
@ -541,6 +551,7 @@ describe("Video seeding", () => {
{ season: 2, episode: 1 }, { season: 2, episode: 1 },
], ],
from: "test", from: "test",
history: [],
}, },
part: null, part: null,
path: "/video/mia s1e13 & s2e1 [tmdb=72636].mkv", path: "/video/mia s1e13 & s2e1 [tmdb=72636].mkv",

View File

@ -8,7 +8,7 @@ x-transcoder: &transcoder-base
- transcoder - transcoder
ports: ports:
- "7666:7666" - "7666:7666"
restart: on-failure restart: unless-stopped
cpus: 1 cpus: 1
env_file: env_file:
- ./.env - ./.env
@ -39,7 +39,7 @@ services:
# ports: # ports:
# - "3000:3000" # - "3000:3000"
# - "8081:8081" # - "8081:8081"
# restart: on-failure # restart: unless-stopped
# environment: # environment:
# - KYOO_URL=${KYOO_URL:-http://api:5000/api} # - KYOO_URL=${KYOO_URL:-http://api:5000/api}
# labels: # labels:
@ -50,7 +50,7 @@ services:
build: build:
context: ./auth context: ./auth
dockerfile: Dockerfile.dev dockerfile: Dockerfile.dev
restart: on-failure restart: unless-stopped
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
@ -71,7 +71,7 @@ services:
build: build:
context: ./api context: ./api
dockerfile: Dockerfile.dev dockerfile: Dockerfile.dev
restart: on-failure restart: unless-stopped
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
@ -99,7 +99,7 @@ services:
scanner: scanner:
build: ./scanner build: ./scanner
restart: on-failure restart: unless-stopped
depends_on: depends_on:
api: api:
condition: service_started condition: service_started
@ -172,7 +172,7 @@ services:
traefik: traefik:
image: traefik:v3.4 image: traefik:v3.4
restart: on-failure restart: unless-stopped
command: command:
- "--providers.docker=true" - "--providers.docker=true"
- "--providers.docker.exposedbydefault=false" - "--providers.docker.exposedbydefault=false"
@ -185,7 +185,7 @@ services:
postgres: postgres:
image: postgres:15 image: postgres:15
restart: on-failure restart: unless-stopped
env_file: env_file:
- ./.env - ./.env
volumes: volumes: