Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit42a24eb

Browse files
authored
scraper: add TransVR (#1652)
Very similar to the current one for GroobyVR. Just adjusted the links and names to make it works for TransVR.
1 parent39975a2 commit42a24eb

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

‎pkg/scrape/transvr.go

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package scrape
2+
3+
import (
4+
"encoding/json"
5+
"regexp"
6+
"strconv"
7+
"strings"
8+
"sync"
9+
10+
"github.com/gocolly/colly/v2"
11+
"github.com/mozillazg/go-slugify"
12+
"github.com/nleeper/goment"
13+
"github.com/thoas/go-funk"
14+
"github.com/xbapps/xbvr/pkg/models"
15+
)
16+
17+
funcTransVR(wg*sync.WaitGroup,updateSitebool,knownScenes []string,outchan<- models.ScrapedScene,singleSceneURLstring,singeScrapeAdditionalInfostring,limitScrapingbool)error {
18+
deferwg.Done()
19+
scraperID:="transvr"
20+
siteID:="TransVR"
21+
allowedDomains:= []string{"transvr.com","www.transvr.com"}
22+
logScrapeStart(scraperID,siteID)
23+
24+
sceneCollector:=createCollector(allowedDomains...)
25+
siteCollector:=createCollector(allowedDomains...)
26+
vodCollector:=createCollector(allowedDomains...)
27+
28+
sceneCollector.OnHTML(`html`,func(e*colly.HTMLElement) {
29+
sc:= models.ScrapedScene{}
30+
sc.ScraperID=scraperID
31+
sc.SceneType="VR"
32+
sc.Studio="TransVR"
33+
sc.Site=siteID
34+
sc.HomepageURL=strings.Split(e.Request.URL.String(),"?")[0]
35+
36+
// Title
37+
sc.Title=strings.Replace(e.ChildText(`title`),"Trans VR: ","",-1)
38+
39+
// Cast
40+
sc.ActorDetails=make(map[string]models.ActorDetails)
41+
e.ForEach(`div.trailer_toptitle_left a`,func(idint,e*colly.HTMLElement) {
42+
sc.Cast=append(sc.Cast,strings.TrimSpace(e.Text))
43+
sc.ActorDetails[strings.TrimSpace(e.Text)]= models.ActorDetails{Source:scraperID+" scrape",ProfileUrl:e.Request.AbsoluteURL(e.Attr("href"))}
44+
})
45+
46+
// Cover URL
47+
coverURL:=e.Request.AbsoluteURL(e.ChildAttr("div.player-thumb img","src"))
48+
sc.Covers=append(sc.Covers,coverURL)
49+
50+
// Scene ID - get from URL
51+
tmps:=strings.Split(coverURL,"/")
52+
tmp:=strings.Replace(tmps[len(tmps)-1],".jpg","",-1)
53+
sc.SiteID=tmp
54+
sc.SceneID=slugify.Slugify(sc.Site)+"-"+sc.SiteID
55+
56+
// Synopsis
57+
sc.Synopsis=strings.TrimSpace(e.ChildText(`div.trailerblock p`))
58+
59+
// Date
60+
dateString:=strings.Replace(e.ChildText(`div.set_meta`),"Added ","",-1)
61+
tmpDate,_:=goment.New(dateString,"MMMM D, YYYY")
62+
sc.Released=tmpDate.Format("YYYY-MM-DD")
63+
64+
// Duration
65+
r:=regexp.MustCompile(`(?:(\d{2}):)?(\d{2}):(\d{2})`)
66+
m:=r.FindStringSubmatch(e.ChildText(`div.set_meta`))
67+
duration:=0
68+
iflen(m)==4 {
69+
hours,_:=strconv.Atoi("0"+m[1])
70+
minutes,_:=strconv.Atoi(m[2])
71+
duration=hours*60+minutes
72+
}
73+
sc.Duration=duration
74+
75+
sc.TrailerType="scrape_html"
76+
params:= models.TrailerScrape{SceneUrl:sc.HomepageURL,HtmlElement:"dl8-video source",ContentPath:"src",QualityPath:"quality",ContentBaseUrl:`https://www.transvr.com`}
77+
strParams,_:=json.Marshal(params)
78+
sc.TrailerSrc=string(strParams)
79+
80+
// Pull data from vod page - not every scene has a vod link
81+
ctx:=colly.NewContext()
82+
ctx.Put("scene",&sc)
83+
vodURL:=e.ChildAttr("a.downBtnbuy","href")
84+
if!strings.Contains(vodURL,"/tour") {
85+
vodCollector.Request("GET",vodURL,nil,ctx,nil)
86+
}
87+
88+
out<-sc
89+
})
90+
91+
vodCollector.OnHTML(`html`,func(e*colly.HTMLElement) {
92+
sc:=e.Request.Ctx.GetAny("scene").(*models.ScrapedScene)
93+
94+
// Gallery
95+
sc.Gallery=e.ChildAttrs("div.gallery-group img","data-orig-file")
96+
97+
// Tags
98+
e.ForEach(`span.meta-tag a`,func(idint,e*colly.HTMLElement) {
99+
sc.Tags=append(sc.Tags,strings.TrimSpace(e.Text))
100+
})
101+
102+
// Not every page has tags so use categories as well
103+
e.ForEach(`span.meta-cat a`,func(idint,e*colly.HTMLElement) {
104+
sc.Tags=append(sc.Tags,strings.TrimSpace(e.Text))
105+
})
106+
107+
})
108+
109+
siteCollector.OnHTML(`div.videohere a`,func(e*colly.HTMLElement) {
110+
sceneURL:=e.Request.AbsoluteURL(e.Attr("href"))
111+
112+
if!funk.ContainsString(knownScenes,sceneURL) {
113+
sceneCollector.Visit(sceneURL)
114+
}
115+
})
116+
117+
siteCollector.OnHTML(`div.pagination li a:not(.active)`,func(e*colly.HTMLElement) {
118+
if!limitScraping {
119+
pageURL:=e.Request.AbsoluteURL(e.Attr("href"))
120+
siteCollector.Visit(pageURL)
121+
}
122+
})
123+
124+
ifsingleSceneURL!="" {
125+
sceneCollector.Visit(singleSceneURL)
126+
}else {
127+
siteCollector.Visit("https://www.transvr.com/tour/categories/movies/1/latest/")
128+
}
129+
130+
ifupdateSite {
131+
updateSiteLastUpdate(scraperID)
132+
}
133+
logScrapeFinished(scraperID,siteID)
134+
returnnil
135+
}
136+
137+
funcinit() {
138+
registerScraper("transvr","TransVR","https://www.transvr.com/tour/custom_assets/favicon/apple-touch-icon.png","transvr.com",TransVR)
139+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp