From a228e925153b32e817e7c36fa0ac2586c57159b1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 4 Aug 2024 17:26:35 +0200 Subject: [PATCH] fix: Mostly ignore event URL mimimis Based on the LibreTime URL, if a show has an "event" URL, we consider it a valid match. --- app.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app.go b/app.go index fff3d14..243b9ee 100644 --- a/app.go +++ b/app.go @@ -7,7 +7,9 @@ import ( "io" "log" "net/http" + "regexp" "sort" + "strings" "sync/atomic" "time" ) @@ -181,11 +183,20 @@ func (a *App) checkForErrors(grid map[string]gridSlot, errors gridErrors) gridEr fmt.Sprintf("Keine URL für Sendung %s auf Website hinterlegt.", slot.WebsiteEventOrganizerCalendarEvent.Title), slot.WebsiteEventOrganizerCalendarEvent.Start, slot) - } else { + } else if slot.LibreTimeLiveInfoV2Show.URL == "" { errors = a.appendError(errors, - fmt.Sprintf("URL auf Webseite (%s) stimmt nicht mit LibreTime (%s) überein.", - slot.WebsiteEventOrganizerCalendarEvent.URL, slot.LibreTimeLiveInfoV2Show.URL), + fmt.Sprintf("URL auf Webseite (%s) fehlt in LibreTime.", + slot.WebsiteEventOrganizerCalendarEvent.URL), slot.WebsiteEventOrganizerCalendarEvent.Start, slot) + } else { + // ignore trailing `-/` from website URLs under the /events/ path for now + match, _ := regexp.MatchString("^"+strings.Replace(slot.LibreTimeLiveInfoV2Show.URL, "rabe.ch", "rabe.ch/event", 1)+"(-[0-9]+/)", slot.WebsiteEventOrganizerCalendarEvent.URL) + if !match { + errors = a.appendError(errors, + fmt.Sprintf("URL auf Webseite (%s) stimmt nicht mit LibreTime (%s) überein.", + slot.WebsiteEventOrganizerCalendarEvent.URL, slot.LibreTimeLiveInfoV2Show.URL), + slot.WebsiteEventOrganizerCalendarEvent.Start, slot) + } } }