mirror of
https://github.com/sbondCo/Watcharr.git
synced 2026-08-07 07:14:44 +00:00
import: Support rating column decimals
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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>)]
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user