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

Fix VRHush/VRAllure Title and Cover Image #1237

Merged
merged 3 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
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
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