import: Support rating column decimals

This commit is contained in:
IRHM
2026-07-30 22:12:54 +01:00
committed by momi
parent ba961bf5c3
commit 769e30c9c7
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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]`)
```
<name> [(<year>)]
+4 -2
View File
@@ -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}
/>
</td>