Skip to content

Commit

Permalink
Add VRTeenrs scraper (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrebey authored and cld9x committed Nov 24, 2019
1 parent f1b5a3f commit 2d854c6
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions pkg/scrape/vrteenrs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package scrape

import (
"regexp"
"strconv"
"strings"
"sync"

"github.com/gocolly/colly"
"github.com/mozillazg/go-slugify"
"github.com/xbapps/xbvr/pkg/models"
)

func VRTeenrs(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out chan<- models.ScrapedScene) error {
defer wg.Done()
scraperID := "vrteenrs"
siteID := "VRTeenrs"
logScrapeStart(scraperID, siteID)

sceneCollector := colly.NewCollector(
colly.AllowedDomains("vrteenrs.com", "www.vrteenrs.com"),
colly.CacheDir(sceneCacheDir),
colly.UserAgent(userAgent),
)

sceneCollector.OnRequest(func(r *colly.Request) {
log.Println("visiting", r.URL.String())
})

sceneCollector.OnHTML(`.list_item`, func(e *colly.HTMLElement) {
sc := models.ScrapedScene{}
sc.SceneType = "VR"
sc.Studio = "International Media Company BV"
sc.Site = siteID
sc.HomepageURL = strings.Split(e.Request.URL.String(), "?")[0]

sc.Title = e.ChildText(".title")
coverURL := strings.TrimPrefix(e.ChildAttr("video", "poster"), "/")
if coverURL == "" {
coverURL = e.ChildAttr(".thumb img", "src")
}
if coverURL != "" {
sc.Covers = append(sc.Covers, coverURL)

// Scene ID - get from cover image URL
re := regexp.MustCompile(`(?m)vrporn(\d+)`)
log.Infof("Getting site id from: %s", coverURL)
sc.SiteID = re.FindStringSubmatch(coverURL)[1]
sc.SceneID = slugify.Slugify(sc.Site) + "-" + sc.SiteID
}

sc.Synopsis = e.ChildText(`.info .description`)

e.ForEach(`.info .subtext`, func(id int, e *colly.HTMLElement) {
tmp := strings.Split(e.Text, "Runtime: ")
if len(tmp) > 1 {
tmpDuration, err := strconv.Atoi(strings.Split(tmp[1], ":")[0])
if err == nil {
sc.Duration = tmpDuration
}
}
})

if sc.Title != "" {
out <- sc
}
})

sceneCollector.Visit("https://www.vrteenrs.com/vrporn.php")

if updateSite {
updateSiteLastUpdate(scraperID)
}
logScrapeFinished(scraperID, siteID)
return nil
}

func init() {
registerScraper("vrteenrs", "VRTeenrs", "https://mcdn.vrporn.com/files/20170702081351/vrteenrs-icon-vr-porn-studio-vrporn.com-virtual-reality.png", VRTeenrs)
}

0 comments on commit 2d854c6

Please sign in to comment.