From fad56ab27a5e07ca98e74ba8f9c7a9957fd23035 Mon Sep 17 00:00:00 2001 From: toshski <104477758+toshski@users.noreply.github.com> Date: Thu, 25 Jan 2024 04:46:42 +1300 Subject: [PATCH] scraper: Add MembersUrl link for Tmwvrnet Scenes (#1595) * Set up members url for tmwvrnet * Make member domain configurable * go fmt * go fmt --------- Co-authored-by: crwxaj <52156245+crwxaj@users.noreply.github.com> --- pkg/config/config.go | 5 +++++ pkg/migrations/migrations.go | 12 ++++++++++++ pkg/scrape/tmwvrnet.go | 3 +++ 3 files changed, 20 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 257024a4f..3b8bfa2ea 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -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 ( diff --git a/pkg/migrations/migrations.go b/pkg/migrations/migrations.go index 035fbed79..e4cb59b69 100644 --- a/pkg/migrations/migrations.go +++ b/pkg/migrations/migrations.go @@ -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 { diff --git a/pkg/scrape/tmwvrnet.go b/pkg/scrape/tmwvrnet.go index c5a083400..17f826d59 100644 --- a/pkg/scrape/tmwvrnet.go +++ b/pkg/scrape/tmwvrnet.go @@ -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" ) @@ -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) {