beginning support for hours - for audiobook tracking
This commit is contained in:
@@ -37,19 +37,23 @@ Licensing? I don't care. Do whatever you want. IP rights are stupid.
|
|||||||
"series": "Series",
|
"series": "Series",
|
||||||
"genre": "Fiction",
|
"genre": "Fiction",
|
||||||
"pages": 100,
|
"pages": 100,
|
||||||
|
"hours": 1.5,
|
||||||
"priority": 0,
|
"priority": 0,
|
||||||
"progress": 0.5,
|
"progress": 0.5,
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `title`, `author`, `series`, `pages`, `genre`, and `hidden` are optional.
|
- `title`, `author`, `series`, `pages`, `hours`, `genre`, and `hidden` are
|
||||||
|
optional.
|
||||||
- At least one of `title`, `author`, `series`, or `genre` must be defined.
|
- At least one of `title`, `author`, `series`, or `genre` must be defined.
|
||||||
- `priority` is the ELO ranking, initializing to `0`.
|
- `priority` is the ELO ranking, initializing to `0`.
|
||||||
- `progress` represents read/unread/in-progress status. `0` is unread, `1` is
|
- `progress` represents read/unread/in-progress status. `0` is unread, `1` is
|
||||||
read, and anything in-between in a percentage of progress.
|
read, and anything in-between in a percentage of progress.
|
||||||
- `hidden` is undefined or `true` to hide a book from ALL of the interface
|
- `hidden` is undefined or `true` to hide a book from ALL of the interface
|
||||||
without deleting its data.
|
without deleting its data.
|
||||||
|
- `hours` is hours.minutes rather than the fractional part being percentage of
|
||||||
|
an hour.
|
||||||
|
|
||||||
Despite the script supporting otherwise, I highly recommend only using this for
|
Despite the script supporting otherwise, I highly recommend only using this for
|
||||||
*specific book titles*. In my experience, using entries representing multiple
|
*specific book titles*. In my experience, using entries representing multiple
|
||||||
|
|||||||
+4
-1
@@ -81,7 +81,10 @@ local get_display_name = function(book)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if book.pages then
|
if book.pages then
|
||||||
result = result .. " ~" .. math.floor(book.progress * book.pages) .. "/" .. book.pages .. " pages read"
|
result = result .. " ~" .. math.floor(book.progress * book.pages) .. "/" .. book.pages .. " pages read (" .. math.floor(book.progress * 100) .. "%)"
|
||||||
|
elseif book.hours then
|
||||||
|
-- TODO correct for the fractional part being minutes instead of percent
|
||||||
|
result = result .. " ~" .. math.floor(book.progress * book.hours * 10) / 10 .. "/" .. book.hours .. " hours listened (" .. math.floor(book.progress * 100) .. "%)"
|
||||||
elseif book.progress > 0 and book.progress < 1 then
|
elseif book.progress > 0 and book.progress < 1 then
|
||||||
result = result .. " ~" .. math.floor(book.progress * 100) .. "% read"
|
result = result .. " ~" .. math.floor(book.progress * 100) .. "% read"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ local filters = {
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
audiobooks_only = function(book)
|
||||||
|
if book.hidden then return false end
|
||||||
|
if book.hours then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
return filters
|
return filters
|
||||||
@@ -27,6 +27,17 @@ sort_orders = {
|
|||||||
fewest_pages_remaining = function(A, B, data)
|
fewest_pages_remaining = function(A, B, data)
|
||||||
return not sort_orders.most_pages_remaining(A, B, data)
|
return not sort_orders.most_pages_remaining(A, B, data)
|
||||||
end,
|
end,
|
||||||
|
most_time_remaining = function(A, B)
|
||||||
|
if not (A.hours and B.hours) then -- fallback to percentage
|
||||||
|
return A.progress < B.progress
|
||||||
|
end
|
||||||
|
local a = A.hours - A.hours * A.progress
|
||||||
|
local b = B.hours - B.hours * B.progress
|
||||||
|
return a > b
|
||||||
|
end,
|
||||||
|
least_time_remaining = function(A, B)
|
||||||
|
return not sort_orders.most_time_remaining(A, B)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
return sort_orders
|
return sort_orders
|
||||||
Reference in New Issue
Block a user