mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Add ratings
This commit is contained in:
parent
3e39ef1705
commit
15a4280a36
@ -94,6 +94,11 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Status Status { get; set; }
|
public Status Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How well this item is rated? (from 0 to 100).
|
||||||
|
/// </summary>
|
||||||
|
public int Rating { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date this show started airing. It can be null if this is unknown.
|
/// The date this show started airing. It can be null if this is unknown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -90,6 +90,11 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Status? Status { get; set; }
|
public Status? Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How well this item is rated? (from 0 to 100).
|
||||||
|
/// </summary>
|
||||||
|
public int Rating { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date this movie aired.
|
/// The date this movie aired.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Kyoo.Abstractions.Controllers;
|
|
||||||
using Kyoo.Abstractions.Models.Attributes;
|
using Kyoo.Abstractions.Models.Attributes;
|
||||||
using Kyoo.Utils;
|
using Kyoo.Utils;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -78,6 +77,11 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Status Status { get; set; }
|
public Status Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How well this item is rated? (from 0 to 100).
|
||||||
|
/// </summary>
|
||||||
|
public int Rating { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date this movie aired.
|
/// The date this movie aired.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -72,6 +72,11 @@ namespace Kyoo.Abstractions.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Status Status { get; set; }
|
public Status Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How well this item is rated? (from 0 to 100).
|
||||||
|
/// </summary>
|
||||||
|
public int Rating { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date this show started airing. It can be null if this is unknown.
|
/// The date this show started airing. It can be null if this is unknown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -60,12 +60,23 @@ namespace Kyoo.Meiliseach
|
|||||||
{
|
{
|
||||||
CamelCase.ConvertName(nameof(LibraryItem.AirDate)),
|
CamelCase.ConvertName(nameof(LibraryItem.AirDate)),
|
||||||
CamelCase.ConvertName(nameof(LibraryItem.AddedDate)),
|
CamelCase.ConvertName(nameof(LibraryItem.AddedDate)),
|
||||||
|
CamelCase.ConvertName(nameof(LibraryItem.Rating)),
|
||||||
},
|
},
|
||||||
DisplayedAttributes = new[]
|
DisplayedAttributes = new[]
|
||||||
{
|
{
|
||||||
CamelCase.ConvertName(nameof(LibraryItem.Id)),
|
CamelCase.ConvertName(nameof(LibraryItem.Id)),
|
||||||
CamelCase.ConvertName(nameof(LibraryItem.Kind)),
|
CamelCase.ConvertName(nameof(LibraryItem.Kind)),
|
||||||
},
|
},
|
||||||
|
RankingRules = new[]
|
||||||
|
{
|
||||||
|
"words",
|
||||||
|
"typo",
|
||||||
|
"proximity",
|
||||||
|
"attribute",
|
||||||
|
"sort",
|
||||||
|
"exactness",
|
||||||
|
$"{CamelCase.ConvertName(nameof(LibraryItem.Rating))}:desc",
|
||||||
|
}
|
||||||
// TODO: Add stopwords
|
// TODO: Add stopwords
|
||||||
// TODO: Extend default ranking to add ratings.
|
// TODO: Extend default ranking to add ratings.
|
||||||
}
|
}
|
||||||
|
1863
back/src/Kyoo.Postgresql/Migrations/20231031212819_rating.Designer.cs
generated
Normal file
1863
back/src/Kyoo.Postgresql/Migrations/20231031212819_rating.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
120
back/src/Kyoo.Postgresql/Migrations/20231031212819_rating.cs
Normal file
120
back/src/Kyoo.Postgresql/Migrations/20231031212819_rating.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Kyoo.Postgresql.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Rating : Items
|
||||||
|
{
|
||||||
|
public static void CreateItemView(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
// language=PostgreSQL
|
||||||
|
migrationBuilder.Sql(@"
|
||||||
|
CREATE VIEW library_items AS
|
||||||
|
SELECT
|
||||||
|
s.id, s.slug, s.name, s.tagline, s.aliases, s.overview, s.tags, s.genres, s.status,
|
||||||
|
s.start_air, s.end_air, s.poster_source, s.poster_blurhash, s.thumbnail_source, s.thumbnail_blurhash,
|
||||||
|
s.logo_source, s.logo_blurhash, s.trailer, s.external_id, s.start_air AS air_date, NULL as path,
|
||||||
|
'show'::item_kind AS kind, s.added_date, s.rating
|
||||||
|
FROM shows AS s
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
-m.id, m.slug, m.name, m.tagline, m.aliases, m.overview, m.tags, m.genres, m.status,
|
||||||
|
m.air_date as start_air, m.air_date as end_air, m.poster_source, m.poster_blurhash, m.thumbnail_source,
|
||||||
|
m.thumbnail_blurhash, m.logo_source, m.logo_blurhash, m.trailer, m.external_id, m.air_date, m.path,
|
||||||
|
'movie'::item_kind AS kind, m.added_date, m.rating
|
||||||
|
FROM movies AS m
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
c.id + 10000 AS id, c.slug, c.name, NULL as tagline, NULL as alises, c.overview, NULL AS tags, NULL AS genres, 'unknown'::status AS status,
|
||||||
|
NULL AS start_air, NULL AS end_air, c.poster_source, c.poster_blurhash, c.thumbnail_source,
|
||||||
|
c.thumbnail_blurhash, c.logo_source, c.logo_blurhash, NULL as trailer, c.external_id, NULL AS air_date, NULL as path,
|
||||||
|
'collection'::item_kind AS kind, c.added_date, NULL as rating
|
||||||
|
FROM collections AS c
|
||||||
|
");
|
||||||
|
|
||||||
|
// language=PostgreSQL
|
||||||
|
migrationBuilder.Sql(@"
|
||||||
|
CREATE VIEW news AS
|
||||||
|
SELECT
|
||||||
|
e.id, e.slug, e.name, NULL AS tagline, '{}' AS aliases, e.path, e.overview, '{}' AS tags, '{}' AS genres,
|
||||||
|
NULL AS status, e.release_date AS air_date, e.poster_source, e.poster_blurhash, e.thumbnail_source, e.thumbnail_blurhash,
|
||||||
|
e.logo_source,e.logo_blurhash, NULL AS trailer, e.external_id, e.season_number, e.episode_number, e.absolute_number,
|
||||||
|
'episode'::news_kind AS kind, e.added_date, s.id AS show_id, s.slug AS show_slug, s.name AS show_name,
|
||||||
|
s.poster_source AS show_poster_source, s.poster_blurhash AS show_poster_blurhash, s.thumbnail_source AS show_thumbnail_source,
|
||||||
|
s.thumbnail_blurhash AS show_thumbnail_blurhash, s.logo_source AS show_logo_source, s.logo_blurhash AS show_logo_blurhash,
|
||||||
|
NULL as rating
|
||||||
|
FROM episodes AS e
|
||||||
|
LEFT JOIN shows AS s ON e.show_id = s.id
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
-m.id, m.slug, m.name, m.tagline, m.aliases, m.path, m.overview, m.tags, m.genres,
|
||||||
|
m.status, m.air_date, m.poster_source, m.poster_blurhash, m.thumbnail_source, m.thumbnail_blurhash,
|
||||||
|
m.logo_source, m.logo_blurhash, m.trailer, m.external_id, NULL AS season_number, NULL AS episode_number, NULL as absolute_number,
|
||||||
|
'movie'::news_kind AS kind, m.added_date, NULL AS show_id, NULL AS show_slug, NULL AS show_name,
|
||||||
|
NULL AS show_poster_source, NULL AS show_poster_blurhash, NULL AS show_thumbnail_source, NULL AS show_thumbnail_blurhash,
|
||||||
|
NULL AS show_logo_source, NULL AS show_logo_blurhash, m.rating
|
||||||
|
FROM movies AS m
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
base.Down(migrationBuilder);
|
||||||
|
// language=PostgreSQL
|
||||||
|
migrationBuilder.Sql(@"DROP VIEW news");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "rating",
|
||||||
|
table: "shows",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "rating",
|
||||||
|
table: "movies",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false);
|
||||||
|
|
||||||
|
CreateItemView(migrationBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
base.Down(migrationBuilder);
|
||||||
|
// language=PostgreSQL
|
||||||
|
migrationBuilder.Sql(@"DROP VIEW news");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "rating",
|
||||||
|
table: "shows");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "rating",
|
||||||
|
table: "movies");
|
||||||
|
|
||||||
|
AddedDate.CreateItemView(migrationBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Kyoo.Abstractions.Models;
|
using Kyoo.Abstractions.Models;
|
||||||
@ -208,6 +208,11 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("path");
|
.HasColumnName("path");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("rating");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
@ -289,6 +294,11 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("path");
|
.HasColumnName("path");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("rating");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
@ -388,6 +398,11 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("path");
|
.HasColumnName("path");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("rating");
|
||||||
|
|
||||||
b.Property<int?>("SeasonNumber")
|
b.Property<int?>("SeasonNumber")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("season_number");
|
.HasColumnName("season_number");
|
||||||
@ -609,6 +624,11 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("overview");
|
.HasColumnName("overview");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("rating");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
|
@ -23,12 +23,14 @@ export enum SortBy {
|
|||||||
StartAir = "startAir",
|
StartAir = "startAir",
|
||||||
EndAir = "endAir",
|
EndAir = "endAir",
|
||||||
AddedDate = "addedDate",
|
AddedDate = "addedDate",
|
||||||
|
Ratings = "rating",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SearchSort {
|
export enum SearchSort {
|
||||||
Relevance = "relevance",
|
Relevance = "relevance",
|
||||||
AirDate = "airDate",
|
AirDate = "airDate",
|
||||||
AddedDate = "addedDate",
|
AddedDate = "addedDate",
|
||||||
|
Ratings = "rating",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortOrd {
|
export enum SortOrd {
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
"airDate": "Air Date",
|
"airDate": "Air Date",
|
||||||
"startAir": "Start air",
|
"startAir": "Start air",
|
||||||
"endAir": "End air",
|
"endAir": "End air",
|
||||||
"addedDate": "Added date"
|
"addedDate": "Added date",
|
||||||
|
"rating": "Ratings"
|
||||||
},
|
},
|
||||||
"sortord": {
|
"sortord": {
|
||||||
"asc": "asc",
|
"asc": "asc",
|
||||||
|
@ -23,10 +23,13 @@
|
|||||||
"sortby": "Trier par {{key}}",
|
"sortby": "Trier par {{key}}",
|
||||||
"sortby-tt": "Trier par",
|
"sortby-tt": "Trier par",
|
||||||
"sortkey": {
|
"sortkey": {
|
||||||
|
"relevance": "Pertinence",
|
||||||
"name": "Nom",
|
"name": "Nom",
|
||||||
|
"airDate": "Date de sortie",
|
||||||
"startAir": "Date de sortie",
|
"startAir": "Date de sortie",
|
||||||
"endAir": "Date de fin de sortie",
|
"endAir": "Date de fin de sortie",
|
||||||
"addedDate": "Date d'ajout"
|
"addedDate": "Date d'ajout",
|
||||||
|
"rating": "Notes"
|
||||||
},
|
},
|
||||||
"sortord": {
|
"sortord": {
|
||||||
"asc": "asc",
|
"asc": "asc",
|
||||||
|
@ -138,6 +138,7 @@ class TheMovieDatabase(Provider):
|
|||||||
status=MovieStatus.FINISHED
|
status=MovieStatus.FINISHED
|
||||||
if movie["status"] == "Released"
|
if movie["status"] == "Released"
|
||||||
else MovieStatus.PLANNED,
|
else MovieStatus.PLANNED,
|
||||||
|
rating=round(float(movie["vote_average"]) * 10),
|
||||||
studios=[self.to_studio(x) for x in movie["production_companies"]],
|
studios=[self.to_studio(x) for x in movie["production_companies"]],
|
||||||
genres=[
|
genres=[
|
||||||
self.genre_map[x["id"]]
|
self.genre_map[x["id"]]
|
||||||
@ -232,6 +233,7 @@ class TheMovieDatabase(Provider):
|
|||||||
else ShowStatus.AIRING
|
else ShowStatus.AIRING
|
||||||
if show["in_production"]
|
if show["in_production"]
|
||||||
else ShowStatus.FINISHED,
|
else ShowStatus.FINISHED,
|
||||||
|
rating=round(float(show["vote_average"]) * 10),
|
||||||
studios=[self.to_studio(x) for x in show["production_companies"]],
|
studios=[self.to_studio(x) for x in show["production_companies"]],
|
||||||
genres=[
|
genres=[
|
||||||
self.genre_map[x["id"]]
|
self.genre_map[x["id"]]
|
||||||
|
@ -34,6 +34,7 @@ class Movie:
|
|||||||
aliases: list[str] = field(default_factory=list)
|
aliases: list[str] = field(default_factory=list)
|
||||||
air_date: Optional[date | int] = None
|
air_date: Optional[date | int] = None
|
||||||
status: Status = Status.UNKNOWN
|
status: Status = Status.UNKNOWN
|
||||||
|
rating: int = None
|
||||||
path: Optional[str] = None
|
path: Optional[str] = None
|
||||||
studios: list[Studio] = field(default_factory=list)
|
studios: list[Studio] = field(default_factory=list)
|
||||||
genres: list[Genre] = field(default_factory=list)
|
genres: list[Genre] = field(default_factory=list)
|
||||||
|
@ -37,6 +37,7 @@ class Show:
|
|||||||
start_air: Optional[date | int]
|
start_air: Optional[date | int]
|
||||||
end_air: Optional[date | int]
|
end_air: Optional[date | int]
|
||||||
status: Status
|
status: Status
|
||||||
|
rating: int
|
||||||
studios: list[Studio]
|
studios: list[Studio]
|
||||||
genres: list[Genre]
|
genres: list[Genre]
|
||||||
seasons: list[Season]
|
seasons: list[Season]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user