From 9f253fea5ca21fdfb4fd109769fbf72b55ec090d Mon Sep 17 00:00:00 2001 From: vt-idiot <81622808+vt-idiot@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:12:42 -0400 Subject: [PATCH] scraper: Fix for missing cover 403 on low resolution SLR covers (#1721) * Update slrstudios.go Fix for scene covers FOR ANTS * Typo, UnusedVar * Update slrstudios.go gofmt... --- pkg/scrape/slrstudios.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/scrape/slrstudios.go b/pkg/scrape/slrstudios.go index 414a5f299..4eb488502 100644 --- a/pkg/scrape/slrstudios.go +++ b/pkg/scrape/slrstudios.go @@ -3,6 +3,7 @@ package scrape import ( "encoding/json" "html" + "net/http" "regexp" "strconv" "strings" @@ -148,14 +149,25 @@ func SexLikeReal(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out // Cover if !isTransScene { - coverURL := strings.Replace(gjson.Get(JsonMetadataA, "thumbnailUrl").String(), "app", "desktop", -1) - if len(coverURL) > 0 { + 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 { + coverURL := desktopCover sc.Covers = append(sc.Covers, coverURL) } else { - e.ForEach(`link[as="image"]`, func(id int, e *colly.HTMLElement) { - sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("href"))) - }) + appCresp, _ := http.Head(appCover) + 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 desktopCresp.Body.Close() } else { posterURLFound := false e.ForEach(`script[type="text/javascript"]`, func(id int, e *colly.HTMLElement) {