Add Show, Movie, Collection and Library types

This commit is contained in:
Zoe Roux 2022-07-17 18:42:14 +02:00
parent a3bdb8953c
commit fb436fd0f5
12 changed files with 476 additions and 0 deletions

24
front/src/models/index.ts Normal file
View File

@ -0,0 +1,24 @@
/*
* 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 type { Page } from "./page";
export type { KyooErrors } from "./kyoo-errors";
export * from "./traits";
export * from "./resources";

View File

@ -0,0 +1,31 @@
/*
* 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/>.
*/
/**
* The list of errors that where made in the request.
*/
export interface KyooErrors {
/**
* The list of errors that where made in the request.
*
* @example `["InvalidFilter: no field 'startYear' on a collection"]`
*/
errors: string[];
}

55
front/src/models/page.ts Normal file
View File

@ -0,0 +1,55 @@
/*
* 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/>.
*/
/**
* A page of resource that contains information about the pagination of resources.
*/
export interface Page<T> {
/**
* The link of the current page.
*
* @format uri
*/
this: string;
/**
* The link of the first page.
*
* @format uri
*/
first: string;
/**
* The link of the next page.
*
* @format uri
*/
next?: string;
/**
* The number of items in the current page.
*/
count: number;
/**
* The list of items in the page.
*/
items: T[];
}

View File

@ -0,0 +1,36 @@
/*
* 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 { Images, Resource } from "../traits";
/**
* A class representing collections of show or movies.
*/
export interface Collection extends Resource, Images {
/**
* The name of this collection.
*/
name: string;
/**
* The description of this collection.
*/
overview: string;
}

View File

@ -0,0 +1,25 @@
/*
* 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";
export * from "./library-item";
export * from "./show";
export * from "./movie";
export * from "./collection";

View File

@ -0,0 +1,40 @@
/*
* 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 { Collection } from "./collection";
import { Movie } from "./movie";
import { Show } from "./show";
/**
* An item that can be contained by a Library (so a Show, a Movie or a Collection).
*/
export type LibraryItem =
| (Show & { type: ItemType.Show })
| (Movie & { type: ItemType.Movie })
| (Collection & { type: ItemType.Collection });
/**
* The type of item, ether a show, a movie or a collection.
*/
export enum ItemType {
Show = 0,
Movie = 1,
Collection = 2,
}

View File

@ -0,0 +1,36 @@
/*
* 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 { Resource } from "../traits/resource";
/**
* The library that will contain Shows, Collections...
*/
export interface Library extends Resource {
/**
* The name of this library.
*/
name: string;
/**
* The list of paths that this library is responsible for. This is mainly used by the Scan task.
*/
paths: string[];
}

View File

@ -0,0 +1,51 @@
/*
* 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 { Resource, Images } from "../traits";
/**
* A series or a movie.
*/
export interface Movie extends Resource, Images {
/**
* The title of this show.
*/
name: string;
/**
* The list of alternative titles of this movie.
*/
aliases: string[];
/**
* The summary of this show.
*/
overview: string;
/**
* Is this movie aired or planned
*/
isPlanned: boolean;
/**
* The date this mavie aired. It can also be null if this is unknown.
*/
airDate: Date | null;
}

View File

@ -0,0 +1,66 @@
/*
* 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 { Resource, Images } from "../traits";
/**
* A series or a movie.
*/
export interface Show extends Resource, Images {
/**
* The title of this show.
*/
name: string;
/**
* The list of alternative titles of this show.
*/
aliases: string[];
/**
* The summary of this show.
*/
overview: string;
/**
* Is this show airing, not aired yet or finished?
*/
status: Status;
/**
* The date this show started airing. It can be null if this is unknown.
*/
startAir: Date | null;
/**
* The date this show finished airing. It can also be null if this is unknown.
*/
endAir: Date | null;
}
/**
* The enum containing show's status.
*/
export enum Status {
Unknown = 0,
Finished = 1,
Airing = 2,
Planned = 3,
}

View File

@ -0,0 +1,55 @@
/*
* 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/>.
*/
/**
* Base traits for items that has image resources.
*/
export interface Images {
/**
* An url to the poster of this resource. If this resource does not have an image, the link will
* be null. If the kyoo's instance is not capable of handling this kind of image for the specific
* resource, this field won't be present.
*/
poster?: string;
/**
* An url to the thumbnail of this resource. If this resource does not have an image, the link
* will be null. If the kyoo's instance is not capable of handling this kind of image for the
* specific resource, this field won't be present.
*/
thumbnail?: string;
/**
* An url to the logo of this resource. If this resource does not have an image, the link will be
* null. If the kyoo's instance is not capable of handling this kind of image for the specific
* resource, this field won't be present.
*/
logo?: string;
/**
* An url to the thumbnail of this resource. If this resource does not have an image, the link
* will be null. If the kyoo's instance is not capable of handling this kind of image for the
* specific resource, this field won't be present.
*/
trailer?: string;
};
export const imageList = ["poster", "thumbnail", "logo", "trailer"];

View File

@ -0,0 +1,22 @@
/*
* 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";

View File

@ -0,0 +1,35 @@
/*
* 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/>.
*/
/**
* The base trait used to represent identifiable resources.
*/
export interface Resource {
/**
* A unique ID for this type of resource. This can't be changed and duplicates are not allowed.
*/
id: number;
/**
* 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: string;
}