0.2.78
This commit is contained in:
@@ -16,7 +16,11 @@ import (
|
||||
const (
|
||||
// The household has it. Either Emby has imported it or the *arr reports a file.
|
||||
RequestStatusAvailable = "available"
|
||||
// Accepted and being worked on: released, monitored, no file yet.
|
||||
// Being filed away: the bytes have landed and the *arr is importing them. This used to
|
||||
// mean "released, monitored, no file yet" — everything between the ask and the arrival —
|
||||
// and now means only the last step of it, with searching, found and downloading (in
|
||||
// requests_progress.go) covering the rest. A television that predates those three is
|
||||
// sent this word for all four; see collapseRequestStatus.
|
||||
RequestStatusProcessing = "processing"
|
||||
// Accepted, but there is nothing to fetch yet — unreleased, or still only in cinemas.
|
||||
RequestStatusPending = "pending"
|
||||
@@ -68,6 +72,12 @@ type RequestSubject struct {
|
||||
// Released is whether there is anything to fetch yet. A film not yet on digital and a
|
||||
// series whose first episode has not aired are both false.
|
||||
Released bool
|
||||
// Progress is what the download client is doing with it, already folded by
|
||||
// downloadProgress. It is passed in rather than computed here so that the caller — which
|
||||
// has the queue rows and has to send the percentage and the ETA anyway — folds them
|
||||
// once. An empty Status means the queue had nothing to say, which is the ordinary case
|
||||
// and not a state of its own.
|
||||
Progress requestProgress
|
||||
}
|
||||
|
||||
// requestStatusFor is the whole rule, and it is ordered by how much each signal is worth.
|
||||
@@ -77,16 +87,48 @@ type RequestSubject struct {
|
||||
// recorded. Only then does absence from the *arr mean removal — checked before the release
|
||||
// state, because an untracked title's release date says nothing about a request nobody is
|
||||
// working on any more.
|
||||
//
|
||||
// The download client outranks the release state, and that ordering is deliberate. Radarr's
|
||||
// minimum-availability setting is a policy about when to *start looking*, not a fact about
|
||||
// whether bytes are moving — a household that fetches on the cinema date has films that are
|
||||
// "not released" and 40% downloaded at the same time, and the honest thing to tell somebody
|
||||
// watching that card is the 40%.
|
||||
//
|
||||
// With nothing in the queue and nothing on disk, a tracked and released title is being
|
||||
// searched for. That is the state this feature exists to make visible: before it, the whole
|
||||
// span from "somebody asked" to "the file landed" was one word, so a viewer could not tell a
|
||||
// request nothing had been found for from one that was minutes away.
|
||||
func requestStatusFor(subject RequestSubject) string {
|
||||
switch {
|
||||
case subject.InLibrary || subject.HasFile:
|
||||
return RequestStatusAvailable
|
||||
case !subject.Tracked:
|
||||
return RequestStatusUnavailable
|
||||
case subject.Progress.Status != "":
|
||||
return subject.Progress.Status
|
||||
case !subject.Released:
|
||||
return RequestStatusPending
|
||||
default:
|
||||
return RequestStatusSearching
|
||||
}
|
||||
}
|
||||
|
||||
// collapseRequestStatus is what a television that predates the download states is told.
|
||||
//
|
||||
// The four new words all live inside the span the old "processing" covered, so an older app
|
||||
// is sent that one word and reads it exactly as it always did — "Searching for a copy",
|
||||
// filed under On the way. It loses the percentage and the estimate, which it has nowhere to
|
||||
// draw anyway, and it gains nothing wrong.
|
||||
//
|
||||
// This is a *narrowing*, never a translation in the other direction: a build that declares
|
||||
// request_progress_v1 is sent the truth. See requestProgressSupported.
|
||||
func collapseRequestStatus(status string) string {
|
||||
switch status {
|
||||
case RequestStatusSearching, RequestStatusFound,
|
||||
RequestStatusDownloading, RequestStatusFailed:
|
||||
return RequestStatusProcessing
|
||||
default:
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +173,23 @@ func seriesReleased(status string, nextAiring *time.Time, now time.Time) bool {
|
||||
func requestStatusLabel(status string) string {
|
||||
switch status {
|
||||
case RequestStatusAvailable:
|
||||
return "Available"
|
||||
return "Ready to watch"
|
||||
case RequestStatusSearching:
|
||||
return "Searching"
|
||||
case RequestStatusFound:
|
||||
return "Found"
|
||||
// Deliberately just the word. The percentage is a number that moves every ten seconds
|
||||
// and the wording does not, so the television composes "Downloading - 43%" from this
|
||||
// label and the progress field rather than the server sending a sentence that is stale
|
||||
// before it is drawn.
|
||||
case RequestStatusDownloading:
|
||||
return "Downloading"
|
||||
case RequestStatusProcessing:
|
||||
return "Processing"
|
||||
case RequestStatusPending:
|
||||
return "Pending"
|
||||
case RequestStatusFailed:
|
||||
return "Unable to download"
|
||||
case RequestStatusUnavailable:
|
||||
return "Unavailable"
|
||||
case RequestStatusRequestable:
|
||||
@@ -147,7 +201,14 @@ func requestStatusLabel(status string) string {
|
||||
|
||||
// requestStatusDetail is the quiet second line: what the state means for the viewer, in
|
||||
// plain language, rather than a repeat of the word above it.
|
||||
func requestStatusDetail(status, mediaType string) string {
|
||||
//
|
||||
// The download states are where this line earns its place, because the word above it is not
|
||||
// the news. "Downloading" is not what somebody is standing there wanting to know — when it
|
||||
// will be ready is — and this is the only line that can say so. The estimate is passed in
|
||||
// rather than recomputed so that the sentence and the estimatedReadySeconds field on the
|
||||
// wire can never disagree; when there is no estimate the line says so plainly instead of
|
||||
// reaching for a vaguer number, which is the whole of "never manufacture an ETA".
|
||||
func requestStatusDetail(status, mediaType string, estimateSeconds int) string {
|
||||
thing := "film"
|
||||
if mediaType == "series" {
|
||||
thing = "series"
|
||||
@@ -155,8 +216,19 @@ func requestStatusDetail(status, mediaType string) string {
|
||||
switch status {
|
||||
case RequestStatusAvailable:
|
||||
return "Ready to watch now"
|
||||
case RequestStatusSearching:
|
||||
return "We haven't found a suitable release yet"
|
||||
case RequestStatusFound:
|
||||
return "Preparing the download"
|
||||
case RequestStatusDownloading:
|
||||
if label := estimatedReadyLabel(estimateSeconds); label != "" {
|
||||
return label
|
||||
}
|
||||
return "We'll let you know when it's ready"
|
||||
case RequestStatusProcessing:
|
||||
return "Searching for a copy"
|
||||
return "Should be ready in a few minutes"
|
||||
case RequestStatusFailed:
|
||||
return "Memby will keep looking for another release"
|
||||
case RequestStatusPending:
|
||||
if thing == "series" {
|
||||
return "Waiting for it to air"
|
||||
|
||||
Reference in New Issue
Block a user