From 43b86af0949a7a9210741b9fae0f414c39ee72e8 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Sun, 30 Jun 2019 15:28:44 +0300 Subject: fix loops so that waiting actually works --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 140e452..c0cc9a0 100644 --- a/main.go +++ b/main.go @@ -81,11 +81,12 @@ func main() { re := regexp.MustCompile(`<(.+?)?>`) feed.Description = string(re.ReplaceAll(programAbout, []byte(``))) + badFeed := false + for _, episode := range episodes { if len(episodeUrlRe.FindAllSubmatch(episode, -1)) > 1 { - log.Println("Page looks strange. Episode in progress? Will wait for 15 minutes and try again...") - time.Sleep(15 * 60 * time.Second) - continue + badFeed = true + break } episodeUrl := "http://www.radiorus.ru/brand/" + string(episodeUrlRe.FindSubmatch(episode)[1]) episodeTitle := string(episodeTitleRe.FindSubmatch(episode)[1]) @@ -118,6 +119,11 @@ func main() { }) } + if badFeed { + log.Println("Page looks strange. Episode in progress? Will wait for 15 minutes and try again...") + time.Sleep(15 * 60 * time.Second) + continue + } rss, err := feed.ToRss() if err != nil { log.Fatal(err) -- cgit v1.2.3