Skip to content

Commit

Permalink
Improvments
Browse files Browse the repository at this point in the history
Migrates any MasterSiteIds to its new custom id.
  • Loading branch information
pops64 committed Nov 29, 2024
1 parent d46bdf4 commit 0ad961c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/config/scraper_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ func MigrateFromOfficalToCustom(id string, url string, name string, company stri
if len(scenes) != 0 {
common.Log.Infoln(name + ` Scenes found migration needed`)

tmp := strings.TrimRight(url, "/")
newId := strings.ToLower(tmp[strings.LastIndex(tmp, "/")+1:]) + `-` + customId
// Update scene data to reflect change
for _, scene := range scenes {
//Needed due to weried VRPHub scrapers
scene.ScraperId = strings.TrimPrefix(id, "vrphub-"+`-`+customId)
scene.ScraperId = newId
scene.Site = name + " " + suffix
scene.NeedsUpdate = true

Expand All @@ -188,17 +190,32 @@ func MigrateFromOfficalToCustom(id string, url string, name string, company stri

// Data taken from offical SLR scraper, updated to fix url change
scraper := ScraperConfig{URL: url, Name: name, Company: company, AvatarUrl: avatarUrl}

// Needed in case the site we are updating was a master site for others
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)

// Add the to the SLR list the new custom PS-Porn site
switch customId {
case "slr":
case "slr":
scraperConfig.CustomScrapers.SlrScrapers = append(scraperConfig.CustomScrapers.SlrScrapers, scraper)
case "povr":
case "povr":
scraperConfig.CustomScrapers.PovrScrapers = append(scraperConfig.CustomScrapers.PovrScrapers, scraper)
case "vrporn":
scraperConfig.CustomScrapers.VrpornScrapers = append(scraperConfig.CustomScrapers.VrpornScrapers, scraper)
case "vrphub":
scraperConfig.CustomScrapers.VrphubScrapers = append(scraperConfig.CustomScrapers.VrphubScrapers, scraper)
}

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

0 comments on commit 0ad961c

Please sign in to comment.