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 to vrphub scraper #1937

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions pkg/scrape/vrphub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"path"
"regexp"
"strconv"
"strings"

"github.com/gocolly/colly/v2"
Expand Down Expand Up @@ -100,9 +101,13 @@ func VRPHub(wg *models.ScrapeWG, updateSite bool, knownScenes []string, out chan

// Cast
sc.ActorDetails = make(map[string]models.ActorDetails)
e.ForEach(`div.td-post-header header.td-post-title span.td-post-date2 a.ftlink`, func(id int, e *colly.HTMLElement) {
sc.Cast = append(sc.Cast, e.Text)
sc.ActorDetails[e.Text] = models.ActorDetails{Source: sc.ScraperID + " scrape", ProfileUrl: e.Attr("href")}
e.ForEach(`div.td-post-header header.td-post-title span.td-post-date2`, func(id int, e *colly.HTMLElement) {
if strings.Contains(e.Text, "Featuring") {
e.ForEach(`a.ftlink`, func(id int, e *colly.HTMLElement) {
sc.Cast = append(sc.Cast, e.Text)
sc.ActorDetails[e.Text] = models.ActorDetails{Source: sc.ScraperID + " scrape", ProfileUrl: e.Attr("href")}
})
}
})

// Gallery
Expand Down Expand Up @@ -131,7 +136,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