From e36e375caec13f78ae50bcb8119b19768599d3b9 Mon Sep 17 00:00:00 2001 From: pops64 Date: Wed, 28 Aug 2024 05:19:26 -0400 Subject: [PATCH] scraper: Fix for SLR Scraper Error Fixes #1779 & #1815 (#1820) * Fix for SLR Scraper Error The Head request to check to ensure the image link was good didn't handle error. I have now added a switch that if it error out because of E.G DNS Resolution error it doesn't crash XBVR. Needs more testing has the conditions to cause the error are difficult to reproduce * Format * Delete slrstudios.go Woops * Format placed in the correct dir --- pkg/scrape/slrstudios.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/scrape/slrstudios.go b/pkg/scrape/slrstudios.go index 4eb488502..b21e7c252 100644 --- a/pkg/scrape/slrstudios.go +++ b/pkg/scrape/slrstudios.go @@ -151,21 +151,25 @@ func SexLikeReal(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out if !isTransScene { appCover := gjson.Get(JsonMetadataA, "thumbnailUrl").String() desktopCover := strings.Replace(gjson.Get(JsonMetadataA, "thumbnailUrl").String(), "app", "desktop", -1) - desktopCresp, _ := http.Head(desktopCover) - if desktopCresp.StatusCode == 200 { + desktopCresp, err := http.Head(desktopCover) + if err != nil { + log.Errorf("Method Head Failed on desktopCover %s with error %s", desktopCover, err) + } else if desktopCresp.StatusCode == 200 { coverURL := desktopCover sc.Covers = append(sc.Covers, coverURL) } else { - appCresp, _ := http.Head(appCover) - if appCresp.StatusCode == 200 { + appCresp, err := http.Head(appCover) + if err != nil { + log.Errorf("Method Head Failed on appCover %s with error %s", appCover, err) + } else if appCresp.StatusCode == 200 { coverURL := appCover sc.Covers = append(sc.Covers, coverURL) - defer appCresp.Body.Close() } else { e.ForEach(`link[as="image"]`, func(id int, e *colly.HTMLElement) { sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("href"))) }) } + defer appCresp.Body.Close() } defer desktopCresp.Body.Close() } else {