Scraper inputs (#4922)

* Pass more details in scene/gallery scrape
This commit is contained in:
WithoutPants
2024-06-11 13:12:45 +10:00
committed by GitHub
parent dcb86d9186
commit 94a978d063
4 changed files with 210 additions and 69 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"strconv"
"github.com/jinzhu/copier"
"github.com/shurcooL/graphql"
@@ -310,62 +309,3 @@ func (s *stashScraper) scrapeGalleryByGallery(ctx context.Context, gallery *mode
func (s *stashScraper) scrapeByURL(_ context.Context, _ string, _ ScrapeContentType) (ScrapedContent, error) {
return nil, ErrNotSupported
}
func sceneToUpdateInput(scene *models.Scene) models.SceneUpdateInput {
dateToStringPtr := func(s *models.Date) *string {
if s != nil {
v := s.String()
return &v
}
return nil
}
// fallback to file basename if title is empty
title := scene.GetTitle()
var url *string
urls := scene.URLs.List()
if len(urls) > 0 {
url = &urls[0]
}
return models.SceneUpdateInput{
ID: strconv.Itoa(scene.ID),
Title: &title,
Details: &scene.Details,
// include deprecated URL for now
URL: url,
Urls: urls,
Date: dateToStringPtr(scene.Date),
}
}
func galleryToUpdateInput(gallery *models.Gallery) models.GalleryUpdateInput {
dateToStringPtr := func(s *models.Date) *string {
if s != nil {
v := s.String()
return &v
}
return nil
}
// fallback to file basename if title is empty
title := gallery.GetTitle()
var url *string
urls := gallery.URLs.List()
if len(urls) > 0 {
url = &urls[0]
}
return models.GalleryUpdateInput{
ID: strconv.Itoa(gallery.ID),
Title: &title,
Details: &gallery.Details,
URL: url,
Urls: urls,
Date: dateToStringPtr(gallery.Date),
}
}