From 81e9378b9d12a498c11a1858ba6734b80a8956a3 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Thu, 30 Jul 2020 11:38:22 -0400 Subject: [PATCH] Add new fall through errors for release time --- downloader/downloader.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index 0f0293f..9a17cb4 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -62,7 +62,7 @@ GetTime: t, err := getUploadTime(config, videoID, ip) if err != nil { //slack(":warning: Upload time error: %v", err) - if tries <= maxTries && (errors.Is(err, errNotScraped) || errors.Is(err, errUploadTimeEmpty)) { + if tries <= maxTries && (errors.Is(err, errNotScraped) || errors.Is(err, errUploadTimeEmpty) || errors.Is(err, errStatusParse) || errors.Is(err, errConnectionIssue)) { err := triggerScrape(videoID, ip) if err == nil { time.Sleep(2 * time.Second) // let them scrape it @@ -99,6 +99,8 @@ GetTime: var errNotScraped = errors.Base("not yet scraped by caa.iti.gr") var errUploadTimeEmpty = errors.Base("upload time is empty") +var errStatusParse = errors.Base("could not parse status, got number, need string") +var errConnectionIssue = errors.Base("there was a connection issue with the api") func slack(format string, a ...interface{}) { fmt.Printf(format+"\n", a...) @@ -134,6 +136,12 @@ func triggerScrape(videoID string, ip *net.TCPAddr) error { } err = json.NewDecoder(res.Body).Decode(&response) if err != nil { + if strings.Contains(err.Error(), "cannot unmarshal number") { + return errors.Err(errStatusParse) + } + if strings.Contains(err.Error(), "no route to host") { + return errors.Err(errConnectionIssue) + } return errors.Err(err) }