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",
|
||||
"genre": "Fiction",
|
||||
"pages": 100,
|
||||
"hours": 1.5,
|
||||
"priority": 0,
|
||||
"progress": 0.5,
|
||||
"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.
|
||||
- `priority` is the ELO ranking, initializing to `0`.
|
||||
- `progress` represents read/unread/in-progress status. `0` is unread, `1` is
|
||||
read, and anything in-between in a percentage of progress.
|
||||
- `hidden` is undefined or `true` to hide a book from ALL of the interface
|
||||
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
|
||||
*specific book titles*. In my experience, using entries representing multiple
|
||||
|
||||
+4
-1
@@ -81,7 +81,10 @@ local get_display_name = function(book)
|
||||
end
|
||||
|
||||
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
|
||||
result = result .. " ~" .. math.floor(book.progress * 100) .. "% read"
|
||||
end
|
||||
|
||||
@@ -31,6 +31,13 @@ local filters = {
|
||||
end
|
||||
return true
|
||||
end,
|
||||
audiobooks_only = function(book)
|
||||
if book.hidden then return false end
|
||||
if book.hours then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
}
|
||||
|
||||
return filters
|
||||
@@ -27,6 +27,17 @@ sort_orders = {
|
||||
fewest_pages_remaining = function(A, B, data)
|
||||
return not sort_orders.most_pages_remaining(A, B, data)
|
||||
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
|
||||
Reference in New Issue
Block a user