diff --git a/pkg/migrations/migrations.go b/pkg/migrations/migrations.go index e7dc46667..dd5d2f7ca 100644 --- a/pkg/migrations/migrations.go +++ b/pkg/migrations/migrations.go @@ -798,6 +798,38 @@ func Migrate() { return nil }, }, + { + // some site, vrbangers & vrconk have blank covers, & vrbangers gallery images will not render due to double slashes ie .com// + ID: "0035-fix-vrbangers-images", + Migrate: func(tx *gorm.DB) error { + var scenes []models.Scene + err := tx.Where("studio LIKE ?", "VRBangers").Or("images LIKE ?", "%{\"url\":\"\",\"type\":\"gallery\",\"orientation\":\"\"}%").Find(&scenes).Error + if err != nil { + return err + } + + for _, scene := range scenes { + changed := false + // check for a blank cover image and remove them + if strings.Contains(scene.Images, ",{\"url\":\"\",\"type\":\"cover\",\"orientation\":\"\"}") { + scene.Images = strings.ReplaceAll(scene.Images, ",{\"url\":\"\",\"type\":\"cover\",\"orientation\":\"\"}", "") + changed = true + } + // remove double slashes from image url for VRBangers + if scene.Studio == "VRBangers" && strings.Contains(scene.Images, ".com//") { + scene.Images = strings.ReplaceAll(scene.Images, ".com//", ".com/") + changed = true + } + if changed { + err = tx.Save(&scene).Error + if err != nil { + return err + } + } + } + return nil + }, + }, }) if err := m.Migrate(); err != nil { diff --git a/pkg/models/model_scene.go b/pkg/models/model_scene.go index dd895256e..66ca4ebcb 100644 --- a/pkg/models/model_scene.go +++ b/pkg/models/model_scene.go @@ -396,17 +396,21 @@ func SceneCreateUpdateFromExternal(db *gorm.DB, ext ScrapedScene) error { var images []Image for i := range ext.Covers { - images = append(images, Image{ - URL: ext.Covers[i], - Type: "cover", - }) + if ext.Covers[i] != "" { + images = append(images, Image{ + URL: ext.Covers[i], + Type: "cover", + }) + } } for i := range ext.Gallery { - images = append(images, Image{ - URL: ext.Gallery[i], - Type: "gallery", - }) + if ext.Gallery[i] != "" { + images = append(images, Image{ + URL: ext.Gallery[i], + Type: "gallery", + }) + } } imgTxt, err := json.Marshal(images) diff --git a/pkg/scrape/vrbangers.go b/pkg/scrape/vrbangers.go index 2ef787b87..76f06d919 100755 --- a/pkg/scrape/vrbangers.go +++ b/pkg/scrape/vrbangers.go @@ -98,7 +98,7 @@ func VRBangersSite(wg *sync.WaitGroup, updateSite bool, knownScenes []string, ou // Gallery - https://content.vrbangers.com/uploads/2021/08/611b4e0ca5c54351494706_XL.jpg gallerytmp := gjson.Get(JsonMetadata, "data.item.galleryImages.#.previews.#(sizeAlias==XL).permalink") for _, v := range gallerytmp.Array() { - sc.Gallery = append(sc.Gallery, contentURL+v.Str) + sc.Gallery = append(sc.Gallery, strings.Replace(contentURL+v.Str, ".com//", ".com/", 1)) } // Synopsis