mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Add Show, Movie, Collection and Library types
This commit is contained in:
parent
a3bdb8953c
commit
fb436fd0f5
24
front/src/models/index.ts
Normal file
24
front/src/models/index.ts
Normal 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";
|
31
front/src/models/kyoo-errors.ts
Normal file
31
front/src/models/kyoo-errors.ts
Normal 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
55
front/src/models/page.ts
Normal 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[];
|
||||
}
|
36
front/src/models/resources/collection.ts
Normal file
36
front/src/models/resources/collection.ts
Normal 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;
|
||||
}
|
25
front/src/models/resources/index.ts
Normal file
25
front/src/models/resources/index.ts
Normal 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";
|
40
front/src/models/resources/library-item.ts
Normal file
40
front/src/models/resources/library-item.ts
Normal 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,
|
||||
}
|
36
front/src/models/resources/library.ts
Normal file
36
front/src/models/resources/library.ts
Normal 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[];
|
||||
}
|
51
front/src/models/resources/movie.ts
Normal file
51
front/src/models/resources/movie.ts
Normal 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;
|
||||
}
|
66
front/src/models/resources/show.ts
Normal file
66
front/src/models/resources/show.ts
Normal 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,
|
||||
}
|
55
front/src/models/traits/images.ts
Normal file
55
front/src/models/traits/images.ts
Normal 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"];
|
22
front/src/models/traits/index.ts
Normal file
22
front/src/models/traits/index.ts
Normal 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";
|
35
front/src/models/traits/resource.ts
Normal file
35
front/src/models/traits/resource.ts
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user