mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add JSON scrape support (#717)
* Add support for scene fragment scrape in xpath
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -18,10 +19,25 @@ import (
|
||||
"github.com/chromedp/chromedp"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"golang.org/x/net/html/charset"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
)
|
||||
|
||||
// Timeout for the scrape http request. Includes transfer time. May want to make this
|
||||
// configurable at some point.
|
||||
const scrapeGetTimeout = time.Second * 30
|
||||
|
||||
func constructSceneURL(url string, scene *models.Scene) string {
|
||||
// support checksum, title and filename
|
||||
ret := strings.Replace(url, "{checksum}", scene.Checksum.String, -1)
|
||||
ret = strings.Replace(url, "{oshash}", scene.OSHash.String, -1)
|
||||
ret = strings.Replace(ret, "{filename}", filepath.Base(scene.Path), -1)
|
||||
ret = strings.Replace(ret, "{title}", scene.Title.String, -1)
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func loadURL(url string, scraperConfig config, globalConfig GlobalConfig) (io.Reader, error) {
|
||||
driverOptions := scraperConfig.DriverOptions
|
||||
if driverOptions != nil && driverOptions.UseCDP {
|
||||
|
||||
Reference in New Issue
Block a user