mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add ratings
This commit is contained in:
parent
3e39ef1705
commit
15a4280a36
@ -94,6 +94,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Status Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How well this item is rated? (from 0 to 100).
|
||||
/// </summary>
|
||||
public int Rating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this show started airing. It can be null if this is unknown.
|
||||
/// </summary>
|
||||
|
@ -90,6 +90,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Status? Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How well this item is rated? (from 0 to 100).
|
||||
/// </summary>
|
||||
public int Rating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this movie aired.
|
||||
/// </summary>
|
||||
|
@ -19,7 +19,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Abstractions.Models.Attributes;
|
||||
using Kyoo.Utils;
|
||||
using Newtonsoft.Json;
|
||||
@ -78,6 +77,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Status Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How well this item is rated? (from 0 to 100).
|
||||
/// </summary>
|
||||
public int Rating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this movie aired.
|
||||
/// </summary>
|
||||
|
@ -72,6 +72,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Status Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How well this item is rated? (from 0 to 100).
|
||||
/// </summary>
|
||||
public int Rating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this show started airing. It can be null if this is unknown.
|
||||
/// </summary>
|
||||
|
@ -60,12 +60,23 @@ namespace Kyoo.Meiliseach
|
||||
{
|
||||
CamelCase.ConvertName(nameof(LibraryItem.AirDate)),
|
||||
CamelCase.ConvertName(nameof(LibraryItem.AddedDate)),
|
||||
CamelCase.ConvertName(nameof(LibraryItem.Rating)),
|
||||
},
|
||||
DisplayedAttributes = new[]
|
||||
{
|
||||
CamelCase.ConvertName(nameof(LibraryItem.Id)),
|
||||
CamelCase.ConvertName(nameof(LibraryItem.Kind)),
|
||||
},
|
||||
RankingRules = new[]
|
||||
{
|
||||
"words",
|
||||
"typo",
|
||||
"proximity",
|
||||
"attribute",
|
||||
"sort",
|
||||
"exactness",
|
||||
$"{CamelCase.ConvertName(nameof(LibraryItem.Rating))}:desc",
|
||||
}
|
||||
// TODO: Add stopwords
|
||||
// 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.Collections.Generic;
|
||||
using Kyoo.Abstractions.Models;
|
||||
@ -208,6 +208,11 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.IsRequired()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("rating");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
@ -289,6 +294,11 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.IsRequired()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("rating");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
@ -388,6 +398,11 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.IsRequired()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("rating");
|
||||
|
||||
b.Property<int?>("SeasonNumber")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("season_number");
|
||||
@ -609,6 +624,11 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("overview");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.IsRequired()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("rating");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
|
@ -23,12 +23,14 @@ export enum SortBy {
|
||||
StartAir = "startAir",
|
||||
EndAir = "endAir",
|
||||
AddedDate = "addedDate",
|
||||
Ratings = "rating",
|
||||
}
|
||||
|
||||
export enum SearchSort {
|
||||
Relevance = "relevance",
|
||||
AirDate = "airDate",
|
||||
AddedDate = "addedDate",
|
||||
Ratings = "rating",
|
||||
}
|
||||
|
||||
export enum SortOrd {
|
||||
|
@ -28,7 +28,8 @@
|
||||
"airDate": "Air Date",
|
||||
"startAir": "Start air",
|
||||
"endAir": "End air",
|
||||
"addedDate": "Added date"
|
||||
"addedDate": "Added date",
|
||||
"rating": "Ratings"
|
||||
},
|
||||
"sortord": {
|
||||
"asc": "asc",
|
||||
|
@ -23,10 +23,13 @@
|
||||
"sortby": "Trier par {{key}}",
|
||||
"sortby-tt": "Trier par",
|
||||
"sortkey": {
|
||||
"relevance": "Pertinence",
|
||||
"name": "Nom",
|
||||
"airDate": "Date de sortie",
|
||||
"startAir": "Date de sortie",
|
||||
"endAir": "Date de fin de sortie",
|
||||
"addedDate": "Date d'ajout"
|
||||
"addedDate": "Date d'ajout",
|
||||
"rating": "Notes"
|
||||
},
|
||||
"sortord": {
|
||||
"asc": "asc",
|
||||
|
@ -138,6 +138,7 @@ class TheMovieDatabase(Provider):
|
||||
status=MovieStatus.FINISHED
|
||||
if movie["status"] == "Released"
|
||||
else MovieStatus.PLANNED,
|
||||
rating=round(float(movie["vote_average"]) * 10),
|
||||
studios=[self.to_studio(x) for x in movie["production_companies"]],
|
||||
genres=[
|
||||
self.genre_map[x["id"]]
|
||||
@ -232,6 +233,7 @@ class TheMovieDatabase(Provider):
|
||||
else ShowStatus.AIRING
|
||||
if show["in_production"]
|
||||
else ShowStatus.FINISHED,
|
||||
rating=round(float(show["vote_average"]) * 10),
|
||||
studios=[self.to_studio(x) for x in show["production_companies"]],
|
||||
genres=[
|
||||
self.genre_map[x["id"]]
|
||||
|
@ -34,6 +34,7 @@ class Movie:
|
||||
aliases: list[str] = field(default_factory=list)
|
||||
air_date: Optional[date | int] = None
|
||||
status: Status = Status.UNKNOWN
|
||||
rating: int = None
|
||||
path: Optional[str] = None
|
||||
studios: list[Studio] = field(default_factory=list)
|
||||
genres: list[Genre] = field(default_factory=list)
|
||||
|
@ -37,6 +37,7 @@ class Show:
|
||||
start_air: Optional[date | int]
|
||||
end_air: Optional[date | int]
|
||||
status: Status
|
||||
rating: int
|
||||
studios: list[Studio]
|
||||
genres: list[Genre]
|
||||
seasons: list[Season]
|
||||
|
Loading…
x
Reference in New Issue
Block a user