mirror of
https://github.com/miniflux/v2.git
synced 2025-07-02 16:38:37 +00:00
refactor: use a better construct than doc.Find(…).First()
As mentioned in goquery's documentation (https://pkg.go.dev/github.com/PuerkitoBio/goquery#Single): > By default, Selection.Find and other functions that accept a selector string to select nodes will use all matches corresponding to that selector. By using the Matcher returned by Single, at most the first match will be selected. > > The one using Single is optimized to be potentially much faster on large documents.
This commit is contained in:
parent
68448b4abb
commit
1b0b8b9c42
8 changed files with 18 additions and 18 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue