Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add duration for vrphub scraper #1934

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/scrape/vrphub.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path"
"regexp"
"strings"
"strconv"

"github.com/gocolly/colly/v2"
"github.com/nleeper/goment"
Expand Down Expand Up @@ -132,6 +133,16 @@ func VRPHub(wg *models.ScrapeWG, updateSite bool, knownScenes []string, out chan

// Duration
sc.Duration = 0
reDuration := regexp.MustCompile(`^WATCH FULL VIDEO ([0-9]+:*[0-9]*) MIN$`)
e.ForEach(`a.maxbutton-get-the-full-video-now`, func(id int, e *colly.HTMLElement) {
tmpDuration := reDuration.FindStringSubmatch(e.Text)
if tmpDuration != nil {
intDuration, err := strconv.Atoi(strings.Split(tmpDuration[1], ":")[0])
if err == nil {
sc.Duration = intDuration
}
}
})

// There are 2 places we can find filenames from - one is in the video
// previews, and one is in the trailer download section. Some posts
Expand Down
Loading