Skip to content

Commit

Permalink
fix: Move multiple sites to Custom List to allow for them to be used …
Browse files Browse the repository at this point in the history
…as alternative sites (#1876)

* Draft PS-Porn migration to Custom

Due to a URL change on SLR it is needed to update the URL. Chose to migrate it to a custom scraper in addition to fix the URL. Will remove the scraper from the List if no scenes have been found for the PS-Porn scraper

* Testing

* Working ready for PR

Some final testing to due. Adds some sites that have mains available so users may set them to alts

* Go Fmt

* Clean Up

* Improvments

Migrates any MasterSiteIds to its new custom id.

* Go Fmt

* Add check for existing site

In case user create a custom site due to a URL change on the parent site. We shouldn't also create our own entry. This will check to ensure it doesn't exists and will only add if the new id isn't present

* Clean UP

* More Clean Up

* Optimization

* Go Fmt
  • Loading branch information
pops64 authored Jan 17, 2025
1 parent 8504091 commit 5d2fb4a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 30 deletions.
74 changes: 74 additions & 0 deletions pkg/config/scraper_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,77 @@ func SetSiteId(configList *[]ScraperConfig, customId string) {
}

}

func MigrateFromOfficalToCustom(id string, url string, name string, company string, avatarUrl string, customId string, suffix string) error {

db, _ := models.GetDB()
defer db.Close()

var scenes []models.Scene
db.Where("scraper_id = ?", id).Find(&scenes)

if len(scenes) != 0 {
common.Log.Infoln(name + ` Scenes found migration needed`)

// Update scene data to reflect change
db.Model(&models.Scene{}).Where("scraper_id = ?", id).Update("needs_update", true)

// Determine the new id from the URL using the same template as the scraper list code
tmp := strings.TrimRight(url, "/")
newId := strings.ToLower(tmp[strings.LastIndex(tmp, "/")+1:]) + `-` + customId

var scraperConfig ScraperList
scraperConfig.Load()

// Data taken from offical scraper list
scraper := ScraperConfig{URL: url, Name: name, Company: company, AvatarUrl: avatarUrl}

// Update any alt sites that is using the old id to the new id
updateMasterSite := func(sites []ScraperConfig) {
for idx, site := range sites {
if site.MasterSiteId == id {
sites[idx].MasterSiteId = newId
}
}
}

updateMasterSite(scraperConfig.CustomScrapers.SlrScrapers)
updateMasterSite(scraperConfig.CustomScrapers.PovrScrapers)
updateMasterSite(scraperConfig.CustomScrapers.VrpornScrapers)
updateMasterSite(scraperConfig.CustomScrapers.VrphubScrapers)

// Append our scraper to the the Custom Scraper list unless its new id already exists
switch customId {
case "slr":
if CheckMatchingSite(scraper, scraperConfig.CustomScrapers.SlrScrapers) == false {
scraperConfig.CustomScrapers.SlrScrapers = append(scraperConfig.CustomScrapers.SlrScrapers, scraper)
}
case "povr":
if CheckMatchingSite(scraper, scraperConfig.CustomScrapers.PovrScrapers) == false {
scraperConfig.CustomScrapers.PovrScrapers = append(scraperConfig.CustomScrapers.PovrScrapers, scraper)
}
case "vrporn":
if CheckMatchingSite(scraper, scraperConfig.CustomScrapers.VrpornScrapers) == false {
scraperConfig.CustomScrapers.VrpornScrapers = append(scraperConfig.CustomScrapers.VrpornScrapers, scraper)
}
case "vrphub":
if CheckMatchingSite(scraper, scraperConfig.CustomScrapers.VrphubScrapers) == false {
scraperConfig.CustomScrapers.VrphubScrapers = append(scraperConfig.CustomScrapers.VrphubScrapers, scraper)
}
}

// Save the new list file
fName := filepath.Join(common.AppDir, "scrapers.json")
list, _ := json.MarshalIndent(scraperConfig, "", " ")
os.WriteFile(fName, list, 0644)

common.Log.Infoln(name + ` migration complete. Please restart XBVR and run ` + name + ` scraper to complete migration`)

} else {

common.Log.Infoln(`No ` + name + ` Scenes found no migration needed. Removing DB entry`)

}

return db.Delete(&models.Site{ID: id}).Error
}
29 changes: 1 addition & 28 deletions pkg/config/scrapers.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@
"company": "",
"avatar_url": ""
},
{
"url": "https://www.sexlikereal.com/studios/fuckpassvr",
"name": "FuckPassVR",
"company": "FuckPassVR",
"avatar_url": "https://cdn-vr.sexlikereal.com/images/studio_creatives/logotypes/1/352/logo_crop_1635153994.png"
},
{
"url": "https://www.sexlikereal.com/studios/heathering",
"name": "Heathering",
Expand Down Expand Up @@ -319,12 +313,6 @@
"company": "POV Central",
"avatar_url": "https://mcdn.vrporn.com/files/20191125091909/POVCentralLogo.jpg"
},
{
"url": "https://www.sexlikereal.com/studios/ps-porn",
"name": "PS-Porn",
"company": "Paula Shy",
"avatar_url": "https://mcdn.vrporn.com/files/20201221090642/PS-Porn-400x400.jpg"
},
{
"url": "https://www.sexlikereal.com/studios/realhotvr",
"name": "RealHotVR",
Expand Down Expand Up @@ -502,21 +490,6 @@
"avatar_url": "https://mcdn.vrporn.com/files/20200421094123/vrclubz_logo_NEW-400x400_webwhite.png"
}
],
"vrphub": [
{
"id": "vrphub-vrhush",
"url": "https://vrphub.com/category/vr-hush",
"name": "VRHush",
"company": "VRHush",
"avatar_url": "https://cdn-nexpectation.secure.yourpornpartner.com/sites/vrh/favicon/apple-touch-icon-180x180.png"
},
{
"id": "vrphub-stripzvr",
"url": "https://vrphub.com/category/stripzvr/",
"name": "StripzVR - VRP Hub",
"company": "StripzVR",
"avatar_url": "https://www.stripzvr.com/wp-content/uploads/2018/09/cropped-favicon-192x192.jpg"
}
]
"vrphub": []
}
}
12 changes: 12 additions & 0 deletions pkg/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,18 @@ func Migrate() {
return nil
},
},
{
ID: "0081-Offical-Site-Removals-With-Main-Site-Aviable",
Migrate: func(tx *gorm.DB) error {

err := config.MigrateFromOfficalToCustom("ps-porn", "https://www.sexlikereal.com/studios/ps-porn-vr", "PS-Porn", "Paula Shy", "https://mcdn.vrporn.com/files/20201221090642/PS-Porn-400x400.jpg", "slr", "(SLR)")
err = config.MigrateFromOfficalToCustom("fuckpassvr", "https://www.sexlikereal.com/studios/fuckpassvr", "FuckPassVR", "FuckPassVR", "https://cdn-vr.sexlikereal.com/images/studio_creatives/logotypes/1/352/logo_crop_1635153994.png", "slr", "(SLR)")
err = config.MigrateFromOfficalToCustom("vrphub-vrhush", "https://vrphub.com/category/vr-hush", "VRHush", "VRHush", "https://cdn-nexpectation.secure.yourpornpartner.com/sites/vrh/favicon/apple-touch-icon-180x180.png", "vrphub", "(VRP Hub)")
err = config.MigrateFromOfficalToCustom("vrphub-stripzvr", "https://vrphub.com/category/stripzvr/", "StripzVR - VRP Hub", "StripzVR", "https://www.stripzvr.com/wp-content/uploads/2018/09/cropped-favicon-192x192.jpg", "vrphub", "(VRP Hub)")
return err

},
},
})

if err := m.Migrate(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/scrape/vrphub.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ func init() {
scrapers.Load()
for _, scraper := range scrapers.XbvrScrapers.VrphubScrapers {
switch scraper.ID {
case "vrphub-vrhush":
case "vr-hush-vrphub":
addVRPHubScraper(scraper.ID, scraper.Name, scraper.Company, scraper.AvatarUrl, false, scraper.URL, vrhushCallback)
case "vrphub-stripzvr":
case "stripzvr-vrphub":
addVRPHubScraper(scraper.ID, scraper.Name, scraper.Company, scraper.AvatarUrl, false, scraper.URL, stripzvrCallback)
}
addVRPHubScraper(scraper.ID, scraper.Name, scraper.Company, scraper.AvatarUrl, false, scraper.URL, noop)
Expand Down

0 comments on commit 5d2fb4a

Please sign in to comment.