0.1.38 gateway

This commit is contained in:
ponzischeme89
2026-08-14 09:40:03 +12:00
parent abc392d30b
commit 5e2ed3d12e
2847 changed files with 1072928 additions and 3783 deletions
+44 -4
View File
@@ -32,10 +32,24 @@ const MDBListSettingsKey = "mdblist_settings"
// HeroPolicy stores only Emby ids and the optional prime-card copy. Names and artwork
// remain library data, so a metadata correction appears without rewriting operator policy.
type HeroPolicy struct {
PinnedItemIDs []string `json:"pinnedItemIds"`
LegacyPinnedMovieIDs []string `json:"pinnedMovieIds,omitempty"`
PrimeSubtitle string `json:"primeSubtitle"`
UpdatedAt time.Time `json:"updatedAt"`
PinnedItemIDs []string `json:"pinnedItemIds"`
LegacyPinnedMovieIDs []string `json:"pinnedMovieIds,omitempty"`
PrimeSubtitle string `json:"primeSubtitle"`
UpdatedAt time.Time `json:"updatedAt"`
Schedules []HeroSchedule `json:"schedules"`
}
// HeroSchedule is resolved by the gateway for every home response. Times are UTC RFC3339;
// weekdays use the local calendar day (Sunday=0) and an empty list means every day.
type HeroSchedule struct {
ID string `json:"id"`
ItemID string `json:"itemId"`
StartAt time.Time `json:"startAt"`
EndAt time.Time `json:"endAt"`
Weekdays []int `json:"weekdays,omitempty"`
Priority int `json:"priority"`
UserID string `json:"userId,omitempty"`
Enabled bool `json:"enabled"`
}
func normalizeHeroPolicy(policy HeroPolicy) HeroPolicy {
@@ -59,6 +73,32 @@ func normalizeHeroPolicy(policy HeroPolicy) HeroPolicy {
if len(runes) > 160 {
policy.PrimeSubtitle = string(runes[:160])
}
cleanSchedules := make([]HeroSchedule, 0, len(policy.Schedules))
seenSchedules := map[string]bool{}
for _, schedule := range policy.Schedules {
schedule.ID, schedule.ItemID, schedule.UserID = strings.TrimSpace(schedule.ID), strings.TrimSpace(schedule.ItemID), strings.TrimSpace(schedule.UserID)
if schedule.ID == "" || schedule.ItemID == "" || seenSchedules[schedule.ID] || !schedule.EndAt.After(schedule.StartAt) {
continue
}
seenSchedules[schedule.ID] = true
if schedule.Priority < -1000 {
schedule.Priority = -1000
}
if schedule.Priority > 1000 {
schedule.Priority = 1000
}
weekdays := make([]int, 0, len(schedule.Weekdays))
seenDays := map[int]bool{}
for _, day := range schedule.Weekdays {
if day >= 0 && day <= 6 && !seenDays[day] {
seenDays[day] = true
weekdays = append(weekdays, day)
}
}
schedule.Weekdays = weekdays
cleanSchedules = append(cleanSchedules, schedule)
}
policy.Schedules = cleanSchedules
return policy
}