mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Move resources to ~/models
This commit is contained in:
parent
0f2474cb11
commit
930fb3edfc
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
|
||||
export const CollectionP = ResourceP("collection")
|
||||
.merge(ImagesP)
|
||||
.extend({
|
||||
/**
|
||||
* The title of this collection.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The summary of this show.
|
||||
*/
|
||||
overview: z.string().nullable(),
|
||||
})
|
||||
.transform((x) => ({
|
||||
...x,
|
||||
href: `/collection/${x.slug}`,
|
||||
}));
|
||||
|
||||
/**
|
||||
* A class representing collections of show or movies.
|
||||
*/
|
||||
export type Collection = z.infer<typeof CollectionP>;
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export enum Genre {
|
||||
Action = "Action",
|
||||
Adventure = "Adventure",
|
||||
Animation = "Animation",
|
||||
Comedy = "Comedy",
|
||||
Crime = "Crime",
|
||||
Documentary = "Documentary",
|
||||
Drama = "Drama",
|
||||
Family = "Family",
|
||||
Fantasy = "Fantasy",
|
||||
History = "History",
|
||||
Horror = "Horror",
|
||||
Music = "Music",
|
||||
Mystery = "Mystery",
|
||||
Romance = "Romance",
|
||||
ScienceFiction = "ScienceFiction",
|
||||
Thriller = "Thriller",
|
||||
War = "War",
|
||||
Western = "Western",
|
||||
Kids = "Kids",
|
||||
News = "News",
|
||||
Reality = "Reality",
|
||||
Soap = "Soap",
|
||||
Talk = "Talk",
|
||||
Politics = "Politics",
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./library-item";
|
||||
export * from "./news";
|
||||
export * from "./show";
|
||||
export * from "./movie";
|
||||
export * from "./collection";
|
||||
export * from "./genre";
|
||||
export * from "./person";
|
||||
export * from "./studio";
|
||||
export * from "./episode";
|
||||
export * from "./season";
|
||||
export * from "./watch-info";
|
||||
export * from "./watch-status";
|
||||
export * from "./watchlist";
|
||||
export * from "./user";
|
||||
export * from "./server-info";
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { CollectionP } from "./collection";
|
||||
import { MovieP } from "./movie";
|
||||
import { ShowP } from "./show";
|
||||
|
||||
export const LibraryItemP = z.union([
|
||||
/*
|
||||
* Either a Show
|
||||
*/
|
||||
ShowP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
/*
|
||||
* Or a Collection
|
||||
*/
|
||||
CollectionP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* An item that can be contained by a Library (so a Show, a Movie or a Collection).
|
||||
*/
|
||||
export type LibraryItem = z.infer<typeof LibraryItemP>;
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
export const MetadataP = z.preprocess(
|
||||
(x) =>
|
||||
typeof x === "object" && x ? Object.fromEntries(Object.entries(x).filter(([_, v]) => v)) : x,
|
||||
z.record(
|
||||
z.object({
|
||||
/*
|
||||
* The ID of the resource on the external provider.
|
||||
*/
|
||||
dataId: z.string(),
|
||||
|
||||
/*
|
||||
* The URL of the resource on the external provider.
|
||||
*/
|
||||
link: z.string().nullable(),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
export type Metadata = z.infer<typeof MetadataP>;
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { EpisodeP } from "./episode";
|
||||
import { MovieP } from "./movie";
|
||||
|
||||
export const NewsP = z.union([
|
||||
/*
|
||||
* Either an episode
|
||||
*/
|
||||
EpisodeP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* A new item added to kyoo.
|
||||
*/
|
||||
export type News = z.infer<typeof NewsP>;
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
|
||||
export const PersonP = ResourceP("people").merge(ImagesP).extend({
|
||||
/**
|
||||
* The name of this person.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The type of work the person has done for the show. That can be something like "Actor",
|
||||
* "Writer", "Music", "Voice Actor"...
|
||||
*/
|
||||
type: z.string().optional(),
|
||||
|
||||
/**
|
||||
* The role the People played. This is mostly used to inform witch character was played for actor
|
||||
* and voice actors.
|
||||
*/
|
||||
role: z.string().optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A studio that make shows.
|
||||
*/
|
||||
export type Person = z.infer<typeof PersonP>;
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
export const QualityP = z
|
||||
.union([
|
||||
z.literal("original"),
|
||||
z.literal("8k"),
|
||||
z.literal("4k"),
|
||||
z.literal("1440p"),
|
||||
z.literal("1080p"),
|
||||
z.literal("720p"),
|
||||
z.literal("480p"),
|
||||
z.literal("360p"),
|
||||
z.literal("240p"),
|
||||
])
|
||||
.default("original");
|
||||
|
||||
/**
|
||||
* A Video Quality Enum.
|
||||
*/
|
||||
export type Quality = z.infer<typeof QualityP>;
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
import { zdate } from "../utils";
|
||||
|
||||
export const SeasonP = ResourceP("season").merge(ImagesP).extend({
|
||||
/**
|
||||
* The name of this season.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The number of this season. This can be set to 0 to indicate specials.
|
||||
*/
|
||||
seasonNumber: z.number(),
|
||||
/**
|
||||
* A quick overview of this season.
|
||||
*/
|
||||
overview: z.string().nullable(),
|
||||
/**
|
||||
* The starting air date of this season.
|
||||
*/
|
||||
startDate: zdate().nullable(),
|
||||
/**
|
||||
* The ending date of this season.
|
||||
*/
|
||||
endDate: zdate().nullable(),
|
||||
/**
|
||||
* The number of episodes available on kyoo of this season.
|
||||
*/
|
||||
episodesCount: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A season of a Show.
|
||||
*/
|
||||
export type Season = z.infer<typeof SeasonP>;
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ResourceP } from "../traits/resource";
|
||||
|
||||
export const StudioP = ResourceP("studio").extend({
|
||||
/**
|
||||
* The name of this studio.
|
||||
*/
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A studio that make shows.
|
||||
*/
|
||||
export type Studio = z.infer<typeof StudioP>;
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { MovieP } from "./movie";
|
||||
import { ShowP } from "./show";
|
||||
|
||||
export const WatchlistP = z.union([
|
||||
/*
|
||||
* Either a show
|
||||
*/
|
||||
ShowP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* A item in the user's watchlist.
|
||||
*/
|
||||
export type Watchlist = z.infer<typeof WatchlistP>;
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./resource";
|
||||
export * from "./images";
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
export const ResourceP = <T extends string>(kind: T) =>
|
||||
z.object({
|
||||
/**
|
||||
* A unique ID for this type of resource. This can't be changed and duplicates are not allowed.
|
||||
*/
|
||||
id: z.string(),
|
||||
|
||||
/**
|
||||
* A human-readable identifier that can be used instead of an ID. A slug must be unique for a type
|
||||
* of resource but it can be changed.
|
||||
*/
|
||||
slug: z.string(),
|
||||
|
||||
/**
|
||||
* The type of resource
|
||||
*/
|
||||
kind: z.literal(kind),
|
||||
});
|
||||
|
||||
/**
|
||||
* The base trait used to represent identifiable resources.
|
||||
*/
|
||||
export type Resource = z.infer<ReturnType<typeof ResourceP>>;
|
3
front/src/models/index.ts
Normal file
3
front/src/models/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./page";
|
||||
export * from "./kyoo-error";
|
||||
export * from "./resources";
|
24
front/src/models/resources/collection.ts
Normal file
24
front/src/models/resources/collection.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
|
||||
export const CollectionP = ResourceP("collection")
|
||||
.merge(ImagesP)
|
||||
.extend({
|
||||
/**
|
||||
* The title of this collection.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The summary of this show.
|
||||
*/
|
||||
overview: z.string().nullable(),
|
||||
})
|
||||
.transform((x) => ({
|
||||
...x,
|
||||
href: `/collection/${x.slug}`,
|
||||
}));
|
||||
|
||||
/**
|
||||
* A class representing collections of show or movies.
|
||||
*/
|
||||
export type Collection = z.infer<typeof CollectionP>;
|
@ -1,26 +1,5 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, imageFn } from "../traits";
|
||||
import { ResourceP } from "../traits/resource";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
import { zdate } from "../utils";
|
||||
|
||||
export const BaseEpisodeP = ResourceP("episode")
|
||||
@ -62,11 +41,11 @@ export const BaseEpisodeP = ResourceP("episode")
|
||||
/**
|
||||
* The direct link to the unprocessed video (pristine quality).
|
||||
*/
|
||||
direct: z.string().transform(imageFn),
|
||||
direct: z.string(),
|
||||
/**
|
||||
* The link to an HLS master playlist containing all qualities available for this video.
|
||||
*/
|
||||
hls: z.string().transform(imageFn).nullable(),
|
||||
hls: z.string().nullable(),
|
||||
}),
|
||||
/**
|
||||
* The id of the show containing this episode
|
@ -1,23 +1,3 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { BaseEpisodeP } from "./episode.base";
|
||||
import { ShowP } from "./show";
|
26
front/src/models/resources/genre.ts
Normal file
26
front/src/models/resources/genre.ts
Normal file
@ -0,0 +1,26 @@
|
||||
export enum Genre {
|
||||
Action = "Action",
|
||||
Adventure = "Adventure",
|
||||
Animation = "Animation",
|
||||
Comedy = "Comedy",
|
||||
Crime = "Crime",
|
||||
Documentary = "Documentary",
|
||||
Drama = "Drama",
|
||||
Family = "Family",
|
||||
Fantasy = "Fantasy",
|
||||
History = "History",
|
||||
Horror = "Horror",
|
||||
Music = "Music",
|
||||
Mystery = "Mystery",
|
||||
Romance = "Romance",
|
||||
ScienceFiction = "ScienceFiction",
|
||||
Thriller = "Thriller",
|
||||
War = "War",
|
||||
Western = "Western",
|
||||
Kids = "Kids",
|
||||
News = "News",
|
||||
Reality = "Reality",
|
||||
Soap = "Soap",
|
||||
Talk = "Talk",
|
||||
Politics = "Politics",
|
||||
}
|
15
front/src/models/resources/index.ts
Normal file
15
front/src/models/resources/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export * from "./library-item";
|
||||
export * from "./news";
|
||||
export * from "./show";
|
||||
export * from "./movie";
|
||||
export * from "./collection";
|
||||
export * from "./genre";
|
||||
export * from "./person";
|
||||
export * from "./studio";
|
||||
export * from "./episode";
|
||||
export * from "./season";
|
||||
export * from "./watch-info";
|
||||
export * from "./watch-status";
|
||||
export * from "./watchlist";
|
||||
export * from "./user";
|
||||
export * from "./server-info";
|
24
front/src/models/resources/library-item.ts
Normal file
24
front/src/models/resources/library-item.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import { CollectionP } from "./collection";
|
||||
import { MovieP } from "./movie";
|
||||
import { ShowP } from "./show";
|
||||
|
||||
export const LibraryItemP = z.union([
|
||||
/*
|
||||
* Either a Show
|
||||
*/
|
||||
ShowP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
/*
|
||||
* Or a Collection
|
||||
*/
|
||||
CollectionP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* An item that can be contained by a Library (so a Show, a Movie or a Collection).
|
||||
*/
|
||||
export type LibraryItem = z.infer<typeof LibraryItemP>;
|
21
front/src/models/resources/metadata.ts
Normal file
21
front/src/models/resources/metadata.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const MetadataP = z.preprocess(
|
||||
(x) =>
|
||||
typeof x === "object" && x ? Object.fromEntries(Object.entries(x).filter(([_, v]) => v)) : x,
|
||||
z.record(
|
||||
z.object({
|
||||
/*
|
||||
* The ID of the resource on the external provider.
|
||||
*/
|
||||
dataId: z.string(),
|
||||
|
||||
/*
|
||||
* The URL of the resource on the external provider.
|
||||
*/
|
||||
link: z.string().nullable(),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
export type Metadata = z.infer<typeof MetadataP>;
|
@ -1,25 +1,5 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP, imageFn } from "../traits";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
import { zdate } from "../utils";
|
||||
import { CollectionP } from "./collection";
|
||||
import { Genre } from "./genre";
|
||||
@ -90,12 +70,12 @@ export const MovieP = ResourceP("movie")
|
||||
/**
|
||||
* The direct link to the unprocessed video (pristine quality).
|
||||
*/
|
||||
direct: z.string().transform(imageFn),
|
||||
direct: z.string(),
|
||||
|
||||
/**
|
||||
* The link to an HLS master playlist containing all qualities available for this video.
|
||||
*/
|
||||
hls: z.string().transform(imageFn).nullable(),
|
||||
hls: z.string().nullable(),
|
||||
}),
|
||||
/**
|
||||
* The link to metadata providers that this show has.
|
19
front/src/models/resources/news.ts
Normal file
19
front/src/models/resources/news.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { z } from "zod";
|
||||
import { EpisodeP } from "./episode";
|
||||
import { MovieP } from "./movie";
|
||||
|
||||
export const NewsP = z.union([
|
||||
/*
|
||||
* Either an episode
|
||||
*/
|
||||
EpisodeP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* A new item added to kyoo.
|
||||
*/
|
||||
export type News = z.infer<typeof NewsP>;
|
25
front/src/models/resources/person.ts
Normal file
25
front/src/models/resources/person.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
|
||||
export const PersonP = ResourceP("people").merge(ImagesP).extend({
|
||||
/**
|
||||
* The name of this person.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The type of work the person has done for the show. That can be something like "Actor",
|
||||
* "Writer", "Music", "Voice Actor"...
|
||||
*/
|
||||
type: z.string().optional(),
|
||||
|
||||
/**
|
||||
* The role the People played. This is mostly used to inform witch character was played for actor
|
||||
* and voice actors.
|
||||
*/
|
||||
role: z.string().optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A studio that make shows.
|
||||
*/
|
||||
export type Person = z.infer<typeof PersonP>;
|
20
front/src/models/resources/quality.ts
Normal file
20
front/src/models/resources/quality.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const QualityP = z
|
||||
.union([
|
||||
z.literal("original"),
|
||||
z.literal("8k"),
|
||||
z.literal("4k"),
|
||||
z.literal("1440p"),
|
||||
z.literal("1080p"),
|
||||
z.literal("720p"),
|
||||
z.literal("480p"),
|
||||
z.literal("360p"),
|
||||
z.literal("240p"),
|
||||
])
|
||||
.default("original");
|
||||
|
||||
/**
|
||||
* A Video Quality Enum.
|
||||
*/
|
||||
export type Quality = z.infer<typeof QualityP>;
|
35
front/src/models/resources/season.ts
Normal file
35
front/src/models/resources/season.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
import { zdate } from "../utils";
|
||||
|
||||
export const SeasonP = ResourceP("season").merge(ImagesP).extend({
|
||||
/**
|
||||
* The name of this season.
|
||||
*/
|
||||
name: z.string(),
|
||||
/**
|
||||
* The number of this season. This can be set to 0 to indicate specials.
|
||||
*/
|
||||
seasonNumber: z.number(),
|
||||
/**
|
||||
* A quick overview of this season.
|
||||
*/
|
||||
overview: z.string().nullable(),
|
||||
/**
|
||||
* The starting air date of this season.
|
||||
*/
|
||||
startDate: zdate().nullable(),
|
||||
/**
|
||||
* The ending date of this season.
|
||||
*/
|
||||
endDate: zdate().nullable(),
|
||||
/**
|
||||
* The number of episodes available on kyoo of this season.
|
||||
*/
|
||||
episodesCount: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A season of a Show.
|
||||
*/
|
||||
export type Season = z.infer<typeof SeasonP>;
|
@ -1,26 +1,5 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Platform } from "react-native";
|
||||
import { z } from "zod";
|
||||
import { imageFn } from "..";
|
||||
|
||||
export const OidcInfoP = z.object({
|
||||
/*
|
||||
@ -28,7 +7,7 @@ export const OidcInfoP = z.object({
|
||||
*/
|
||||
displayName: z.string(),
|
||||
/*
|
||||
* A url returing a square logo for this provider.
|
||||
* A url returning a square logo for this provider.
|
||||
*/
|
||||
logoUrl: z.string().nullable(),
|
||||
});
|
||||
@ -71,7 +50,7 @@ export const ServerInfoP = z
|
||||
provider,
|
||||
{
|
||||
...info,
|
||||
link: imageFn(`/auth/login/${provider}?redirectUrl=${baseUrl}/login/callback`),
|
||||
link: `/auth/login/${provider}?redirectUrl=${baseUrl}/login/callback`,
|
||||
},
|
||||
]),
|
||||
),
|
@ -1,23 +1,3 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ImagesP, ResourceP } from "../traits";
|
||||
import { zdate } from "../utils";
|
14
front/src/models/resources/studio.ts
Normal file
14
front/src/models/resources/studio.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { z } from "zod";
|
||||
import { ResourceP } from "../traits";
|
||||
|
||||
export const StudioP = ResourceP("studio").extend({
|
||||
/**
|
||||
* The name of this studio.
|
||||
*/
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* A studio that make shows.
|
||||
*/
|
||||
export type Studio = z.infer<typeof StudioP>;
|
@ -1,26 +1,5 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { imageFn } from "../traits/images";
|
||||
import { ResourceP } from "../traits/resource";
|
||||
import { ResourceP } from "../traits";
|
||||
|
||||
export const UserP = ResourceP("user")
|
||||
.extend({
|
||||
@ -80,7 +59,7 @@ export const UserP = ResourceP("user")
|
||||
})
|
||||
.transform((x) => ({
|
||||
...x,
|
||||
logo: imageFn(`/user/${x.slug}/logo`),
|
||||
logo: `/user/${x.slug}/logo`,
|
||||
isVerified: x.permissions.length > 0,
|
||||
isAdmin: x.permissions?.includes("admin.write"),
|
||||
}));
|
@ -1,25 +1,4 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { imageFn } from "../traits";
|
||||
import { QualityP } from "./quality";
|
||||
|
||||
/**
|
||||
@ -90,7 +69,7 @@ export const SubtitleP = TrackP.extend({
|
||||
/*
|
||||
* The url of this track (only if this is a subtitle)..
|
||||
*/
|
||||
link: z.string().transform(imageFn).nullable(),
|
||||
link: z.string().nullable(),
|
||||
/*
|
||||
* Is this an external subtitle (as in stored in a different file)
|
||||
*/
|
||||
@ -169,7 +148,7 @@ export const WatchInfoP = z
|
||||
/**
|
||||
* The list of fonts that can be used to display subtitles.
|
||||
*/
|
||||
fonts: z.array(z.string().transform(imageFn)),
|
||||
fonts: z.array(z.string()),
|
||||
/**
|
||||
* The list of chapters. See Chapter for more information.
|
||||
*/
|
@ -1,23 +1,3 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { zdate } from "../utils";
|
||||
import { BaseEpisodeP } from "./episode.base";
|
19
front/src/models/resources/watchlist.ts
Normal file
19
front/src/models/resources/watchlist.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { z } from "zod";
|
||||
import { MovieP } from "./movie";
|
||||
import { ShowP } from "./show";
|
||||
|
||||
export const WatchlistP = z.union([
|
||||
/*
|
||||
* Either a show
|
||||
*/
|
||||
ShowP,
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
MovieP,
|
||||
]);
|
||||
|
||||
/**
|
||||
* A item in the user's watchlist.
|
||||
*/
|
||||
export type Watchlist = z.infer<typeof WatchlistP>;
|
@ -1,36 +1,11 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Platform } from "react-native";
|
||||
import { z } from "zod";
|
||||
import { lastUsedUrl } from "..";
|
||||
|
||||
export const imageFn = (url: string) =>
|
||||
Platform.OS === "web" ? `/api${url}` : `${lastUsedUrl}${url}`;
|
||||
|
||||
export const Img = z.object({
|
||||
source: z.string(),
|
||||
blurhash: z.string(),
|
||||
low: z.string().transform(imageFn),
|
||||
medium: z.string().transform(imageFn),
|
||||
high: z.string().transform(imageFn),
|
||||
low: z.string(),
|
||||
medium: z.string(),
|
||||
high: z.string(),
|
||||
});
|
||||
|
||||
export const ImagesP = z.object({
|
2
front/src/models/traits/index.ts
Normal file
2
front/src/models/traits/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./resource";
|
||||
export * from "./images";
|
25
front/src/models/traits/resource.ts
Normal file
25
front/src/models/traits/resource.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const ResourceP = <T extends string>(kind: T) =>
|
||||
z.object({
|
||||
/**
|
||||
* A unique ID for this type of resource. This can't be changed and duplicates are not allowed.
|
||||
*/
|
||||
id: z.string(),
|
||||
|
||||
/**
|
||||
* A human-readable identifier that can be used instead of an ID. A slug must be unique for a type
|
||||
* of resource but it can be changed.
|
||||
*/
|
||||
slug: z.string(),
|
||||
|
||||
/**
|
||||
* The type of resource
|
||||
*/
|
||||
kind: z.literal(kind),
|
||||
});
|
||||
|
||||
/**
|
||||
* The base trait used to represent identifiable resources.
|
||||
*/
|
||||
export type Resource = z.infer<ReturnType<typeof ResourceP>>;
|
3
front/src/models/utils.ts
Normal file
3
front/src/models/utils.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const zdate = z.coerce.date;
|
@ -1,6 +1,6 @@
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { type ReactNode, useState } from "react";
|
||||
import { createQueryClient } from "~/models/query";
|
||||
import { createQueryClient } from "~/query";
|
||||
// import { useUserTheme } from "@kyoo/models";
|
||||
import { ThemeSelector } from "~/primitives/theme";
|
||||
|
||||
|
@ -6,9 +6,8 @@ import {
|
||||
} from "@tanstack/react-query";
|
||||
import type { ComponentType, ReactElement } from "react";
|
||||
import type { z } from "zod";
|
||||
import type { KyooError } from "./kyoo-error";
|
||||
import { type KyooError, type Page, Paged } from "~/models";
|
||||
// import { getToken, getTokenWJ } from "./login";
|
||||
import { type Page, Paged } from "./page";
|
||||
|
||||
export let lastUsedUrl: string = null!;
|
||||
|
Loading…
x
Reference in New Issue
Block a user