2019-02-09 12:30:49 +00:00
|
|
|
package paths
|
|
|
|
|
|
|
|
import (
|
2020-07-07 00:35:43 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
2019-03-23 14:56:59 +00:00
|
|
|
"github.com/stashapp/stash/pkg/manager/config"
|
2020-04-24 02:52:21 +00:00
|
|
|
"github.com/stashapp/stash/pkg/utils"
|
2019-02-09 12:30:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type jsonPaths struct {
|
2020-04-24 02:52:21 +00:00
|
|
|
Metadata string
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
MappingsFile string
|
|
|
|
ScrapedFile string
|
|
|
|
|
|
|
|
Performers string
|
|
|
|
Scenes string
|
|
|
|
Galleries string
|
|
|
|
Studios string
|
2020-07-07 00:35:43 +00:00
|
|
|
Tags string
|
2020-03-10 03:28:15 +00:00
|
|
|
Movies string
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-23 14:56:59 +00:00
|
|
|
func newJSONPaths() *jsonPaths {
|
2019-02-09 12:30:49 +00:00
|
|
|
jp := jsonPaths{}
|
2020-04-24 02:52:21 +00:00
|
|
|
jp.Metadata = config.GetMetadataPath()
|
2019-03-23 14:56:59 +00:00
|
|
|
jp.MappingsFile = filepath.Join(config.GetMetadataPath(), "mappings.json")
|
|
|
|
jp.ScrapedFile = filepath.Join(config.GetMetadataPath(), "scraped.json")
|
|
|
|
jp.Performers = filepath.Join(config.GetMetadataPath(), "performers")
|
|
|
|
jp.Scenes = filepath.Join(config.GetMetadataPath(), "scenes")
|
|
|
|
jp.Galleries = filepath.Join(config.GetMetadataPath(), "galleries")
|
|
|
|
jp.Studios = filepath.Join(config.GetMetadataPath(), "studios")
|
2020-03-10 03:28:15 +00:00
|
|
|
jp.Movies = filepath.Join(config.GetMetadataPath(), "movies")
|
2020-07-07 00:35:43 +00:00
|
|
|
jp.Tags = filepath.Join(config.GetMetadataPath(), "tags")
|
2019-02-09 12:30:49 +00:00
|
|
|
return &jp
|
|
|
|
}
|
|
|
|
|
2020-04-24 02:52:21 +00:00
|
|
|
func GetJSONPaths() *jsonPaths {
|
|
|
|
jp := newJSONPaths()
|
|
|
|
return jp
|
|
|
|
}
|
|
|
|
|
|
|
|
func EnsureJSONDirs() {
|
|
|
|
jsonPaths := GetJSONPaths()
|
|
|
|
utils.EnsureDir(jsonPaths.Metadata)
|
|
|
|
utils.EnsureDir(jsonPaths.Scenes)
|
|
|
|
utils.EnsureDir(jsonPaths.Galleries)
|
|
|
|
utils.EnsureDir(jsonPaths.Performers)
|
|
|
|
utils.EnsureDir(jsonPaths.Studios)
|
|
|
|
utils.EnsureDir(jsonPaths.Movies)
|
2020-07-07 00:35:43 +00:00
|
|
|
utils.EnsureDir(jsonPaths.Tags)
|
2020-04-24 02:52:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
func (jp *jsonPaths) PerformerJSONPath(checksum string) string {
|
2019-02-14 22:53:32 +00:00
|
|
|
return filepath.Join(jp.Performers, checksum+".json")
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (jp *jsonPaths) SceneJSONPath(checksum string) string {
|
2019-02-14 22:53:32 +00:00
|
|
|
return filepath.Join(jp.Scenes, checksum+".json")
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (jp *jsonPaths) StudioJSONPath(checksum string) string {
|
2019-02-14 22:53:32 +00:00
|
|
|
return filepath.Join(jp.Studios, checksum+".json")
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
2020-03-10 03:28:15 +00:00
|
|
|
|
2020-07-07 00:35:43 +00:00
|
|
|
func (jp *jsonPaths) TagJSONPath(checksum string) string {
|
|
|
|
return filepath.Join(jp.Tags, checksum+".json")
|
|
|
|
}
|
|
|
|
|
2020-03-10 03:28:15 +00:00
|
|
|
func (jp *jsonPaths) MovieJSONPath(checksum string) string {
|
|
|
|
return filepath.Join(jp.Movies, checksum+".json")
|
|
|
|
}
|