mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Support setting scrapers path in UI (#2124)
* Support setting scrapers path in UI * Refresh scrapers when scrapers path changes
This commit is contained in:
@@ -7,6 +7,7 @@ fragment ConfigGeneralData on ConfigGeneralResult {
|
|||||||
databasePath
|
databasePath
|
||||||
generatedPath
|
generatedPath
|
||||||
metadataPath
|
metadataPath
|
||||||
|
scrapersPath
|
||||||
cachePath
|
cachePath
|
||||||
calculateMD5
|
calculateMD5
|
||||||
videoFileNamingAlgorithm
|
videoFileNamingAlgorithm
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ input ConfigGeneralInput {
|
|||||||
generatedPath: String
|
generatedPath: String
|
||||||
"""Path to import/export files"""
|
"""Path to import/export files"""
|
||||||
metadataPath: String
|
metadataPath: String
|
||||||
|
"""Path to scrapers"""
|
||||||
|
scrapersPath: String
|
||||||
"""Path to cache"""
|
"""Path to cache"""
|
||||||
cachePath: String
|
cachePath: String
|
||||||
"""Whether to calculate MD5 checksums for scene video files"""
|
"""Whether to calculate MD5 checksums for scene video files"""
|
||||||
|
|||||||
@@ -57,6 +57,20 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateDir := func(key string, value string, optional bool) error {
|
||||||
|
if err := checkConfigOverride(config.Metadata); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !optional || value != "" {
|
||||||
|
if err := utils.EnsureDir(value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
existingDBPath := c.GetDatabasePath()
|
existingDBPath := c.GetDatabasePath()
|
||||||
if input.DatabasePath != nil && existingDBPath != *input.DatabasePath {
|
if input.DatabasePath != nil && existingDBPath != *input.DatabasePath {
|
||||||
if err := checkConfigOverride(config.Database); err != nil {
|
if err := checkConfigOverride(config.Database); err != nil {
|
||||||
@@ -72,41 +86,39 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co
|
|||||||
|
|
||||||
existingGeneratedPath := c.GetGeneratedPath()
|
existingGeneratedPath := c.GetGeneratedPath()
|
||||||
if input.GeneratedPath != nil && existingGeneratedPath != *input.GeneratedPath {
|
if input.GeneratedPath != nil && existingGeneratedPath != *input.GeneratedPath {
|
||||||
if err := checkConfigOverride(config.Generated); err != nil {
|
if err := validateDir(config.Generated, *input.GeneratedPath, false); err != nil {
|
||||||
return makeConfigGeneralResult(), err
|
return makeConfigGeneralResult(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.EnsureDir(*input.GeneratedPath); err != nil {
|
c.Set(config.Generated, input.GeneratedPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshScraperCache := false
|
||||||
|
existingScrapersPath := c.GetScrapersPath()
|
||||||
|
if input.ScrapersPath != nil && existingScrapersPath != *input.ScrapersPath {
|
||||||
|
if err := validateDir(config.ScrapersPath, *input.ScrapersPath, false); err != nil {
|
||||||
return makeConfigGeneralResult(), err
|
return makeConfigGeneralResult(), err
|
||||||
}
|
}
|
||||||
c.Set(config.Generated, input.GeneratedPath)
|
|
||||||
|
refreshScraperCache = true
|
||||||
|
c.Set(config.ScrapersPath, input.ScrapersPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
existingMetadataPath := c.GetMetadataPath()
|
existingMetadataPath := c.GetMetadataPath()
|
||||||
if input.MetadataPath != nil && existingMetadataPath != *input.MetadataPath {
|
if input.MetadataPath != nil && existingMetadataPath != *input.MetadataPath {
|
||||||
if err := checkConfigOverride(config.Metadata); err != nil {
|
if err := validateDir(config.Metadata, *input.MetadataPath, true); err != nil {
|
||||||
return makeConfigGeneralResult(), err
|
return makeConfigGeneralResult(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
if *input.MetadataPath != "" {
|
|
||||||
if err := utils.EnsureDir(*input.MetadataPath); err != nil {
|
|
||||||
return makeConfigGeneralResult(), err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.Set(config.Metadata, input.MetadataPath)
|
c.Set(config.Metadata, input.MetadataPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
existingCachePath := c.GetCachePath()
|
existingCachePath := c.GetCachePath()
|
||||||
if input.CachePath != nil && existingCachePath != *input.CachePath {
|
if input.CachePath != nil && existingCachePath != *input.CachePath {
|
||||||
if err := checkConfigOverride(config.Metadata); err != nil {
|
if err := validateDir(config.Cache, *input.CachePath, true); err != nil {
|
||||||
return makeConfigGeneralResult(), err
|
return makeConfigGeneralResult(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
if *input.CachePath != "" {
|
|
||||||
if err := utils.EnsureDir(*input.CachePath); err != nil {
|
|
||||||
return makeConfigGeneralResult(), err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.Set(config.Cache, input.CachePath)
|
c.Set(config.Cache, input.CachePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +247,6 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co
|
|||||||
initialiseCustomImages()
|
initialiseCustomImages()
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshScraperCache := false
|
|
||||||
if input.ScraperUserAgent != nil {
|
if input.ScraperUserAgent != nil {
|
||||||
c.Set(config.ScraperUserAgent, input.ScraperUserAgent)
|
c.Set(config.ScraperUserAgent, input.ScraperUserAgent)
|
||||||
refreshScraperCache = true
|
refreshScraperCache = true
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* Added forward jump 10 second button to video player. ([#1973](https://github.com/stashapp/stash/pull/1973))
|
* Added forward jump 10 second button to video player. ([#1973](https://github.com/stashapp/stash/pull/1973))
|
||||||
|
|
||||||
### 🎨 Improvements
|
### 🎨 Improvements
|
||||||
|
* Added support for setting scrapers path in the settings page. ([#2124](https://github.com/stashapp/stash/pull/2124))
|
||||||
* Added keyboard shortcuts to hide scene page sidebar and scene scrubber. ([#2099](https://github.com/stashapp/stash/pull/2099))
|
* Added keyboard shortcuts to hide scene page sidebar and scene scrubber. ([#2099](https://github.com/stashapp/stash/pull/2099))
|
||||||
* Overhauled, restructured and added auto-save to the settings pages. ([#2086](https://github.com/stashapp/stash/pull/2086))
|
* Overhauled, restructured and added auto-save to the settings pages. ([#2086](https://github.com/stashapp/stash/pull/2086))
|
||||||
* Include path and hashes in destroy scene/image/gallery post hook input. ([#2102](https://github.com/stashapp/stash/pull/2102/files))
|
* Include path and hashes in destroy scene/image/gallery post hook input. ([#2102](https://github.com/stashapp/stash/pull/2102/files))
|
||||||
|
|||||||
@@ -116,6 +116,14 @@ export const SettingsConfigurationPanel: React.FC = () => {
|
|||||||
onChange={(v) => saveGeneral({ generatedPath: v })}
|
onChange={(v) => saveGeneral({ generatedPath: v })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<StringSetting
|
||||||
|
id="scrapers-path"
|
||||||
|
headingID="config.general.scrapers_path.heading"
|
||||||
|
subHeadingID="config.general.scrapers_path.description"
|
||||||
|
value={general.scrapersPath ?? undefined}
|
||||||
|
onChange={(v) => saveGeneral({ scrapersPath: v })}
|
||||||
|
/>
|
||||||
|
|
||||||
<StringSetting
|
<StringSetting
|
||||||
id="metadata-path"
|
id="metadata-path"
|
||||||
headingID="config.general.metadata_path.heading"
|
headingID="config.general.metadata_path.heading"
|
||||||
|
|||||||
@@ -267,6 +267,10 @@
|
|||||||
"preview_generation": "Preview Generation",
|
"preview_generation": "Preview Generation",
|
||||||
"scraper_user_agent": "Scraper User Agent",
|
"scraper_user_agent": "Scraper User Agent",
|
||||||
"scraper_user_agent_desc": "User-Agent string used during scrape http requests",
|
"scraper_user_agent_desc": "User-Agent string used during scrape http requests",
|
||||||
|
"scrapers_path": {
|
||||||
|
"description": "Directory location of scraper configuration files",
|
||||||
|
"heading": "Scrapers Path"
|
||||||
|
},
|
||||||
"scraping": "Scraping",
|
"scraping": "Scraping",
|
||||||
"sqlite_location": "File location for the SQLite database (requires restart)",
|
"sqlite_location": "File location for the SQLite database (requires restart)",
|
||||||
"video_ext_desc": "Comma-delimited list of file extensions that will be identified as videos.",
|
"video_ext_desc": "Comma-delimited list of file extensions that will be identified as videos.",
|
||||||
|
|||||||
Reference in New Issue
Block a user