0.1.52 Gateway
This commit is contained in:
@@ -13,9 +13,23 @@ import (
|
||||
)
|
||||
|
||||
const radarrCalendarCachePrefix = "radarr:calendar:v3:"
|
||||
const radarrScheduleDays = 5
|
||||
|
||||
// radarrScheduleDays is a month where the Sonarr schedule row's is a week, because films
|
||||
// and episodes arrive at quite different rates. A household's Sonarr calendar fills a week
|
||||
// several times over; its Radarr calendar, measured against the real catalogue, yields
|
||||
// about one title a fortnight — at five days the row was empty or held a single card most
|
||||
// of the time, which reads as a broken shelf rather than a quiet month.
|
||||
const radarrScheduleDays = 30
|
||||
|
||||
// radarrTheatricalDelayDays is the median cinema-to-digital gap for recent releases, used
|
||||
// only to estimate a digital date Radarr has not published. It shares a figure with
|
||||
// radarrScheduleDays by coincidence, not by meaning — they are free to move apart.
|
||||
const radarrTheatricalDelayDays = 30
|
||||
|
||||
// radarrWeekdayLabelDays is how far out a bare weekday still names an unambiguous day.
|
||||
// Beyond it the label carries a date, or a release five weeks away reads as this Friday.
|
||||
const radarrWeekdayLabelDays = 6
|
||||
|
||||
type radarrRelease struct {
|
||||
at time.Time
|
||||
estimated bool
|
||||
@@ -185,7 +199,7 @@ func toRadarrScheduleItem(movie radarr.Movie, release radarrRelease, now time.Ti
|
||||
}
|
||||
localRelease := release.at.In(location)
|
||||
item.MembyAirsAt = localRelease.Format(time.RFC3339)
|
||||
item.MembyAirDayLabel = scheduleAirDayLabel(localRelease, now, location)
|
||||
item.MembyAirDayLabel = radarrReleaseDayLabel(localRelease, now, location)
|
||||
item.MembyAirLabel = digitalReleaseLabel(localRelease, now, location, release.estimated)
|
||||
switch {
|
||||
case movie.HasFile:
|
||||
@@ -205,11 +219,27 @@ func toRadarrScheduleItem(movie radarr.Movie, release radarrRelease, now time.Ti
|
||||
return item
|
||||
}
|
||||
|
||||
// radarrReleaseDayLabel is the card's own day chip. It is Radarr's rather than
|
||||
// scheduleAirDayLabel because that one answers for a seven-day Sonarr window, where every
|
||||
// date it can be handed is inside the coming week and a weekday is never ambiguous.
|
||||
func radarrReleaseDayLabel(release, now time.Time, location *time.Location) string {
|
||||
today := localDayStart(now.In(location), location)
|
||||
releaseDay := localDayStart(release.In(location), location)
|
||||
switch {
|
||||
case releaseDay.Equal(today):
|
||||
return "Today"
|
||||
case releaseDay.Equal(today.AddDate(0, 0, 1)):
|
||||
return "Tomorrow"
|
||||
case releaseDay.Before(today.AddDate(0, 0, radarrWeekdayLabelDays+1)):
|
||||
return releaseDay.Format("Monday")
|
||||
default:
|
||||
return releaseDay.Format("2 Jan")
|
||||
}
|
||||
}
|
||||
|
||||
func digitalReleaseLabel(release, now time.Time, location *time.Location, estimated bool) string {
|
||||
release = release.In(location)
|
||||
now = now.In(location)
|
||||
today := localDayStart(now, location)
|
||||
releaseDay := localDayStart(release, location)
|
||||
today := localDayStart(now.In(location), location)
|
||||
releaseDay := localDayStart(release.In(location), location)
|
||||
prefix := "Digital release "
|
||||
if estimated {
|
||||
prefix = "Estimated digital release "
|
||||
@@ -219,8 +249,10 @@ func digitalReleaseLabel(release, now time.Time, location *time.Location, estima
|
||||
return prefix + "today"
|
||||
case releaseDay.Equal(today.AddDate(0, 0, 1)):
|
||||
return prefix + "tomorrow"
|
||||
case releaseDay.Before(today.AddDate(0, 0, radarrWeekdayLabelDays+1)):
|
||||
return prefix + releaseDay.Format("Monday")
|
||||
default:
|
||||
return prefix + release.Format("Monday")
|
||||
return prefix + releaseDay.Format("2 January")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user