diff --git a/pkg/config/scraper_list.go b/pkg/config/scraper_list.go index 29296522d..9bfc6a2cf 100644 --- a/pkg/config/scraper_list.go +++ b/pkg/config/scraper_list.go @@ -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 +} diff --git a/pkg/config/scrapers.json b/pkg/config/scrapers.json index 299dafce6..d7f34df48 100644 --- a/pkg/config/scrapers.json +++ b/pkg/config/scrapers.json @@ -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", @@ -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", @@ -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": [] } } diff --git a/pkg/migrations/migrations.go b/pkg/migrations/migrations.go index c2b0ce823..639d4424a 100644 --- a/pkg/migrations/migrations.go +++ b/pkg/migrations/migrations.go @@ -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 { diff --git a/pkg/scrape/vrphub.go b/pkg/scrape/vrphub.go index e461fbb7e..b140f04cf 100644 --- a/pkg/scrape/vrphub.go +++ b/pkg/scrape/vrphub.go @@ -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)