Skip to content

Commit

Permalink
scraper: Add MembersUrl link for Tmwvrnet Scenes (xbapps#1595)
Browse files Browse the repository at this point in the history
* Set up members url for tmwvrnet

* Make member domain configurable

* go fmt

* go fmt

---------

Co-authored-by: crwxaj <52156245+crwxaj@users.noreply.github.com>
  • Loading branch information
toshski and crwxaj authored Jan 24, 2024
1 parent b80afdb commit fad56ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ type ObjectConfig struct {
Storage struct {
MatchOhash bool `default:"false" json:"match_ohash"`
} `json:"storage"`
ScraperSettings struct {
TMWVRNet struct {
TmwMembersDomain string `default:"members.tmwvrnet.com" json:"tmwMembersDomain"`
} `json:"tmwvrnet"`
} `json:"scraper_settings"`
}

var (
Expand Down
12 changes: 12 additions & 0 deletions pkg/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,18 @@ func Migrate() {
return nil
},
},
{
ID: "0075-Update-tmwvrnet-members",
Migrate: func(tx *gorm.DB) error {
sql := `update scenes set member_url = replace(replace(scene_url, 'https://tmwvrnet.com/trailers/', 'https://members.tmwvrnet.com/scenes/'), '.html', '_vids.html') where scene_url like 'https://tmwvrnet.com/trailers/%';`
err := tx.Exec(sql).Error
if err == nil {

err = tx.Exec(sql).Error
}
return err
},
},
})

if err := m.Migrate(); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/scrape/tmwvrnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/mozillazg/go-slugify"
"github.com/nleeper/goment"
"github.com/thoas/go-funk"
"github.com/xbapps/xbvr/pkg/config"
"github.com/xbapps/xbvr/pkg/models"
)

Expand All @@ -30,6 +31,8 @@ func TmwVRnet(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out cha
sc.Studio = "TeenMegaWorld"
sc.Site = siteID
sc.HomepageURL = strings.Split(e.Request.URL.String(), "?")[0]
sc.MembersUrl = strings.Replace(sc.HomepageURL, "https://tmwvrnet.com/trailers/", "https://"+config.Config.ScraperSettings.TMWVRNet.TmwMembersDomain+"/scenes/", 1)
sc.MembersUrl = strings.Replace(sc.MembersUrl, ".html", "_vids.html", 1)

// Date & Duration
e.ForEach(`.video-info-data`, func(id int, e *colly.HTMLElement) {
Expand Down

0 comments on commit fad56ab

Please sign in to comment.