package api import "strings" // The lifecycle word a schedule card wears: whether the show is still being made, whether // the film has actually come out. // // It is *arr's own vocabulary rather than a Memby one, and deliberately so — the household // operator reads the same word in Sonarr or Radarr, and a card that said something else // would be a second thing to reconcile. The gateway sends both halves: the slug is what the // television colours by, the label is what it prints, so a status this build has never // heard of still reads correctly on a TV that predates it. type lifecycleTag struct { Status string Label string } // seriesLifecycleTag maps Sonarr's series status. Anything unrecognised carries no tag at // all rather than an invented one: a card with no lifecycle is the honest answer when the // only thing we know is that Sonarr said a word we do not have. func seriesLifecycleTag(status string) lifecycleTag { switch strings.ToLower(strings.TrimSpace(status)) { case "continuing": return lifecycleTag{Status: "continuing", Label: "CONTINUING"} case "upcoming": return lifecycleTag{Status: "upcoming", Label: "UPCOMING"} case "ended": return lifecycleTag{Status: "ended", Label: "ENDED"} case "cancelled", "canceled": return lifecycleTag{Status: "cancelled", Label: "CANCELLED"} case "deleted": return lifecycleTag{Status: "deleted", Label: "REMOVED"} default: return lifecycleTag{} } } // movieLifecycleTag maps Radarr's movie status. "inCinemas" loses its capital on the wire // because the slug is a lookup key on the television, not prose. func movieLifecycleTag(status string) lifecycleTag { switch strings.ToLower(strings.TrimSpace(status)) { case "tba": return lifecycleTag{Status: "tba", Label: "TBA"} case "announced": return lifecycleTag{Status: "announced", Label: "ANNOUNCED"} case "incinemas": return lifecycleTag{Status: "incinemas", Label: "IN CINEMAS"} case "released": return lifecycleTag{Status: "released", Label: "RELEASED"} case "deleted": return lifecycleTag{Status: "deleted", Label: "REMOVED"} default: return lifecycleTag{} } }