Skip to content

Commit

Permalink
scraper: Fix VRHush/VRAllure Title and Cover Image (xbapps#1237)
Browse files Browse the repository at this point in the history
* Fix VRHush Tilt and Cover Image

* Fix Trailer Source & migrate existing scenes

* Same change for vrallure
  • Loading branch information
toshski authored Apr 17, 2023
1 parent 43b5aee commit 8528af1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
8 changes: 8 additions & 0 deletions pkg/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,14 @@ func Migrate() {
return nil
},
},
{
// rebuild search indexes with new fields
ID: "0061-fix-vrhush-vrallure-trailers",
Migrate: func(tx *gorm.DB) error {
sql := `update scenes set trailer_source = replace(trailer_source, 'deo-video source', 'web-vr-video-player source') where scraper_id in ('vrhush', 'vrallure')`
return tx.Exec(sql).Error
},
},
})

if err := m.Migrate(); err != nil {
Expand Down
10 changes: 6 additions & 4 deletions pkg/scrape/vrallure.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ func VRAllure(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out cha
})

// Title / Cover
e.ForEach(`deo-video`, func(id int, e *colly.HTMLElement) {
sc.Title = strings.TrimSpace(e.Attr("title"))
sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("cover-image")))
e.ForEach(`.latest-scene-title`, func(id int, e *colly.HTMLElement) {
sc.Title = strings.TrimSpace(e.Text)
})
e.ForEach(`web-vr-video-player`, func(id int, e *colly.HTMLElement) {
sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("coverimage")))
})

// Gallery
Expand Down Expand Up @@ -91,7 +93,7 @@ func VRAllure(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out cha

// trailer details
sc.TrailerType = "scrape_html"
params := models.TrailerScrape{SceneUrl: sc.HomepageURL, HtmlElement: "deo-video source", ContentPath: "src", QualityPath: "quality", ContentBaseUrl: "https:"}
params := models.TrailerScrape{SceneUrl: sc.HomepageURL, HtmlElement: "web-vr-video-player source", ContentPath: "src", QualityPath: "quality", ContentBaseUrl: "https:"}
strParams, _ := json.Marshal(params)
sc.TrailerSrc = string(strParams)

Expand Down
10 changes: 6 additions & 4 deletions pkg/scrape/vrhush.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func VRHush(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out chan<
reGetOriginal := regexp.MustCompile(`^(https?:\/\/b8h6h9v9\.ssl\.hwcdn\.net\/vrh\/)(?:largethumbs|hugethumbs|rollover_large|rollover_huge)(\/.+)-c\d{3,4}x\d{3,4}(\.\w{3,4})$`)

// Title / Cover
e.ForEach(`deo-video`, func(id int, e *colly.HTMLElement) {
sc.Title = strings.TrimSpace(e.Attr("title"))
sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("cover-image")))
e.ForEach(`.latest-scene-title`, func(id int, e *colly.HTMLElement) {
sc.Title = strings.TrimSpace(e.Text)
})
e.ForEach(`web-vr-video-player`, func(id int, e *colly.HTMLElement) {
sc.Covers = append(sc.Covers, e.Request.AbsoluteURL(e.Attr("coverimage")))
})

// Gallery
Expand Down Expand Up @@ -85,7 +87,7 @@ func VRHush(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out chan<

// trailer details
sc.TrailerType = "scrape_html"
params := models.TrailerScrape{SceneUrl: sc.HomepageURL, HtmlElement: "deo-video source", ContentPath: "src", QualityPath: "quality", ContentBaseUrl: "https:"}
params := models.TrailerScrape{SceneUrl: sc.HomepageURL, HtmlElement: "web-vr-video-player", ContentPath: "src", QualityPath: "quality", ContentBaseUrl: "https:"}
strParams, _ := json.Marshal(params)
sc.TrailerSrc = string(strParams)

Expand Down

0 comments on commit 8528af1

Please sign in to comment.