diff --git a/internal/mediaproxy/rewriter.go b/internal/mediaproxy/rewriter.go index bb5c2b78..39da1e8b 100644 --- a/internal/mediaproxy/rewriter.go +++ b/internal/mediaproxy/rewriter.go @@ -87,7 +87,7 @@ func genericProxyRewriter(router *mux.Router, proxifyFunction urlProxyRewriter, } } - output, err := doc.Find("body").First().Html() + output, err := doc.FindMatcher(goquery.Single("body")).Html() if err != nil { return htmlDocument } diff --git a/internal/reader/processor/nebula.go b/internal/reader/processor/nebula.go index cf8a70c0..216e9b34 100644 --- a/internal/reader/processor/nebula.go +++ b/internal/reader/processor/nebula.go @@ -48,7 +48,7 @@ func fetchNebulaWatchTime(websiteURL string) (int, error) { return 0, docErr } - durs, exists := doc.Find(`meta[property="video:duration"]`).First().Attr("content") + durs, exists := doc.FindMatcher(goquery.Single(`meta[property="video:duration"]`)).Attr("content") // durs contains video watch time in seconds if !exists { return 0, errors.New("duration has not found") diff --git a/internal/reader/processor/odysee.go b/internal/reader/processor/odysee.go index 7a174b5a..873ae60c 100644 --- a/internal/reader/processor/odysee.go +++ b/internal/reader/processor/odysee.go @@ -48,7 +48,7 @@ func fetchOdyseeWatchTime(websiteURL string) (int, error) { return 0, docErr } - durs, exists := doc.Find(`meta[property="og:video:duration"]`).First().Attr("content") + durs, exists := doc.FindMatcher(goquery.Single(`meta[property="og:video:duration"]`)).Attr("content") // durs contains video watch time in seconds if !exists { return 0, errors.New("duration has not found") diff --git a/internal/reader/processor/youtube.go b/internal/reader/processor/youtube.go index 2d41e11f..68e72ba6 100644 --- a/internal/reader/processor/youtube.go +++ b/internal/reader/processor/youtube.go @@ -60,7 +60,7 @@ func fetchYouTubeWatchTimeFromWebsite(websiteURL string) (int, error) { return 0, docErr } - durs, exists := doc.Find(`meta[itemprop="duration"]`).First().Attr("content") + durs, exists := doc.FindMatcher(goquery.Single(`meta[itemprop="duration"]`)).Attr("content") if !exists { return 0, errors.New("duration has not found") } diff --git a/internal/reader/readability/readability.go b/internal/reader/readability/readability.go index 193edf07..299211f5 100644 --- a/internal/reader/readability/readability.go +++ b/internal/reader/readability/readability.go @@ -77,7 +77,7 @@ func ExtractContent(page io.Reader) (baseURL string, extractedContent string, er return "", "", err } - if hrefValue, exists := document.Find("head base").First().Attr("href"); exists { + if hrefValue, exists := document.FindMatcher(goquery.Single("head base")).Attr("href"); exists { hrefValue = strings.TrimSpace(hrefValue) if urllib.IsAbsoluteURL(hrefValue) { baseURL = hrefValue diff --git a/internal/reader/rewrite/rewrite_functions.go b/internal/reader/rewrite/rewrite_functions.go index 78590031..2125f8f0 100644 --- a/internal/reader/rewrite/rewrite_functions.go +++ b/internal/reader/rewrite/rewrite_functions.go @@ -44,7 +44,7 @@ func addImageTitle(entryURL, entryContent string) string { img.ReplaceWithHtml(`
` + altAttr + `

` + html.EscapeString(titleAttr) + `

`) }) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -76,7 +76,7 @@ func addMailtoSubject(entryURL, entryContent string) string { a.AppendHtml(" [" + html.EscapeString(subject) + "]") }) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -160,7 +160,7 @@ func addDynamicImage(entryURL, entryContent string) string { } if changed { - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -197,7 +197,7 @@ func addDynamicIframe(entryURL, entryContent string) string { }) if changed { - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -217,7 +217,7 @@ func fixMediumImages(entryURL, entryContent string) string { } }) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -239,7 +239,7 @@ func useNoScriptImages(entryURL, entryContent string) string { } }) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -317,7 +317,7 @@ func removeCustom(entryContent string, selector string) string { doc.Find(selector).Remove() - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -344,7 +344,7 @@ func applyFuncOnTextContent(entryContent string, selector string, repl func(stri doc.Find(selector).Each(treatChildren) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -401,7 +401,7 @@ func addHackerNewsLinksUsing(entryContent, app string) string { } }) - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } @@ -420,7 +420,7 @@ func removeTables(entryContent string) string { for _, selector := range selectors { for { - loopElement = doc.Find(selector).First() + loopElement = doc.FindMatcher(goquery.Single(selector)) if loopElement.Length() == 0 { break @@ -436,6 +436,6 @@ func removeTables(entryContent string) string { } } - output, _ := doc.Find("body").First().Html() + output, _ := doc.FindMatcher(goquery.Single("body")).Html() return output } diff --git a/internal/reader/scraper/scraper.go b/internal/reader/scraper/scraper.go index a200a587..de8e3afc 100644 --- a/internal/reader/scraper/scraper.go +++ b/internal/reader/scraper/scraper.go @@ -75,7 +75,7 @@ func findContentUsingCustomRules(page io.Reader, rules string) (baseURL string, return "", "", err } - if hrefValue, exists := document.Find("head base").First().Attr("href"); exists { + if hrefValue, exists := document.FindMatcher(goquery.Single("head base")).Attr("href"); exists { hrefValue = strings.TrimSpace(hrefValue) if urllib.IsAbsoluteURL(hrefValue) { baseURL = hrefValue diff --git a/internal/reader/subscription/finder.go b/internal/reader/subscription/finder.go index 514b7ffc..ebebe56a 100644 --- a/internal/reader/subscription/finder.go +++ b/internal/reader/subscription/finder.go @@ -146,7 +146,7 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWebPage(websiteURL, contentTyp return nil, locale.NewLocalizedErrorWrapper(err, "error.unable_to_parse_html_document", err) } - if hrefValue, exists := doc.Find("head base").First().Attr("href"); exists { + if hrefValue, exists := doc.FindMatcher(goquery.Single("head base")).Attr("href"); exists { hrefValue = strings.TrimSpace(hrefValue) if urllib.IsAbsoluteURL(hrefValue) { websiteURL = hrefValue