From 769e30c9c7ab00c44a5500650907541c10b90c34 Mon Sep 17 00:00:00 2001 From: IRHM Date: Thu, 30 Jul 2026 22:12:54 +0100 Subject: [PATCH] import: Support rating column decimals --- CHANGELOG.md | 2 +- doc/docs/importing/text-file.md | 2 +- src/routes/(app)/import/process/+page.svelte | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 285b6df2..4a9015c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ These changes are awaiting release: ## New -- Import(text list): Support providing a rating in square brackets. +- Import(text list): Support providing a rating (out of 10, supporting decimals) in square brackets. ## Changed diff --git a/doc/docs/importing/text-file.md b/doc/docs/importing/text-file.md index 53edec05..96678a22 100644 --- a/doc/docs/importing/text-file.md +++ b/doc/docs/importing/text-file.md @@ -19,7 +19,7 @@ Each line is a new entry. The name of the content (show/movie) must be provided. Optionally provide: - The year in brackets (eg: `(1983)`) -- A rating (out of 10) in square brackets (eg: `[4]`) +- A rating (out of 10) in square brackets (eg: `[4]` or `[6.9]`) ``` [()] diff --git a/src/routes/(app)/import/process/+page.svelte b/src/routes/(app)/import/process/+page.svelte index a32ba72a..e2195aa0 100644 --- a/src/routes/(app)/import/process/+page.svelte +++ b/src/routes/(app)/import/process/+page.svelte @@ -78,7 +78,8 @@ // which we assume is the release year of content. const yearRegex = new RegExp(/\([0-9]{4}\)/); // Matches supported rating between square brackets. - const ratingRegex = new RegExp(/\[([0-9]|10)\]/); + // Supports (the sixes can be any number 0-9): [6], [6.6], and [10]. + const ratingRegex = new RegExp(/\[([0-9](?:\.[0-9])?|10)\]/); const s = list.data.split("\n"); for (let i = 0; i < s.length; i++) { if (!s[i]) { @@ -96,7 +97,7 @@ // Try extracting a rating. const rating = l.name.match(ratingRegex); if (rating && rating.length > 0) { - console.log("found rating", rating); + // console.log("found rating", rating); l.rating = Number(rating[1]); if (typeof rating.index === "number") { l.name = l.name.slice(0, rating.index); @@ -743,6 +744,7 @@ type="number" min="0" max="10" + step="0.1" disabled={isImporting} />