Skip to content

One self-hosted app for your shows, movies and music.

HolyArrs 1.0.17 (#239)

CoderLuii06c561d27e15
diff --git a/.github/readme/README.ar.md b/.github/readme/README.ar.md
index 6077a64..90df8a3 100644
--- a/.github/readme/README.ar.md
+++ b/.github/readme/README.ar.md
@@ -202,7 +202,7 @@ docker compose up -d
| الوسم | استخدمه لـ |
| :----: | --- |
| `latest` | أحدث إصدار. |
-| `1.0.16` | إصدار واحد بعينه. لا يتحرك أبدًا. |
+| `1.0.17` | إصدار واحد بعينه. لا يتحرك أبدًا. |
## الاستخدام
diff --git a/.github/readme/README.de.md b/.github/readme/README.de.md
index eaf9deb..477a85c 100644
--- a/.github/readme/README.de.md
+++ b/.github/readme/README.de.md
@@ -200,7 +200,7 @@ Die Images liegen auf Docker Hub als [`holyarrs/holyarrs`](https://hub.docker.co
| Tag | Dafür nutzen |
| :----: | --- |
| `latest` | Die neueste Version. |
-| `1.0.16` | Eine genaue Version. Sie ändert sich nie. |
+| `1.0.17` | Eine genaue Version. Sie ändert sich nie. |
## Verwendung
diff --git a/.github/readme/README.es.md b/.github/readme/README.es.md
index c03595f..2b65b45 100644
--- a/.github/readme/README.es.md
+++ b/.github/readme/README.es.md
@@ -200,7 +200,7 @@ Las imágenes están en Docker Hub como [`holyarrs/holyarrs`](https://hub.docker
| Etiqueta | Para qué sirve |
| :----: | --- |
| `latest` | La versión más reciente. |
-| `1.0.16` | Una versión exacta. Nunca se mueve. |
+| `1.0.17` | Una versión exacta. Nunca se mueve. |
## Uso
diff --git a/.github/readme/README.fr.md b/.github/readme/README.fr.md
index d9455c7..9d1dfb8 100644
--- a/.github/readme/README.fr.md
+++ b/.github/readme/README.fr.md
@@ -200,7 +200,7 @@ Les images sont sur Docker Hub sous le nom [`holyarrs/holyarrs`](https://hub.doc
| Étiquette | À utiliser pour |
| :----: | --- |
| `latest` | La version la plus récente. |
-| `1.0.16` | Une version précise. Elle ne bouge jamais. |
+| `1.0.17` | Une version précise. Elle ne bouge jamais. |
## Utilisation
diff --git a/.github/readme/README.hi.md b/.github/readme/README.hi.md
index e2d06fd..6e0c8bf 100644
--- a/.github/readme/README.hi.md
+++ b/.github/readme/README.hi.md
@@ -200,7 +200,7 @@ NAS पर चला रहे हैं? देखिए [Unraid, Synology औ
| टैग | किसके लिए |
| :----: | --- |
| `latest` | नवीनतम रिलीज़। |
-| `1.0.16` | एक तय वर्ज़न। यह कभी नहीं बदलता। |
+| `1.0.17` | एक तय वर्ज़न। यह कभी नहीं बदलता। |
## इस्तेमाल
diff --git a/.github/readme/README.it.md b/.github/readme/README.it.md
index 3a4df2e..32f27c1 100644
--- a/.github/readme/README.it.md
+++ b/.github/readme/README.it.md
@@ -200,7 +200,7 @@ Le immagini sono su Docker Hub come [`holyarrs/holyarrs`](https://hub.docker.com
| Tag | A cosa serve |
| :----: | --- |
| `latest` | La versione più recente. |
-| `1.0.16` | Una versione esatta. Non cambia mai. |
+| `1.0.17` | Una versione esatta. Non cambia mai. |
## Utilizzo
diff --git a/.github/readme/README.ja.md b/.github/readme/README.ja.md
index 217fad2..3a796dd 100644
--- a/.github/readme/README.ja.md
+++ b/.github/readme/README.ja.md
@@ -200,7 +200,7 @@ NAS をお使いですか。[Unraid、Synology などの NAS](https://docs.HolyA
| タグ | 用途 |
| :----: | --- |
| `latest` | 最新のリリース。 |
-| `1.0.16` | 特定の1つのバージョンです。動くことはありません。 |
+| `1.0.17` | 特定の1つのバージョンです。動くことはありません。 |
## 使い方
diff --git a/.github/readme/README.ko.md b/.github/readme/README.ko.md
index 2eeeb23..62e1ce2 100644
--- a/.github/readme/README.ko.md
+++ b/.github/readme/README.ko.md
@@ -200,7 +200,7 @@ NAS를 쓰세요? [Unraid, Synology 및 기타 NAS](https://docs.HolyArrs.com/ru
| 태그 | 용도 |
| :----: | --- |
| `latest` | 최신 릴리스. |
-| `1.0.16` | 정확히 한 버전이에요. 절대 움직이지 않아요. |
+| `1.0.17` | 정확히 한 버전이에요. 절대 움직이지 않아요. |
## 사용법
diff --git a/.github/readme/README.nl.md b/.github/readme/README.nl.md
index a9da163..5f5d6ee 100644
--- a/.github/readme/README.nl.md
+++ b/.github/readme/README.nl.md
@@ -200,7 +200,7 @@ De images staan op Docker Hub als [`holyarrs/holyarrs`](https://hub.docker.com/r
| Tag | Gebruik het voor |
| :----: | --- |
| `latest` | De nieuwste versie. |
-| `1.0.16` | Eén exacte versie. Die verandert nooit. |
+| `1.0.17` | Eén exacte versie. Die verandert nooit. |
## Gebruik
diff --git a/.github/readme/README.pl.md b/.github/readme/README.pl.md
index a5a3a65..f99f7b8 100644
--- a/.github/readme/README.pl.md
+++ b/.github/readme/README.pl.md
@@ -200,7 +200,7 @@ Image'e są na Docker Hub jako [`holyarrs/holyarrs`](https://hub.docker.com/r/ho
| Tag | Do czego użyć |
| :----: | --- |
| `latest` | Najnowsza wersja. |
-| `1.0.16` | Jedna dokładna wersja. Nigdy się nie zmienia. |
+| `1.0.17` | Jedna dokładna wersja. Nigdy się nie zmienia. |
## Użycie
diff --git a/.github/readme/README.pt-BR.md b/.github/readme/README.pt-BR.md
index 5c7ef2b..1fe4aae 100644
--- a/.github/readme/README.pt-BR.md
+++ b/.github/readme/README.pt-BR.md
@@ -200,7 +200,7 @@ As imagens ficam no Docker Hub como [`holyarrs/holyarrs`](https://hub.docker.com
| Tag | Use para |
| :----: | --- |
| `latest` | A versão mais recente. |
-| `1.0.16` | Uma versão exata. Nunca muda. |
+| `1.0.17` | Uma versão exata. Nunca muda. |
## Uso
diff --git a/.github/readme/README.ru.md b/.github/readme/README.ru.md
index 9161273..2b30280 100644
--- a/.github/readme/README.ru.md
+++ b/.github/readme/README.ru.md
@@ -200,7 +200,7 @@ HolyArrs только читает ваши старые приложения и
| Тег | Для чего |
| :----: | --- |
| `latest` | Самая новая версия. |
-| `1.0.16` | Одна точная версия. Никогда не сдвигается. |
+| `1.0.17` | Одна точная версия. Никогда не сдвигается. |
## Использование
diff --git a/.github/readme/README.tr.md b/.github/readme/README.tr.md
index 744eb30..de4055a 100644
--- a/.github/readme/README.tr.md
+++ b/.github/readme/README.tr.md
@@ -200,7 +200,7 @@ NAS mı kullanıyorsun? [Unraid, Synology ve diğer NAS cihazları](https://docs
| Etiket | Ne için kullanılır |
| :----: | --- |
| `latest` | En yeni sürüm. |
-| `1.0.16` | Tam olarak tek bir sürüm. Asla değişmez. |
+| `1.0.17` | Tam olarak tek bir sürüm. Asla değişmez. |
## Kullanım
diff --git a/.github/readme/README.uk.md b/.github/readme/README.uk.md
index 97ca4e9..a1fb185 100644
--- a/.github/readme/README.uk.md
+++ b/.github/readme/README.uk.md
@@ -200,7 +200,7 @@ HolyArrs лише читає твої старі застосунки й ніч
| Тег | Для чого |
| :----: | --- |
| `latest` | Найновіша версія. |
-| `1.0.16` | Одна точна версія. Вона ніколи не змінюється. |
+| `1.0.17` | Одна точна версія. Вона ніколи не змінюється. |
## Використання
diff --git a/.github/readme/README.zh-CN.md b/.github/readme/README.zh-CN.md
index d61c46b..c0dc70b 100644
--- a/.github/readme/README.zh-CN.md
+++ b/.github/readme/README.zh-CN.md
@@ -200,7 +200,7 @@ HolyArrs 只读取你的旧应用,不会改动它们里面的任何东西,
| 标签 | 用途 |
| :----: | --- |
| `latest` | 最新版本。 |
-| `1.0.16` | 固定的某一个版本,永远不会变。 |
+| `1.0.17` | 固定的某一个版本,永远不会变。 |
## 用法
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb98ed4..65d46bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable changes to HolyArrs are listed here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/).
+## 1.0.17
+
+### Added
+
+- The Library sorts by Score, and shows each title's score while you do. ([#139](https://github.com/HolyArrs/HolyArrs/issues/139))
+
## 1.0.16
### Added
diff --git a/README.md b/README.md
index 48e0ce7..fdc3ea2 100644
--- a/README.md
+++ b/README.md
@@ -200,7 +200,7 @@ Images live on Docker Hub as [`holyarrs/holyarrs`](https://hub.docker.com/r/holy
| Tag | Use it for |
| :----: | --- |
| `latest` | The newest release. |
-| `1.0.16` | One exact version. It never moves. |
+| `1.0.17` | One exact version. It never moves. |
## Usage
diff --git a/VERSION b/VERSION
index b668c3b..8fc77d0 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.16
+1.0.17
diff --git a/app/backend/cmd/holyarrs/title_score_test.go b/app/backend/cmd/holyarrs/title_score_test.go
new file mode 100644
index 0000000..d51dc2b
--- /dev/null
+++ b/app/backend/cmd/holyarrs/title_score_test.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "context"
+ "database/sql"
+ "encoding/json"
+ "fmt"
+ "testing"
+)
+
+// The title list carries a title's score and vote count, and leaves both
+// out when the title has none.
+func TestTitleListScore(t *testing.T) {
+ t.Parallel()
+ srv, s, _ := libSetup(t)
+ do(t, "POST", srv.URL+"/api/v1/library-folders", fmt.Sprintf(`{"path":%q,"kind":"movie"}`, t.TempDir()), 201)
+ do(t, "POST", srv.URL+"/api/v1/titles", `{"id":"tmdb:693134"}`, 201)
+ list := func(set string) map[string]json.RawMessage {
+ t.Helper()
+ if err := s.Write(context.Background(), func(tx *sql.Tx) error {
+ _, err := tx.Exec("UPDATE titles SET " + set + " WHERE id = 1")
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+ var out struct {
+ Titles []map[string]json.RawMessage `json:"titles"`
+ }
+ if err := json.Unmarshal(do(t, "GET", srv.URL+"/api/v1/titles", "", 200), &out); err != nil || len(out.Titles) != 1 {
+ t.Fatalf("list %v %v", out, err)
+ }
+ return out.Titles[0]
+ }
+ if v := list("score = 7.4, votes = 900"); string(v["score"]) != "7.4" || string(v["votes"]) != "900" {
+ t.Fatalf("score %s votes %s", v["score"], v["votes"])
+ }
+ for _, set := range []string{"score = NULL, votes = 0", "score = 0, votes = 0"} {
+ if v := list(set); v["score"] != nil || v["votes"] != nil {
+ t.Fatalf("%s: score %s votes %s", set, v["score"], v["votes"])
+ }
+ }
+}
diff --git a/app/backend/internal/core/database/migrations/main/0104_title_score.sql b/app/backend/internal/core/database/migrations/main/0104_title_score.sql
new file mode 100644
index 0000000..1cc7eb4
--- /dev/null
+++ b/app/backend/internal/core/database/migrations/main/0104_title_score.sql
@@ -0,0 +1,5 @@
+-- A movie's or show's members' average out of 10 and its vote count, so the
+-- Library can sort by score. A title from before this has no score (NULL)
+-- until its next details refresh fills it; 0 means looked up with none.
+ALTER TABLE titles ADD COLUMN score REAL;
+ALTER TABLE titles ADD COLUMN votes INTEGER NOT NULL DEFAULT 0;
diff --git a/app/backend/internal/core/database/title_score_migration_test.go b/app/backend/internal/core/database/title_score_migration_test.go
new file mode 100644
index 0000000..00f22f4
--- /dev/null
+++ b/app/backend/internal/core/database/title_score_migration_test.go
@@ -0,0 +1,43 @@
+package database
+
+import (
+ "context"
+ "database/sql"
+ "testing"
+)
+
+// 0104 adds the score and vote count to titles: a title from an older
+// build keeps every field and has no score (NULL) and 0 votes until its
+// next details refresh.
+func TestTitleScoreMigration(t *testing.T) {
+ dir := t.TempDir()
+ ctx := context.Background()
+ old, err := Open(dir, Options{MainMigrations: upTo(t, 103)})
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = old.Write(ctx, func(tx *sql.Tx) error {
+ _, err := tx.Exec(`INSERT INTO titles (id, created_at, created_by, updated_at, updated_by, kind, name, sort_name, metadata_source, why_added, rating, runtime_minutes)
+ VALUES (7, 'c', '{"kind":"system"}', 'u', '{"kind":"system"}', 'movie', 'Old Film', 'old film', 'tmdb', 'by_hand', 'PG-13', 121)`)
+ return err
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ _ = old.Close()
+
+ s, err := Open(dir, Options{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer s.Close()
+ var name, rating string
+ var runtime, votes int
+ var score sql.NullFloat64
+ if err := s.Read().QueryRow(`SELECT name, rating, runtime_minutes, score, votes FROM titles WHERE id = 7`).Scan(&name, &rating, &runtime, &score, &votes); err != nil {
+ t.Fatal(err)
+ }
+ if name != "Old Film" || rating != "PG-13" || runtime != 121 || score.Valid || votes != 0 {
+ t.Fatalf("old title %q %q %d score %v votes %d", name, rating, runtime, score, votes)
+ }
+}
diff --git a/app/backend/internal/discover/title_view.go b/app/backend/internal/discover/title_view.go
index b61c96f..7cf4d46 100644
--- a/app/backend/internal/discover/title_view.go
+++ b/app/backend/internal/discover/title_view.go
@@ -100,6 +100,9 @@ type TitleView struct {
RuntimeMinutes int `json:"runtime_minutes,omitempty"`
Rating string `json:"rating,omitempty"`
People []string `json:"people"`
+ // Score is the members' average out of 10 and Votes how many voted.
+ Score float64 `json:"score,omitempty"`
+ Votes int `json:"votes,omitempty"`
// Tags route the title's grabs and searches to the Downloaders and Sources that share one.
Tags []string `json:"tags"`
// AddedAt is when the title joined the Library; SizeBytes is the sum of
@@ -154,7 +157,10 @@ func (h *ViewHandlers) View(ctx context.Context, t mediafiles.Title) (TitleView,
GateDriver: t.GateDriver, GateOpensAt: t.GateOpensAt, CinemaDate: t.CinemaDate, DigitalDate: t.DigitalDate,
PhysicalDate: t.PhysicalDate, RefreshedAt: t.RefreshedAt, DroppedAt: t.DroppedAt, Artwork: ArtworkLinks(t.Artwork),
Backdrop: t.Backdrop, Logo: t.Logo, Genres: nonNil(t.Genres), RuntimeMinutes: t.RuntimeMinutes, Rating: t.Rating, People: nonNil(t.People),
- AddedAt: t.CreatedAt, Tags: nonNil(t.Tags)}
+ AddedAt: t.CreatedAt, Tags: nonNil(t.Tags), Votes: t.Votes}
+ if t.Score != nil {
+ v.Score = *t.Score
+ }
now := time.Now()
var err error
facts := factsOf(ctx)
diff --git a/app/backend/internal/library/library.go b/app/backend/internal/library/library.go
index af0bd4b..a0e0544 100644
--- a/app/backend/internal/library/library.go
+++ b/app/backend/internal/library/library.go
@@ -356,13 +356,14 @@ func applyMovie(t *mediafiles.Title, m metadata.Movie, now time.Time) {
t.CinemaDate, t.DigitalDate, t.PhysicalDate = m.CinemaDate, m.DigitalDate, m.PhysicalDate
t.Aliases = MergeAliases(t.Aliases, m.Name, m.OtherNames)
t.Status = titleStatus(Stage(DatesOf(*t), now))
- ApplyDetails(t, m.Backdrop, m.Logo, m.Genres, m.Rating, m.People, m.Runtime)
+ ApplyDetails(t, m.Backdrop, m.Logo, m.Genres, m.Rating, m.People, m.Runtime, m.Score, m.Votes)
t.Directors, t.Studio = append([]string{}, m.Directors...), m.Studio
}
// applyDetails copies the screen details; a fresh lookup replaces them all.
-func ApplyDetails(t *mediafiles.Title, backdrop, logo string, genres []string, rating string, people []string, runtime int) {
+func ApplyDetails(t *mediafiles.Title, backdrop, logo string, genres []string, rating string, people []string, runtime int, score float64, votes int) {
t.Backdrop, t.Logo, t.Rating, t.RuntimeMinutes = backdrop, logo, rating, max(runtime, 0)
+ t.Score, t.Votes = &score, max(votes, 0)
t.Genres = append([]string{}, genres...)
t.People = append([]string{}, people...)
}
diff --git a/app/backend/internal/library/refresh_test.go b/app/backend/internal/library/refresh_test.go
index ab87555..7b4984a 100644
--- a/app/backend/internal/library/refresh_test.go
+++ b/app/backend/internal/library/refresh_test.go
@@ -396,3 +396,106 @@ func TestArtworkCacheCapAndHosts(t *testing.T) {
t.Fatal("path outside the cache")
}
}
+
+// A lookup always stores a score, 0 when the source has none; only titles
+// added before scores existed read back with none (NULL).
+func TestMovieScoreStored(t *testing.T) {
+ s := open(t)
+ ctx := context.Background()
+ addFolder(t, s)
+ rated := dune
+ rated.Score, rated.Votes = 8.1, 6200
+ id1, err := AddMovie(ctx, s, rated, AddOptions{}, nil, now, domain.System)
+ if err != nil {
+ t.Fatal(err)
+ }
+ id2, err := AddMovie(ctx, s, future, AddOptions{}, nil, now, domain.System)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var t1, t2 mediafiles.Title
+ _ = database.Get(ctx, s.Read(), "titles", id1, &t1)
+ _ = database.Get(ctx, s.Read(), "titles", id2, &t2)
+ if t1.Score == nil || *t1.Score != 8.1 || t1.Votes != 6200 {
+ t.Fatalf("rated %v %d", t1.Score, t1.Votes)
+ }
+ if t2.Score == nil || *t2.Score != 0 || t2.Votes != 0 {
+ t.Fatalf("looked up without a score %v %d", t2.Score, t2.Votes)
+ }
+ if err := s.Write(ctx, func(tx *sql.Tx) error {
+ _, err := tx.Exec("UPDATE titles SET score = NULL WHERE id = ?", id2)
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+ _ = database.Get(ctx, s.Read(), "titles", id2, &t2)
+ if t2.Score != nil {
+ t.Fatalf("NULL score read back as %v", *t2.Score)
+ }
+}
+
+type changedMovies struct {
+ *metadata.Static
+ ids []string
+}
+
+func (c changedMovies) Changed(context.Context, time.Time) ([]string, error) { return c.ids, nil }
+
+// Titles with no score yet are picked even while the changed list decides,
+// at most ScoreFillPerRun a run, and never one fetched under 12 hours ago
+// or one the source dropped.
+func TestRefreshPlanFillsScores(t *testing.T) {
+ s := open(t)
+ ctx := context.Background()
+ addFolder(t, s)
+ total := ScoreFillPerRun + 5
+ for i := 1; i <= total; i++ {
+ m := metadata.Movie{Name: fmt.Sprint("Movie ", i), Year: 2020, IDs: map[string]string{"tmdb": fmt.Sprint(i)}, CinemaDate: d("2020-01-01")}
+ if _, err := AddMovie(ctx, s, m, AddOptions{}, nil, now, domain.System); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // Every movie was fetched 13 hours ago, before scores were kept; movie 1
+ // was fetched 2 hours ago, movie 2 has a score, movie 3 was dropped.
+ if err := s.Write(ctx, func(tx *sql.Tx) error {
+ ago13, ago2 := database.FormatTime(now.Add(-13*time.Hour)), database.FormatTime(now.Add(-2*time.Hour))
+ for _, u := range []struct {
+ q string
+ arg any
+ }{
+ {"UPDATE titles SET score = NULL, refreshed_at = ?", ago13},
+ {`UPDATE titles SET refreshed_at = ? WHERE json_extract(source_ids, '$.tmdb') = '1'`, ago2},
+ {`UPDATE titles SET score = ? WHERE json_extract(source_ids, '$.tmdb') = '2'`, 7.4},
+ {`UPDATE titles SET dropped_at = ? WHERE json_extract(source_ids, '$.tmdb') = '3'`, ago13},
+ } {
+ if _, err := tx.Exec(u.q, u.arg); err != nil {
+ return err
+ }
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+ svc := &Service{Store: s, Metadata: changedMovies{Static: &metadata.Static{}, ids: []string{"tmdb:2"}}, Now: func() time.Time { return now }}
+ last := now.Add(-24 * time.Hour)
+ ids, why, err := svc.RefreshPlan(ctx, false, &last)
+ if err != nil {
+ t.Fatal(err)
+ }
+ byID := map[string]string{}
+ filled := 0
+ for _, id := range ids {
+ var tt mediafiles.Title
+ _ = database.Get(ctx, s.Read(), "titles", id, &tt)
+ byID[tt.SourceIDs["tmdb"]] = why[id]
+ if why[id] == "no score yet" {
+ filled++
+ }
+ }
+ if filled != ScoreFillPerRun || byID["2"] != "on the changed list" || byID["1"] != "" || byID["3"] != "" || byID["4"] != "no score yet" {
+ t.Fatalf("filled %d, why 1 %q 2 %q 3 %q 4 %q", filled, byID["1"], byID["2"], byID["3"], byID["4"])
+ }
+ if ids, _, _ := svc.RefreshPlan(ctx, true, nil); len(ids) != total {
+ t.Fatalf("by hand %d", len(ids))
+ }
+}
diff --git a/app/backend/internal/library/refreshall.go b/app/backend/internal/library/refreshall.go
index ef74262..19840dc 100644
--- a/app/backend/internal/library/refreshall.go
+++ b/app/backend/internal/library/refreshall.go
@@ -31,6 +31,16 @@ const (
changedListAge = 14 * 24 * time.Hour // the changed list is used when the last run is newer
)
+// ScoreFillPerRun is how many movies, and how many shows, with no score yet
+// a scheduled refresh adds, so a large Library fills over a few runs.
+const ScoreFillPerRun = 300
+
+// NeedsScore is true for a title not looked up since scores were kept,
+// not dropped by the source and not fetched within fresh.
+func NeedsScore(t mediafiles.Title, now time.Time, fresh time.Duration) bool {
+ return t.Score == nil && t.DroppedAt == nil && (t.RefreshedAt == nil || now.Sub(*t.RefreshedAt) >= fresh)
+}
+
// ShouldRefresh applies the refresh rules, in order, to a Title that is not
// on the changed list: over 180 days since the last fetch, yes; under 12
// hours, no; announced or in cinemas, yes; released with the physical date
@@ -67,7 +77,8 @@ func changedSince(lastStart time.Time) time.Time {
// RefreshPlan picks the Titles a refresh-all run covers. byHand covers every
// movie. Otherwise, when the last start is under 14 days ago and the
// provider has a changed list, the movies on it are refreshed; when that
-// list is empty or unavailable the rules decide (ShouldRefresh).
+// list is empty or unavailable the rules decide (ShouldRefresh). Either
+// way, up to ScoreFillPerRun movies with no score yet are added.
func (s *Service) RefreshPlan(ctx context.Context, byHand bool, lastStart *time.Time) (ids []int64, why map[int64]string, err error) {
ts, err := database.Select[mediafiles.Title](ctx, s.Store.Read(), "titles", "kind = 'movie' AND state != 'removed' ORDER BY id")
if err != nil {
@@ -95,7 +106,12 @@ func (s *Service) RefreshPlan(ctx context.Context, byHand bool, lastStart *time.
log.Printf("library: changed list: %v; using the refresh rules", err)
}
}
+ filled := 0
for _, t := range ts {
+ if filled < ScoreFillPerRun && NeedsScore(t, now, refreshFresh) {
+ ids, why[t.ID], filled = append(ids, t.ID), "no score yet", filled+1
+ continue
+ }
if len(changed) > 0 {
if changed[lookupID(t)] {
ids, why[t.ID] = append(ids, t.ID), "on the changed list"
diff --git a/app/backend/internal/mediafiles/testdata/pin_catalog_json.golden.json b/app/backend/internal/mediafiles/testdata/pin_catalog_json.golden.json
index e4859d0..f6b3750 100644
--- a/app/backend/internal/mediafiles/testdata/pin_catalog_json.golden.json
+++ b/app/backend/internal/mediafiles/testdata/pin_catalog_json.golden.json
@@ -51,6 +51,8 @@
"RuntimeMinutes": 0,
"Rating": "",
"People": null,
+ "Score": null,
+ "Votes": 0,
"Directors": null,
"Studio": "",
"Tags": null
diff --git a/app/backend/internal/mediafiles/testdata/pin_catalog_layouts.golden.txt b/app/backend/internal/mediafiles/testdata/pin_catalog_layouts.golden.txt
index fa92b34..5255f42 100644
--- a/app/backend/internal/mediafiles/testdata/pin_catalog_layouts.golden.txt
+++ b/app/backend/internal/mediafiles/testdata/pin_catalog_layouts.golden.txt
@@ -55,6 +55,8 @@ Genres []string `db:"genres,json"`
RuntimeMinutes int `db:"runtime_minutes"`
Rating string `db:"rating"`
People []string `db:"people,json"`
+Score *float64 `db:"score"`
+Votes int `db:"votes"`
Directors []string `db:"directors,json"`
Studio string `db:"studio"`
Tags []string `db:"tags,json"`
diff --git a/app/backend/internal/mediafiles/types.go b/app/backend/internal/mediafiles/types.go
index 7637f7a..dbb29db 100644
--- a/app/backend/internal/mediafiles/types.go
+++ b/app/backend/internal/mediafiles/types.go
@@ -81,6 +81,10 @@ type Title struct {
RuntimeMinutes int `db:"runtime_minutes"`
Rating string `db:"rating"`
People []string `db:"people,json"`
+ // Score is the members' average out of 10 (nil until the first lookup
+ // after scores were kept; 0 when the source has none) and Votes how many voted.
+ Score *float64 `db:"score"`
+ Votes int `db:"votes"`
// Directors are a movie's directors alone (People mixes them in after the cast).
Directors []string `db:"directors,json"`
// Studio is a movie's first production company.
diff --git a/app/backend/internal/metadata/shows.go b/app/backend/internal/metadata/shows.go
index a5de493..05f0058 100644
--- a/app/backend/internal/metadata/shows.go
+++ b/app/backend/internal/metadata/shows.go
@@ -47,6 +47,8 @@ type Show struct {
Logo string `json:"logo,omitempty"`
Genres []string `json:"genres,omitempty"`
Rating string `json:"rating,omitempty"` // US content rating
+ Score float64 `json:"score,omitempty"` // members' average out of 10, one decimal
+ Votes int `json:"votes,omitempty"` // how many members voted
People []string `json:"people,omitempty"`
OtherNames []string `json:"other_names,omitempty"` // original, alternative and translated names
Seasons []Season `json:"seasons,omitempty"`
diff --git a/app/backend/internal/metadata/tmdb.go b/app/backend/internal/metadata/tmdb.go
index 4ec1191..cdecead 100644
--- a/app/backend/internal/metadata/tmdb.go
+++ b/app/backend/internal/metadata/tmdb.go
@@ -517,6 +517,13 @@ type tmdbExtras struct {
Job string `json:"job"`
} `json:"crew"`
} `json:"credits"`
+ VoteAverage float64 `json:"vote_average"`
+ VoteCount int `json:"vote_count"`
+}
+
+// score is the members' average to one decimal and its vote count.
+func (x tmdbExtras) score() (float64, int) {
+ return float64(int(x.VoteAverage*10+0.5)) / 10, x.VoteCount
}
// maxCast is how many cast names a Title keeps.
@@ -620,6 +627,7 @@ func (m tmdbMovie) movieWithCollection(images string, collectionKnown bool) Movi
out.CinemaDate, out.DigitalDate, out.PhysicalDate = m.dates()
out.Backdrop, out.Logo, out.Genres, out.People = m.tmdbExtras.pictures(images)
out.Directors = m.tmdbExtras.directors()
+ out.Score, out.Votes = m.tmdbExtras.score()
for _, c := range m.ProductionCompanies {
if c.Name != "" {
out.Studio = c.Name
diff --git a/app/backend/internal/metadata/tmdb_test.go b/app/backend/internal/metadata/tmdb_test.go
index fc4112c..7196d27 100644
--- a/app/backend/internal/metadata/tmdb_test.go
+++ b/app/backend/internal/metadata/tmdb_test.go
@@ -2,6 +2,7 @@ package metadata
import (
"context"
+ "encoding/json"
"errors"
"net/http"
"net/http/httptest"
@@ -174,3 +175,27 @@ func TestTokenFile(t *testing.T) {
}
func writeFile(p, s string) error { return os.WriteFile(p, []byte(s), 0o600) }
+
+// The members' average and vote count come with every movie and show answer
+// and are kept to one decimal; an answer without them gives 0 and 0.
+func TestTMDBScoreAndVotes(t *testing.T) {
+ var m tmdbMovie
+ if err := json.Unmarshal([]byte(`{"id":1,"title":"A","vote_average":7.86,"vote_count":1200}`), &m); err != nil {
+ t.Fatal(err)
+ }
+ if got := m.movie(""); got.Score != 7.9 || got.Votes != 1200 {
+ t.Fatalf("movie score %v votes %d", got.Score, got.Votes)
+ }
+ var s tmdbShow
+ if err := json.Unmarshal([]byte(`{"id":2,"name":"B","vote_average":6.04,"vote_count":80}`), &s); err != nil {
+ t.Fatal(err)
+ }
+ if got := s.show(""); got.Score != 6.0 || got.Votes != 80 {
+ t.Fatalf("show score %v votes %d", got.Score, got.Votes)
+ }
+ var bare tmdbMovie
+ _ = json.Unmarshal([]byte(`{"id":3,"title":"C"}`), &bare)
+ if got := bare.movie(""); got.Score != 0 || got.Votes != 0 {
+ t.Fatalf("no score %v votes %d", got.Score, got.Votes)
+ }
+}
diff --git a/app/backend/internal/metadata/tmdb_tv.go b/app/backend/internal/metadata/tmdb_tv.go
index c00511c..d504222 100644
--- a/app/backend/internal/metadata/tmdb_tv.go
+++ b/app/backend/internal/metadata/tmdb_tv.go
@@ -84,6 +84,7 @@ func (m tmdbShow) show(images string) Show {
}
out.Backdrop, out.Logo, out.Genres, out.People = m.tmdbExtras.pictures(images)
out.Rating = m.usRating()
+ out.Score, out.Votes = m.tmdbExtras.score()
for _, s := range m.Seasons {
out.Seasons = append(out.Seasons, Season{Number: s.Number, Name: s.Name})
}
diff --git a/app/backend/internal/metadata/types.go b/app/backend/internal/metadata/types.go
index e45df9b..92a9a52 100644
--- a/app/backend/internal/metadata/types.go
+++ b/app/backend/internal/metadata/types.go
@@ -26,6 +26,8 @@ type Movie struct {
Logo string `json:"logo,omitempty"` // English or no-language logo PNG URL (w500)
Genres []string `json:"genres,omitempty"` // provider genre names, English
Rating string `json:"rating,omitempty"` // US certification, "" when unknown
+ Score float64 `json:"score,omitempty"` // members' average out of 10, one decimal
+ Votes int `json:"votes,omitempty"` // how many members voted
People []string `json:"people,omitempty"` // top cast, then directors (names only)
// Directors are the directors alone (names only).
Directors []string `json:"directors,omitempty"`
diff --git a/app/backend/internal/shows/schedule.go b/app/backend/internal/shows/schedule.go
index 821c247..d51a6f0 100644
--- a/app/backend/internal/shows/schedule.go
+++ b/app/backend/internal/shows/schedule.go
@@ -84,7 +84,8 @@ func showFacts(ctx context.Context, db database.Lister, titleID int64, now time.
// KindRefreshShows is the 12-hour show refresh, or every show by hand.
const KindRefreshShows = "refresh_shows"
-// ShowRefreshPlan picks the shows a refresh-all run covers.
+// ShowRefreshPlan picks the shows a refresh-all run covers: up to
+// library.ScoreFillPerRun shows with no score yet, then what the rules say.
func (s *Service) ShowRefreshPlan(ctx context.Context, byHand bool) (ids []int64, why map[int64]string, err error) {
db := s.Store.Read()
ts, err := database.Select[mediafiles.Title](ctx, db, "titles", "kind = 'show' AND state != 'removed' ORDER BY sort_name, id")
@@ -93,11 +94,16 @@ func (s *Service) ShowRefreshPlan(ctx context.Context, byHand bool) (ids []int64
}
why = map[int64]string{}
now := s.Clock()
+ filled := 0
for _, t := range ts {
if byHand {
ids, why[t.ID] = append(ids, t.ID), "by hand"
continue
}
+ if filled < library.ScoreFillPerRun && library.NeedsScore(t, now, showFresh) {
+ ids, why[t.ID], filled = append(ids, t.ID), "no score yet", filled+1
+ continue
+ }
f, err := showFacts(ctx, db, t.ID, now)
if err != nil {
return nil, nil, err
diff --git a/app/backend/internal/shows/schedule_test.go b/app/backend/internal/shows/schedule_test.go
index e754e60..ede4fe2 100644
--- a/app/backend/internal/shows/schedule_test.go
+++ b/app/backend/internal/shows/schedule_test.go
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"errors"
+ "fmt"
"strings"
"sync"
"testing"
@@ -314,3 +315,46 @@ func TestRefreshShowsJobStopsOnNoAccess(t *testing.T) {
}
})
}
+
+// Shows with no score yet are picked once the 6 hours have passed, even
+// when the rules say no, at most library.ScoreFillPerRun a run; dropped
+// shows are skipped.
+func TestShowRefreshPlanFillsScores(t *testing.T) {
+ s := open(t)
+ ctx := context.Background()
+ svc, _ := scheduleSvc(t, s, metadata.ShowSources{})
+ total := library.ScoreFillPerRun + 5
+ if err := s.Write(ctx, func(tx *sql.Tx) error {
+ for i := range total {
+ name, at := fmt.Sprintf("Show %03d", i), now.Add(-7*time.Hour)
+ var dropped any
+ switch i {
+ case 0:
+ at = now.Add(-5 * time.Hour)
+ case 1:
+ dropped = database.FormatTime(at)
+ }
+ if _, err := tx.Exec(`INSERT INTO titles (created_at, created_by, updated_at, updated_by, kind, name, sort_name, metadata_source, why_added, status, refreshed_at, dropped_at)
+ VALUES (?, '{"kind":"system"}', ?, '{"kind":"system"}', 'show', ?, ?, 'tmdb', 'by_hand', 'ended', ?, ?)`,
+ database.FormatTime(now), database.FormatTime(now), name, strings.ToLower(name), database.FormatTime(at), dropped); err != nil {
+ return err
+ }
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+ ids, why, err := svc.ShowRefreshPlan(ctx, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ filled := 0
+ for _, id := range ids {
+ if why[id] == "no score yet" {
+ filled++
+ }
+ }
+ if len(ids) != library.ScoreFillPerRun || filled != len(ids) || why[1] != "" || why[2] != "" || why[3] != "no score yet" {
+ t.Fatalf("planned %d, filled %d, why %q %q %q", len(ids), filled, why[1], why[2], why[3])
+ }
+}
diff --git a/app/backend/internal/shows/score_test.go b/app/backend/internal/shows/score_test.go
new file mode 100644
index 0000000..35b429e
--- /dev/null
+++ b/app/backend/internal/shows/score_test.go
@@ -0,0 +1,27 @@
+package shows
+
+import (
+ "testing"
+
+ "github.com/HolyArrs/holyarrs/app/backend/internal/mediafiles"
+ "github.com/HolyArrs/holyarrs/app/backend/internal/metadata"
+)
+
+// A show switched to TVMaze keeps the score TMDB gave it; one that never had a
+// score is still marked as looked up, so the back-fill does not pick it again.
+func TestShowScoreKeptOffTMDB(t *testing.T) {
+ var ti mediafiles.Title
+ applyShow(&ti, metadata.Show{Source: "tmdb", Name: "Mashle", Score: 8.4, Votes: 12000})
+ if ti.Score == nil || *ti.Score != 8.4 || ti.Votes != 12000 {
+ t.Fatalf("tmdb score %v %d", ti.Score, ti.Votes)
+ }
+ applyShow(&ti, metadata.Show{Source: "tvmaze", Name: "Mashle"})
+ if ti.Score == nil || *ti.Score != 8.4 || ti.Votes != 12000 {
+ t.Fatalf("score lost on tvmaze %v %d", ti.Score, ti.Votes)
+ }
+ var fresh mediafiles.Title
+ applyShow(&fresh, metadata.Show{Source: "tvmaze", Name: "New"})
+ if fresh.Score == nil || *fresh.Score != 0 {
+ t.Fatalf("tvmaze show without a score: %v", fresh.Score)
+ }
+}
diff --git a/app/backend/internal/shows/service.go b/app/backend/internal/shows/service.go
index addcc15..22d111a 100644
--- a/app/backend/internal/shows/service.go
+++ b/app/backend/internal/shows/service.go
@@ -168,7 +168,12 @@ func applyShow(t *mediafiles.Title, sh metadata.Show) {
default:
t.Status = "running"
}
- library.ApplyDetails(t, sh.Backdrop, sh.Logo, sh.Genres, sh.Rating, sh.People, sh.Runtime)
+ score, votes := t.Score, t.Votes
+ library.ApplyDetails(t, sh.Backdrop, sh.Logo, sh.Genres, sh.Rating, sh.People, sh.Runtime, sh.Score, sh.Votes)
+ // Only TMDB gives a score, so a show on another source keeps the one it had.
+ if sh.Source != "tmdb" && score != nil {
+ t.Score, t.Votes = score, votes
+ }
}
// absolutes gives each regular episode its absolute number: the source's,
diff --git a/app/backend/tools/structurecheck/testdata/baseline-migrations.txt b/app/backend/tools/structurecheck/testdata/baseline-migrations.txt
index e6f010a..215dc34 100644
--- a/app/backend/tools/structurecheck/testdata/baseline-migrations.txt
+++ b/app/backend/tools/structurecheck/testdata/baseline-migrations.txt
@@ -102,3 +102,4 @@ main 0100_plex_watchlist_chosen.sql 4c05b0cd27b4a0b60bcf262aa2261937083d871c330b
main 0101_library_folder_copies_expected.sql 11d78e688fe6ba9985ff736ea60895772a5facadcf55b34b29adf94ab3c305f4
main 0102_move_per_instance.sql 4e25a81a66fcb40a8ee7b57c8889be8e05f4257cf5460a1c0291324639ca4704
main 0103_own_trait_size.sql c3af7decd065a17676d1bbba1a27e174e3a8975aa9bfa2b48814136312e4a0da
+main 0104_title_score.sql 100561ffefc752246dd55a3cee9acb5762b3292898d6bb54096bb84d78a0534d
diff --git a/app/frontend/src/lib/core/i18n/messages/ar/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/ar/mediafiles.json
index 97f86ee..437e732 100644
--- a/app/frontend/src/lib/core/i18n/messages/ar/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/ar/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "السنة",
"mediafiles.col.genres": "الأنواع",
"mediafiles.col.rating": "التصنيف العمري",
+ "mediafiles.col.score": "التقييم",
"mediafiles.col.requested": "طلبه",
"mediafiles.col.quality": "جودة الملف",
"mediafiles.col.kept": "مواكَب للجديد",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "التقدّم",
"mediafiles.sort.release": "الصدور",
"mediafiles.sort.runtime": "المدة",
+ "mediafiles.sort.score": "التقييم",
"mediafiles.sort.network": "الشبكة",
"mediafiles.sort.rules": "الجودة",
"mediafiles.sort.nextRelease": "الإصدار التالي",
diff --git a/app/frontend/src/lib/core/i18n/messages/de/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/de/mediafiles.json
index 7388cee..dc26367 100644
--- a/app/frontend/src/lib/core/i18n/messages/de/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/de/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Jahr",
"mediafiles.col.genres": "Genres",
"mediafiles.col.rating": "Altersfreigabe",
+ "mediafiles.col.score": "Wertung",
"mediafiles.col.requested": "Angefragt von",
"mediafiles.col.quality": "Dateiqualität",
"mediafiles.col.kept": "Aktuell gehalten",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Fortschritt",
"mediafiles.sort.release": "Erschienen",
"mediafiles.sort.runtime": "Laufzeit",
+ "mediafiles.sort.score": "Wertung",
"mediafiles.sort.network": "Sender",
"mediafiles.sort.rules": "Qualität",
"mediafiles.sort.nextRelease": "Nächste Veröffentlichung",
diff --git a/app/frontend/src/lib/core/i18n/messages/en/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/en/mediafiles.json
index 37f0221..2f8459f 100644
--- a/app/frontend/src/lib/core/i18n/messages/en/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/en/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Year",
"mediafiles.col.genres": "Genres",
"mediafiles.col.rating": "Age rating",
+ "mediafiles.col.score": "Score",
"mediafiles.col.requested": "Requested by",
"mediafiles.col.quality": "File quality",
"mediafiles.col.kept": "Kept up to date",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Progress",
"mediafiles.sort.release": "Out",
"mediafiles.sort.runtime": "Runtime",
+ "mediafiles.sort.score": "Score",
"mediafiles.sort.network": "Network",
"mediafiles.sort.rules": "Quality",
"mediafiles.sort.nextRelease": "Next release",
diff --git a/app/frontend/src/lib/core/i18n/messages/es/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/es/mediafiles.json
index c8898fa..d17f047 100644
--- a/app/frontend/src/lib/core/i18n/messages/es/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/es/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Año",
"mediafiles.col.genres": "Géneros",
"mediafiles.col.rating": "Clasificación por edad",
+ "mediafiles.col.score": "Puntuación",
"mediafiles.col.requested": "Solicitado por",
"mediafiles.col.quality": "Calidad del archivo",
"mediafiles.col.kept": "Se mantiene al día",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Progreso",
"mediafiles.sort.release": "Estreno",
"mediafiles.sort.runtime": "Duración",
+ "mediafiles.sort.score": "Puntuación",
"mediafiles.sort.network": "Cadena",
"mediafiles.sort.rules": "Calidad",
"mediafiles.sort.nextRelease": "Próximo lanzamiento",
diff --git a/app/frontend/src/lib/core/i18n/messages/fr/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/fr/mediafiles.json
index 0d53b65..9e7058e 100644
--- a/app/frontend/src/lib/core/i18n/messages/fr/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/fr/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Année",
"mediafiles.col.genres": "Genres",
"mediafiles.col.rating": "Classification par âge",
+ "mediafiles.col.score": "Note",
"mediafiles.col.requested": "Demandé par",
"mediafiles.col.quality": "Qualité du fichier",
"mediafiles.col.kept": "Tenu à jour",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Progression",
"mediafiles.sort.release": "Sortie",
"mediafiles.sort.runtime": "Durée",
+ "mediafiles.sort.score": "Note",
"mediafiles.sort.network": "Chaîne",
"mediafiles.sort.rules": "Qualité",
"mediafiles.sort.nextRelease": "Prochaine sortie",
diff --git a/app/frontend/src/lib/core/i18n/messages/hi/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/hi/mediafiles.json
index 0328688..3c481e1 100644
--- a/app/frontend/src/lib/core/i18n/messages/hi/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/hi/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "साल",
"mediafiles.col.genres": "जॉनर",
"mediafiles.col.rating": "उम्र रेटिंग",
+ "mediafiles.col.score": "स्कोर",
"mediafiles.col.requested": "रिक्वेस्ट करने वाला",
"mediafiles.col.quality": "फ़ाइल क्वालिटी",
"mediafiles.col.kept": "अप-टू-डेट रखा गया",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "प्रगति",
"mediafiles.sort.release": "रिलीज़",
"mediafiles.sort.runtime": "रनटाइम",
+ "mediafiles.sort.score": "स्कोर",
"mediafiles.sort.network": "नेटवर्क",
"mediafiles.sort.rules": "क्वालिटी",
"mediafiles.sort.nextRelease": "अगली रिलीज़",
diff --git a/app/frontend/src/lib/core/i18n/messages/it/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/it/mediafiles.json
index b8fbbca..ea3c745 100644
--- a/app/frontend/src/lib/core/i18n/messages/it/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/it/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Anno",
"mediafiles.col.genres": "Generi",
"mediafiles.col.rating": "Classificazione per età",
+ "mediafiles.col.score": "Voto",
"mediafiles.col.requested": "Richiesto da",
"mediafiles.col.quality": "Qualità del file",
"mediafiles.col.kept": "Tenuto aggiornato",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Avanzamento",
"mediafiles.sort.release": "Uscita",
"mediafiles.sort.runtime": "Durata",
+ "mediafiles.sort.score": "Voto",
"mediafiles.sort.network": "Rete",
"mediafiles.sort.rules": "Qualità",
"mediafiles.sort.nextRelease": "Prossima uscita",
diff --git a/app/frontend/src/lib/core/i18n/messages/ja/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/ja/mediafiles.json
index 5b5644c..e908a8f 100644
--- a/app/frontend/src/lib/core/i18n/messages/ja/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/ja/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "年",
"mediafiles.col.genres": "ジャンル",
"mediafiles.col.rating": "年齢区分",
+ "mediafiles.col.score": "スコア",
"mediafiles.col.requested": "リクエストした人",
"mediafiles.col.quality": "ファイルの品質",
"mediafiles.col.kept": "最新に保つ",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "進捗",
"mediafiles.sort.release": "公開",
"mediafiles.sort.runtime": "上映時間",
+ "mediafiles.sort.score": "スコア",
"mediafiles.sort.network": "放送局",
"mediafiles.sort.rules": "品質",
"mediafiles.sort.nextRelease": "次のリリース",
diff --git a/app/frontend/src/lib/core/i18n/messages/ko/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/ko/mediafiles.json
index 61cc40d..33d13a0 100644
--- a/app/frontend/src/lib/core/i18n/messages/ko/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/ko/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "연도",
"mediafiles.col.genres": "장르",
"mediafiles.col.rating": "관람 등급",
+ "mediafiles.col.score": "평점",
"mediafiles.col.requested": "요청자",
"mediafiles.col.quality": "파일 품질",
"mediafiles.col.kept": "최신 상태 유지",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "진행률",
"mediafiles.sort.release": "공개",
"mediafiles.sort.runtime": "상영 시간",
+ "mediafiles.sort.score": "평점",
"mediafiles.sort.network": "방송사",
"mediafiles.sort.rules": "품질",
"mediafiles.sort.nextRelease": "다음 발매",
diff --git a/app/frontend/src/lib/core/i18n/messages/nl/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/nl/mediafiles.json
index d75a9c3..9113216 100644
--- a/app/frontend/src/lib/core/i18n/messages/nl/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/nl/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Jaar",
"mediafiles.col.genres": "Genres",
"mediafiles.col.rating": "Leeftijdsklasse",
+ "mediafiles.col.score": "Score",
"mediafiles.col.requested": "Aangevraagd door",
"mediafiles.col.quality": "Kwaliteit van het bestand",
"mediafiles.col.kept": "Actueel gehouden",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Voortgang",
"mediafiles.sort.release": "Uit",
"mediafiles.sort.runtime": "Speelduur",
+ "mediafiles.sort.score": "Score",
"mediafiles.sort.network": "Zender",
"mediafiles.sort.rules": "Kwaliteit",
"mediafiles.sort.nextRelease": "Volgende release",
diff --git a/app/frontend/src/lib/core/i18n/messages/pl/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/pl/mediafiles.json
index b6b5d42..f63c283 100644
--- a/app/frontend/src/lib/core/i18n/messages/pl/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/pl/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Rok",
"mediafiles.col.genres": "Gatunki",
"mediafiles.col.rating": "Kategoria wiekowa",
+ "mediafiles.col.score": "Ocena",
"mediafiles.col.requested": "Prośba od",
"mediafiles.col.quality": "Jakość pliku",
"mediafiles.col.kept": "Śledzone nowości",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Postęp",
"mediafiles.sort.release": "Premiera",
"mediafiles.sort.runtime": "Czas trwania",
+ "mediafiles.sort.score": "Ocena",
"mediafiles.sort.network": "Stacja",
"mediafiles.sort.rules": "Jakość",
"mediafiles.sort.nextRelease": "Następne wydanie",
diff --git a/app/frontend/src/lib/core/i18n/messages/pt-br/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/pt-br/mediafiles.json
index d94f87e..423bac8 100644
--- a/app/frontend/src/lib/core/i18n/messages/pt-br/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/pt-br/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Ano",
"mediafiles.col.genres": "Gêneros",
"mediafiles.col.rating": "Classificação",
+ "mediafiles.col.score": "Nota",
"mediafiles.col.requested": "Pedido por",
"mediafiles.col.quality": "Qualidade do arquivo",
"mediafiles.col.kept": "Mantido em dia",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Progresso",
"mediafiles.sort.release": "Lançamento",
"mediafiles.sort.runtime": "Duração",
+ "mediafiles.sort.score": "Nota",
"mediafiles.sort.network": "Emissora",
"mediafiles.sort.rules": "Qualidade",
"mediafiles.sort.nextRelease": "Próximo lançamento",
diff --git a/app/frontend/src/lib/core/i18n/messages/ru/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/ru/mediafiles.json
index 0174b6f..5fdf826 100644
--- a/app/frontend/src/lib/core/i18n/messages/ru/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/ru/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Год",
"mediafiles.col.genres": "Жанры",
"mediafiles.col.rating": "Возрастной рейтинг",
+ "mediafiles.col.score": "Оценка",
"mediafiles.col.requested": "Запросил",
"mediafiles.col.quality": "Качество файла",
"mediafiles.col.kept": "Держится актуальным",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Прогресс",
"mediafiles.sort.release": "Выход",
"mediafiles.sort.runtime": "Длительность",
+ "mediafiles.sort.score": "Оценка",
"mediafiles.sort.network": "Телесеть",
"mediafiles.sort.rules": "Качество",
"mediafiles.sort.nextRelease": "Следующий релиз",
diff --git a/app/frontend/src/lib/core/i18n/messages/tr/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/tr/mediafiles.json
index bbb9e85..acc8d3b 100644
--- a/app/frontend/src/lib/core/i18n/messages/tr/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/tr/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Yıl",
"mediafiles.col.genres": "Türler",
"mediafiles.col.rating": "Yaş sınırı",
+ "mediafiles.col.score": "Puan",
"mediafiles.col.requested": "İsteyen",
"mediafiles.col.quality": "Dosya kalitesi",
"mediafiles.col.kept": "Güncel tutuluyor",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "İlerleme",
"mediafiles.sort.release": "Çıkış",
"mediafiles.sort.runtime": "Süre",
+ "mediafiles.sort.score": "Puan",
"mediafiles.sort.network": "Kanal",
"mediafiles.sort.rules": "Kalite",
"mediafiles.sort.nextRelease": "Sonraki çıkış",
diff --git a/app/frontend/src/lib/core/i18n/messages/uk/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/uk/mediafiles.json
index 9d35fc0..3d24ec1 100644
--- a/app/frontend/src/lib/core/i18n/messages/uk/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/uk/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "Рік",
"mediafiles.col.genres": "Жанри",
"mediafiles.col.rating": "Вікове обмеження",
+ "mediafiles.col.score": "Оцінка",
"mediafiles.col.requested": "Запросив(ла)",
"mediafiles.col.quality": "Якість файлу",
"mediafiles.col.kept": "Стежимо за оновленнями",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "Перебіг",
"mediafiles.sort.release": "Вихід",
"mediafiles.sort.runtime": "Тривалість",
+ "mediafiles.sort.score": "Оцінка",
"mediafiles.sort.network": "Мережа",
"mediafiles.sort.rules": "Якість",
"mediafiles.sort.nextRelease": "Наступний реліз",
diff --git a/app/frontend/src/lib/core/i18n/messages/zh-cn/mediafiles.json b/app/frontend/src/lib/core/i18n/messages/zh-cn/mediafiles.json
index fc7d0fa..14dc2cd 100644
--- a/app/frontend/src/lib/core/i18n/messages/zh-cn/mediafiles.json
+++ b/app/frontend/src/lib/core/i18n/messages/zh-cn/mediafiles.json
@@ -213,6 +213,7 @@
"mediafiles.col.year": "年份",
"mediafiles.col.genres": "类型",
"mediafiles.col.rating": "年龄分级",
+ "mediafiles.col.score": "评分",
"mediafiles.col.requested": "请求者",
"mediafiles.col.quality": "文件画质",
"mediafiles.col.kept": "持续追踪",
@@ -237,6 +238,7 @@
"mediafiles.sort.progress": "进度",
"mediafiles.sort.release": "上映",
"mediafiles.sort.runtime": "时长",
+ "mediafiles.sort.score": "评分",
"mediafiles.sort.network": "电视网",
"mediafiles.sort.rules": "画质",
"mediafiles.sort.nextRelease": "下次发行",
diff --git a/app/frontend/src/lib/core/types.ts b/app/frontend/src/lib/core/types.ts
index aea8308..d7596ce 100644
--- a/app/frontend/src/lib/core/types.ts
+++ b/app/frontend/src/lib/core/types.ts
@@ -47,6 +47,9 @@ export interface TitleView {
genres?: string[];
runtime_minutes?: number;
rating?: string;
+ // Members' average out of 10 and its vote count (not the age rating); missing when not known.
+ score?: number;
+ votes?: number;
added_at?: string;
size_bytes?: number;
copy?: TitleCopy;
diff --git a/app/frontend/src/lib/mediafiles/LibraryList.svelte b/app/frontend/src/lib/mediafiles/LibraryList.svelte
index b5bcd80..de3cc32 100644
--- a/app/frontend/src/lib/mediafiles/LibraryList.svelte
+++ b/app/frontend/src/lib/mediafiles/LibraryList.svelte
@@ -30,7 +30,7 @@
import { exceptionChip, firstOfLetter, letterOf, letters, missingEpisodes, posterStatus, type Kind } from './library.ts';
import { libraryState } from './library-state.ts';
import { partOff } from './parts.svelte.ts';
- import { buildEntries, cell, grow, isProgressCol, posterExtra, posterFacts, requestedBy, rowCell, shrink, tone, type Entry, type View } from './library-view.ts';
+ import { buildEntries, cell, grow, isProgressCol, posterExtra, posterFacts, requestedBy, rowCell, scoreText, shrink, tone, type Entry, type View } from './library-view.ts';
import { needsAttention, barOf, type PosterDetail } from './poster.ts';
import { columnSort, progressOf, sortName, sortsFor, tableMinWidth, type Column, type FilterState, type LibKind, type SortDir, type SortKey } from './table.ts';
import { artName, slotKind } from './title-page.ts';
@@ -104,10 +104,10 @@
const actsW = $derived(96 + (touchActs ? 48 : 0));
const factCols = $derived(chosenCols.filter((c) => c.id !== 'status' && c.id !== 'kept'));
const rowCols = $derived.by(() => {
- if (kind === 'all') return [];
let room = listWidth - 10 - 52 - 120 - 168 - actsW - 12 * 3 - (selecting ? 28 + 12 : 0);
const out: Column[] = [];
- for (const c of factCols) {
+ // All mixes kinds, so its rows show only the score, and only while sorted by it.
+ for (const c of kind === 'all' ? factCols.filter((c) => c.id === 'score' && sort.key === 'score') : factCols) {
if (out.length === 3 || (out.length && room < colPx(c) + 12)) break;
out.push(c);
room -= colPx(c) + 12;
@@ -318,7 +318,7 @@
{@const p = progressOf(t)}
{@const ls = who === 'staff' ? libraryState(t) : null}
<li class="item" style:--poster-ratio={posterRatio(t.kind)} animate:flip={{ duration: moveMs, easing: easeOut }} data-testid="library-card" data-title-id={t.id} data-letter={letterOf(sortName(t.name))} class:selected={picked.has(t.id)} class:last-opened={lastOpenedId === t.id}>
- <LibraryPoster title={t.name} year={t.year} href={openLink(t)} image={posterSrc(t.artwork[0], gridMin)} kind={t.kind === 'artist' ? 'artist' : t.kind === 'show' ? 'show' : 'movie'} vtName={artName(t.id)} status={ls} attention={needsAttention(ls)} bar={barOf(ls, p.have, p.total)} detail={posterDetail} extra={posterExtra(t)} facts={posterFacts(t)} kept={t.keep_up_to_date} {canManage} {selecting} selected={picked.has(t.id)} onsearch={() => searchTitles([t.id])} onkeep={(k) => setKeep([t.id], k)} />
+ <LibraryPoster title={t.name} year={t.year} href={openLink(t)} image={posterSrc(t.artwork[0], gridMin)} kind={t.kind === 'artist' ? 'artist' : t.kind === 'show' ? 'show' : 'movie'} vtName={artName(t.id)} status={ls} attention={needsAttention(ls)} bar={barOf(ls, p.have, p.total)} detail={posterDetail} extra={posterExtra(t)} facts={posterFacts(t)} score={sort.key === 'score' ? scoreText(t) : ''} kept={t.keep_up_to_date} {canManage} {selecting} selected={picked.has(t.id)} onsearch={() => searchTitles([t.id])} onkeep={(k) => setKeep([t.id], k)} />
{#if selecting}
<button type="button" class="pick" aria-pressed={picked.has(t.id)} aria-label={tr('mediafiles.list.select', { name: t.name })} onclick={() => togglePick(t.id)} data-testid="library-pick"><span class="pick-dot" aria-hidden="true">{#if picked.has(t.id)}<Icon name="check" size={14} stroke={3} />{/if}</span></button>
{/if}
@@ -327,7 +327,7 @@
{/each}
</ul>
{:else}
- <div class="rows {view}" class:v-rows={view === 'rows'} class:has-select={selecting} style="--acts-w: {actsW}px; --cols: {gridCols}; --table-min: {tableMin}px; --banner-w: {bannerW}px; --row-pad: {20 + touchActs}px" bind:this={listEl} bind:clientWidth={listWidth}>
+ <div class="rows {view}" class:v-rows={view === 'rows'} class:has-select={selecting} style="--acts-w: {actsW}px; --cols: {gridCols}; --table-min: {tableMin}px; --banner-w: {bannerW}px; --row-pad: {20 + touchActs + (view === 'table' && !phone && hiddenCols > 0 ? 16 : 0)}px" bind:this={listEl} bind:clientWidth={listWidth}>
{#if view === 'rows' && !phone}
<div class="lh" role="presentation" style="--facts: {factsTpl}">
{#if selecting}<span></span>{/if}
@@ -434,7 +434,7 @@
<span class="name">
<a href={openLink(t)} tabindex="-1" title={t.name}>{t.name}</a>
<span class="sub">
- {#if kind === 'all'}{kindLabel(t.kind)}{#if t.year} · {t.year}{/if}{/if}
+ {#if kind === 'all'}{kindLabel(t.kind)}{#if t.year} · {t.year}{/if}{#if sort.key === 'score' && !phone && scoreText(t)} · ★ {scoreText(t)}{/if}{/if}
{#if ls && (kind === 'all' || phone || !shownCols.some((c) => c.id === 'status'))}<span class="ls {ls.tone}" data-testid="library-status" data-state={ls.key}><i class="dot" aria-hidden="true"></i>{ls.label}</span>{/if}
</span>
{#if phone}<span class="facts">{factCols.slice(0, 3).map((c) => (isProgressCol(c) ? `${p.have}/${p.total}` : cell(t, c, seriesOf(t)))).filter(Boolean).join(' · ')}</span>{/if}
diff --git a/app/frontend/src/lib/mediafiles/LibraryPoster.svelte b/app/frontend/src/lib/mediafiles/LibraryPoster.svelte
index ad22fee..25c34a9 100644
--- a/app/frontend/src/lib/mediafiles/LibraryPoster.svelte
+++ b/app/frontend/src/lib/mediafiles/LibraryPoster.svelte
@@ -50,6 +50,7 @@
detail = 'status',
extra = '',
facts = [],
+ score = '',
kept,
canManage = false,
selecting = false,
@@ -72,6 +73,8 @@
extra?: string;
facts?: string[];
+ // Shown on the art while the Library is sorted by score.
+ score?: string;
kept: boolean;
canManage?: boolean;
selecting?: boolean;
@@ -91,7 +94,7 @@
const pic = $derived(sized(image, 'poster', cw || 200));
const kindIcon = $derived<IconName>(kind === 'show' ? 'tv' : kind === 'artist' ? 'music' : 'film');
const words = $derived(ls?.label ?? (bar.tone === 'ok' ? t('mediafiles.poster.inLibrary') : ''));
- const name = $derived([title, year, words].filter(Boolean).join(', '));
+ const name = $derived([title, year, words, score && `${t('mediafiles.col.score')} ${score}`].filter(Boolean).join(', '));
$effect(() => {
if (!root) return;
@@ -136,6 +139,10 @@
{#if attention && ls}
<span class="badge {bar.tone}" aria-hidden="true"><Icon name={ls.icon} size={12} stroke={2.25} />{#if ls.percent !== undefined && bar.tone === 'busy'}<b>{ls.percent}%</b>{/if}</span>
{/if}
+ <!-- While picking, the pick dot takes this corner. -->
+ {#if score && !selecting}
+ <span class="badge score" aria-hidden="true"><svg width="10" height="10" viewBox="0 0 12 12"><path d="M6 .8l1.6 3.3 3.6.5-2.6 2.5.6 3.6L6 9l-3.2 1.7.6-3.6L.8 4.6l3.6-.5z" fill="currentColor" /></svg><b>{score}</b></span>
+ {/if}
<span class="line {bar.tone}" aria-hidden="true"><i style="transform: scaleX({bar.fill})"></i></span>
</a>
{#if !touch}
@@ -176,6 +183,7 @@
.badge.gap { color: var(--wait-on-art, #ffb340); }
.badge.idle { color: rgb(255 255 255 / 82%); }
.badge b { color: #fff; font-weight: 600; }
+ .badge.score { right: auto; left: 7px; padding: 0 7px 0 6px; color: #f5c518; }
.line { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgb(0 0 0 / 38%); }
diff --git a/app/frontend/src/lib/mediafiles/index.ts b/app/frontend/src/lib/mediafiles/index.ts
index d57c821..a35a00c 100644
--- a/app/frontend/src/lib/mediafiles/index.ts
+++ b/app/frontend/src/lib/mediafiles/index.ts
@@ -12,6 +12,7 @@ export { canAdopt } from './organise.ts';
export { changedParts } from './title-defaults.ts';
export { choices } from './organise.ts';
export { chooseWarnings } from './releases.ts';
+export { chosenColumns } from './table.ts';
export { codecLabel } from './copies.ts';
export { collectionBody } from './collections.ts';
export { collectionResultLine } from './collections.ts';
diff --git a/app/frontend/src/lib/mediafiles/library-view.test.ts b/app/frontend/src/lib/mediafiles/library-view.test.ts
index 1f4c4fe..ac6ab47 100644
--- a/app/frontend/src/lib/mediafiles/library-view.test.ts
+++ b/app/frontend/src/lib/mediafiles/library-view.test.ts
@@ -30,6 +30,10 @@ describe('rowCell / cell', () => {
expect(cell({ ...m, digital_date: undefined, cinema_date: '2999-01-01' } as TitleView, col('release'), '')).toMatch(/^Cinemas/);
expect(cell(m, col('series'), 'Matrix')).toBe('Matrix');
expect(cell(m, col('nope'), '')).toBe('');
+ expect(cell({ ...m, score: 7.4, votes: 900 } as TitleView, col('score'), '')).toBe('★ 7.4');
+ expect(cell({ ...m, score: 8, votes: 900 } as TitleView, col('score'), '')).toBe('★ 8.0');
+ expect(cell({ ...m, score: 9.1, votes: 3 } as TitleView, col('score'), '')).toBe('');
+ expect(cell(m, col('score'), '')).toBe('');
expect(rowCell(m, col('episodes'), { have: 3, total: 10 }, '')).toBe('3/10');
expect(rowCell(m, col('episodes'), { have: 0, total: 0 }, '')).toBe('');
});
diff --git a/app/frontend/src/lib/mediafiles/library-view.ts b/app/frontend/src/lib/mediafiles/library-view.ts
index 0136728..a9075cb 100644
--- a/app/frontend/src/lib/mediafiles/library-view.ts
+++ b/app/frontend/src/lib/mediafiles/library-view.ts
@@ -9,6 +9,7 @@ import { quality } from '#lib/ui/title-cards.ts';
import { t as tr } from '../core/i18n/i18n.svelte.ts';
import { codecLabel, languageName } from './copies.ts';
import { libraryState } from './library-state.ts';
+import { shownScore } from '../core/rating.ts';
import { progressOf, releaseDate, type Column } from './table.ts';
export type View = 'rows' | 'table' | 'posters' | 'overview';
@@ -63,6 +64,11 @@ function movieOut(t: TitleView): string {
return date(releaseDate(t)) || tr('mediafiles.view.notKnown');
}
+/** A title's score to one decimal, or '' when it has none or too few votes. */
+export function scoreText(t: TitleView): string {
+ return shownScore(t.score, t.votes)?.toFixed(1) ?? '';
+}
+
export function cell(t: TitleView, c: Column, series: string): string {
switch (c.id) {
case 'network': return t.show?.network ?? '';
@@ -77,6 +83,7 @@ export function cell(t: TitleView, c: Column, series: string): string {
case 'audio': return (t.copy?.audio_languages ?? []).map(languageName).join(', ');
case 'genres': return (t.genres ?? []).slice(0, 3).join(', ');
case 'rating': return t.rating ?? '';
+ case 'score': return scoreText(t) ? `★ ${scoreText(t)}` : '';
case 'path': return t.folder_path ?? '';
case 'release': return t.kind === 'movie' ? movieOut(t) : '';
case 'runtime': return t.runtime_minutes ? tr('mediafiles.view.runtime', { h: Math.floor(t.runtime_minutes / 60), m: t.runtime_minutes % 60 }) : '';
diff --git a/app/frontend/src/lib/mediafiles/table.test.ts b/app/frontend/src/lib/mediafiles/table.test.ts
index 7815053..e76fa2b 100644
--- a/app/frontend/src/lib/mediafiles/table.test.ts
+++ b/app/frontend/src/lib/mediafiles/table.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import type { TitleView } from '../core/types.ts';
-import { applyLayout, columnsFor, filterCounts, loadColumns, loadSaved, moveColumn, noFilter, passes, saveColumns, saveSaved, sortLabel, sortTitles, tableMinWidth, type FilterContext } from './table.ts';
+import { applyLayout, chosenColumns, columnsFor, columnSort, filterCounts, loadColumns, loadSaved, moveColumn, noFilter, passes, saveColumns, saveSaved, sortLabel, sortLabels, sortsFor, sortTitles, startDir, tableMinWidth, type FilterContext } from './table.ts';
function memory() {
const m = new Map<string, string>();
@@ -68,6 +68,31 @@ describe('sorting', () => {
const shows = [show(7, 'Ended', {}), show(8, 'Soon', { next_air_date: '2026-11-01' }), show(9, 'Sooner', { next_air_date: '2026-10-25' })];
expect(sortTitles(shows, 'next').map((t) => t.id)).toEqual([9, 8, 7]);
});
+ it('sorts by score, highest first, with unscored and low-vote titles last both ways', () => {
+ const scored = [
+ movie(1, 'Mid', { score: 7.4, votes: 900 }),
+ movie(2, 'None', {}),
+ movie(3, 'Top', { score: 8.1, votes: 5000 }),
+ movie(4, 'Few votes', { score: 9.5, votes: 3 }),
+ movie(5, 'Low', { score: 6, votes: 40 }),
+ movie(6, 'Zero', { score: 0, votes: 0 })
+ ];
+ expect(startDir('score')).toBe('desc');
+ expect(sortTitles(scored, 'score', 'desc').map((t) => t.id)).toEqual([3, 1, 5, 4, 2, 6]);
+ expect(sortTitles(scored, 'score', 'asc').map((t) => t.id)).toEqual([5, 1, 3, 4, 2, 6]);
+ });
+ it('breaks score ties by name', () => {
+ const tie = [movie(1, 'Zulu', { score: 7, votes: 100 }), movie(2, 'Alpha', { score: 7, votes: 100 })];
+ expect(sortTitles(tie, 'score', 'desc').map((t) => t.id)).toEqual([2, 1]);
+ });
+ it('offers score for movies, shows and All, never for music', () => {
+ for (const k of ['movie', 'show', 'all'] as const) expect(sortsFor(k)).toContain('score');
+ expect(sortsFor('artist')).not.toContain('score');
+ expect(columnSort.score).toBe('score');
+ expect(columnsFor('movie').find((c) => c.id === 'score')?.on).toBe(false);
+ expect(columnsFor('show').find((c) => c.id === 'score')?.on).toBe(false);
+ expect(columnsFor('artist').some((c) => c.id === 'score')).toBe(false);
+ });
});
describe('filter counts', () => {
@@ -125,6 +150,39 @@ describe('tableMinWidth', () => {
});
});
+describe('chosenColumns', () => {
+ it('shows the score right after the status while sorting by score, without saving it', () => {
+ const cols = columnsFor('movie');
+ const before = JSON.stringify(cols);
+ const ids = chosenColumns(cols, 'score').map((c) => c.id);
+ expect(ids.slice(0, 2)).toEqual(['status', 'score']);
+ expect(ids.filter((id) => id === 'score')).toHaveLength(1);
+ expect(JSON.stringify(cols)).toBe(before);
+ const store = memory();
+ saveColumns(1, 'movie', cols, store);
+ expect(loadColumns(1, 'movie', store).find((c) => c.id === 'score')?.on).toBe(false);
+ });
+ it('moves a score column that is on to the front, and leads with it when status is off', () => {
+ const on = columnsFor('movie').map((c) => (c.id === 'score' ? { ...c, on: true } : c));
+ expect(chosenColumns(on, 'score').map((c) => c.id).slice(0, 2)).toEqual(['status', 'score']);
+ const noStatus = on.filter((c) => c.id !== 'status');
+ expect(chosenColumns(noStatus, 'score')[0].id).toBe('score');
+ });
+ it('is only the columns that are on for any other sort, and for music', () => {
+ const cols = columnsFor('movie');
+ expect(chosenColumns(cols, 'name')).toEqual(cols.filter((c) => c.on));
+ expect(chosenColumns(columnsFor('artist'), 'score')).toEqual(columnsFor('artist').filter((c) => c.on));
+ });
+});
+
+describe('labels', () => {
+ it('every sort and column has English words', () => {
+ for (const [k, label] of Object.entries(sortLabels)) expect(label, k).not.toBe(`mediafiles.sort.${k}`);
+ for (const kind of ['movie', 'show', 'artist'] as const) for (const c of columnsFor(kind)) expect(c.label, c.id).not.toBe(`mediafiles.col.${c.id}`);
+ expect(sortLabels.score).toBe('Score');
+ });
+});
+
describe('sortLabel', () => {
it('names the Music next sort a release', () => {
expect(sortLabel('next', 'artist')).toBe('Next release');
diff --git a/app/frontend/src/lib/mediafiles/table.ts b/app/frontend/src/lib/mediafiles/table.ts
index 83a083e..3a9b9e0 100644
--- a/app/frontend/src/lib/mediafiles/table.ts
+++ b/app/frontend/src/lib/mediafiles/table.ts
@@ -2,12 +2,13 @@
import type { TitleView } from '../core/types.ts';
import { matches, type Filter } from './library.ts';
import { libraryState } from './library-state.ts';
+import { shownScore } from '../core/rating.ts';
import { t as tr } from '../core/i18n/i18n.svelte.ts';
export type LibKind = 'movie' | 'show' | 'artist';
export type ColumnId =
- | 'status' | 'network' | 'rules' | 'next' | 'last' | 'seasons' | 'episodes' | 'added' | 'year' | 'size' | 'genres' | 'rating' | 'path'
+ | 'status' | 'network' | 'rules' | 'next' | 'last' | 'seasons' | 'episodes' | 'added' | 'year' | 'size' | 'genres' | 'rating' | 'score' | 'path'
| 'release' | 'runtime' | 'series' | 'albums' | 'tracks' | 'latest' | 'requested' | 'quality' | 'kept' | 'showstate' | 'activity' | 'codec' | 'audio';
export interface Column {
@@ -22,7 +23,7 @@ export interface Column {
export type ColumnLayout = { id: ColumnId; on: boolean }[];
-export type SortKey = 'status' | 'name' | 'year' | 'added' | 'size' | 'next' | 'last' | 'progress' | 'release' | 'runtime' | 'network' | 'rules';
+export type SortKey = 'status' | 'name' | 'year' | 'added' | 'size' | 'next' | 'last' | 'progress' | 'release' | 'runtime' | 'network' | 'rules' | 'score';
export type SortDir = 'asc' | 'desc';
export type Kept = 'any' | 'on' | 'off';
@@ -64,7 +65,7 @@ export interface SavedFilter {
// Each label reads its words when used, so it follows the language.
export const sortLabels = {} as Record<SortKey, string>;
-for (const k of ['status', 'name', 'year', 'added', 'size', 'next', 'last', 'progress', 'release', 'runtime', 'network', 'rules'] as SortKey[]) {
+for (const k of ['status', 'name', 'year', 'added', 'size', 'next', 'last', 'progress', 'release', 'runtime', 'network', 'rules', 'score'] as SortKey[]) {
Object.defineProperty(sortLabels, k, { get: () => tr(`mediafiles.sort.${k}`), enumerable: true });
}
@@ -72,7 +73,7 @@ for (const k of ['status', 'name', 'year', 'added', 'size', 'next', 'last', 'pro
export const columnSort: Partial<Record<ColumnId, SortKey>> = {
status: 'status',
year: 'year', added: 'added', size: 'size', next: 'next', last: 'last', episodes: 'progress', tracks: 'progress',
- release: 'release', runtime: 'runtime', network: 'network', rules: 'rules', latest: 'next'
+ release: 'release', runtime: 'runtime', network: 'network', rules: 'rules', latest: 'next', score: 'score'
};
export const noFilter: FilterState = { status: 'all', kept: 'any', asker: 'anyone', series: 0, codec: '', subs: false };
@@ -97,6 +98,7 @@ export function columnsFor(kind: LibKind): Column[] {
col('year', '64px', false, true),
col('genres', '160px', false),
col('rating', '88px', false),
+ col('score', '84px', false, true),
col('requested', '130px', false),
col('quality', '130px', false),
col('kept', '72px', false),
@@ -127,6 +129,7 @@ export function columnsFor(kind: LibKind): Column[] {
col('year', '64px', true, true),
col('runtime', '84px', false, true),
col('rating', '88px', false),
+ col('score', '84px', false, true),
col('series', '160px', false),
col('genres', '160px', false),
col('requested', '130px', false),
@@ -139,6 +142,14 @@ export function columnsFor(kind: LibKind): Column[] {
];
}
+// The columns that are on; while sorting by score its column shows right after the status, for this view only.
+export function chosenColumns(cols: Column[], key: SortKey): Column[] {
+ const on = cols.filter((c) => c.on && !(key === 'score' && c.id === 'score'));
+ const score = key === 'score' && cols.find((c) => c.id === 'score');
+ if (score) on.splice(on[0]?.id === 'status' ? 1 : 0, 0, { ...score, on: true });
+ return on;
+}
+
export function columnsKey(member: number | undefined, kind: LibKind): string {
return `holyarrs.library-columns.${member ?? 'me'}.${kind}`;
}
@@ -191,10 +202,10 @@ export function sortLabel(k: SortKey, kind: LibKind | 'all'): string {
}
export function sortsFor(kind: LibKind | 'all'): SortKey[] {
- if (kind === 'show') return ['status', 'name', 'next', 'last', 'progress', 'added', 'year', 'size', 'network', 'rules'];
+ if (kind === 'show') return ['status', 'name', 'next', 'last', 'progress', 'added', 'year', 'score', 'size', 'network', 'rules'];
if (kind === 'artist') return ['status', 'name', 'progress', 'added', 'size', 'next'];
- if (kind === 'movie') return ['status', 'name', 'year', 'release', 'added', 'size', 'runtime', 'rules'];
- return ['name', 'year', 'added', 'size'];
+ if (kind === 'movie') return ['status', 'name', 'year', 'score', 'release', 'added', 'size', 'runtime', 'rules'];
+ return ['name', 'year', 'score', 'added', 'size'];
}
// Drops a leading article so "The Wire" sorts under W.
@@ -329,6 +340,7 @@ function sortValue(t: TitleView, key: SortKey): number | string | null {
case 'runtime': return t.runtime_minutes || null;
case 'network': return t.show?.network?.toLocaleLowerCase() || null;
case 'rules': return t.pick_rules_name?.toLocaleLowerCase() || null;
+ case 'score': return shownScore(t.score, t.votes) ?? null;
case 'progress': {
const p = progressOf(t);
return p.total ? p.have / p.total : null;
diff --git a/app/frontend/src/routes/library/+page.svelte b/app/frontend/src/routes/library/+page.svelte
index 07cc3f7..7ea6017 100644
--- a/app/frontend/src/routes/library/+page.svelte
+++ b/app/frontend/src/routes/library/+page.svelte
@@ -8,7 +8,7 @@
import Sheet from '#lib/ui/Sheet.svelte';
import { audienceOf } from '#lib/ui/title-status.ts';
import { densityLabels, loadDensity, loadPosterSize, posterLabels, saveDensity, savePosterSize, type Density, type PosterSize } from '#lib/ui/library-art.ts';
- import { libraryTitles, filters, kinds, matchesTitleQuery, ofKind, titleQuery, type Filter, type Kind, activeCount, filterCounts, loadColumns, loadSaved, passes, saveColumns, saveSaved, sortTitles, sortsFor, startDir, columnsFor, defaultSort, type Column, type FilterContext, type FilterState, type Kept, type LibKind, type SavedFilter, type SortDir, type SortKey, detailLabels, flipFrom, loadPosterDetail, savePosterDetail, type PosterDetail, rememberLibraryKind, partsNow, codecLabel, copyCodecs, type CopySearchPreview, type CopySearchResult, deleteBody } from '#lib/mediafiles/index.ts';
+ import { libraryTitles, filters, kinds, matchesTitleQuery, ofKind, titleQuery, type Filter, type Kind, activeCount, filterCounts, loadColumns, loadSaved, passes, saveColumns, saveSaved, sortTitles, sortsFor, startDir, chosenColumns, columnsFor, defaultSort, type Column, type FilterContext, type FilterState, type Kept, type LibKind, type SavedFilter, type SortDir, type SortKey, detailLabels, flipFrom, loadPosterDetail, savePosterDetail, type PosterDetail, rememberLibraryKind, partsNow, codecLabel, copyCodecs, type CopySearchPreview, type CopySearchResult, deleteBody } from '#lib/mediafiles/index.ts';
import { episodeLabel, showProgress } from '#lib/shows/index.ts';
import { artistProgress, artistHref } from '#lib/music/index.ts';
import { DlFind, searchShortcut, dlTop } from '#lib/downloads/index.ts';
@@ -151,7 +151,7 @@
const me = myId;
columns = loadColumns(me, k);
});
- const chosenCols = $derived(columns.filter((c) => c.on));
+ const chosenCols = $derived(chosenColumns(columns, sort.key));
// Columns that do not fit the width wait until the window is wider (the banner and the title always stay); the header says how many wait. The art is the hero of each row, so the banner column takes its share of the width.
let density = $state<Density>('large');
let posterSize = $state<PosterSize>('m');
diff --git a/docs/library/index.md b/docs/library/index.md
index 92448ac..ac86521 100644
--- a/docs/library/index.md
+++ b/docs/library/index.md
@@ -24,6 +24,27 @@ Set up the folders, subtitles, audio and media server links that decide how your
New install: start with [Library folders](folders.md). The shared-folder layout that keeps imports instant is in [Folders and hardlinks](../start/folders.md).
+## Sorting the Library
+
+Open **Sort & filter**, pick a sort under **Sort by**, then **Ascending** or **Descending** under **Order**. A title with no value for the sort stays at the bottom either way.
+
+| Showing | Sorts |
+|---|---|
+| Movies | Status, Name, Year, Score, Out, Added, Size, Runtime, Quality |
+| TV shows | Status, Name, Next episode, Last aired, Progress, Added, Year, Score, Size, Network, Quality |
+| Music | Status, Name, Progress, Added, Size, Next release |
+| The whole Library | Name, Year, Score, Added, Size |
+
+### Score
+
+**Score** is the members' average out of 10, shown with a ★. Highest comes first.
+
+- A title needs at least 25 votes to have a score. Titles without one stay at the bottom either way, and so does music in the whole Library.
+- While you sort by Score, every view shows it: a Score column first in **Rows**, the first fact in **Banners** and **Overview**, the line under each name on a phone, and a small ★ badge on each poster in **Posters**. Titles without a score show nothing.
+- The Score column goes away when you pick another sort, unless you turned it on yourself.
+- Music has no score, so the Music sort list leaves it out. A show that has only ever taken its details from TVMaze has none either.
+- Titles already in your Library get their score over the next few scheduled refreshes, up to 300 movies and 300 shows each run. To fill every title now, open **Settings > Schedules** and select **Run now** on **Refresh movie details** and **Refresh show details**. With **Refresh movie details** turned off, movies fill only with **Run now**.
+
## Related
- [Downloaders](../downloads/downloaders.md)
diff --git a/docs/start/home-and-settings.md b/docs/start/home-and-settings.md
index f1efd7f..ce7e166 100644
--- a/docs/start/home-and-settings.md
+++ b/docs/start/home-and-settings.md
@@ -50,7 +50,7 @@ Open **Settings** from the menu. You see only the screens your account may use,
|---|---|
| **Settings > Parts** | Turn Movies, Shows, Music, Subtitles and Requests on or off |
| **Settings > Movies and TV defaults** | Set what a newly added movie or show gets |
-| **Settings > Appearance** | Theme (**Automatic**, **Dark**, **Light**), **Play trailers by themselves**, **Show Library art on the sign-in page** |
+| **Settings > Appearance** | Theme (**Automatic**, **Dark**, **Light**), **Play trailers by themselves**, **Show Library art on the sign-in page**, and **Ratings**: up to three scores beside the year on title pages. The Library's **Score** sort always uses the members' average, whatever you pick here |
| **Settings > Library folders** | Add and check folders. See [Folders](../folders/) |
| **Settings > Backups** | Back up, and **Download key kit** |