Sync shared snapshot from 2e6baaa
This commit is contained in:
1 parent
5ea8551d60
commit
81b62cdc26
34 files changed
+197
-121
No files matched your search
@@ -9,7 +9,7 @@ OUTPUT_DIR=../output
|
||||
DOWNLOADS_DIR=../downloads
|
||||
THUMBNAIL_DIR=../thumbnails
|
||||
MODEL_CACHE_DIR=../models
|
||||
WORKFLOWS_DIR=../MediaTools/public/workflows
|
||||
WORKFLOWS_DIR=../CraftStudio/public/workflows
|
||||
FFMPEG_PATH=ffmpeg
|
||||
FFPROBE_PATH=ffprobe
|
||||
YT_DLP_PATH=yt-dlp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Shared media backend
|
||||
|
||||
The backend is one Go module, shared across every `MEDIA_SERVICE` instance in the workspace. Set `MEDIA_SERVICE` to `viewer`, `tools`, `analyzer`, `config`, `moderator`, `kiosk`, or `carriernode` to select the route set while keeping the same auth, database, migration, file-safety, and worker implementation.
|
||||
The backend is one Go module, shared across every `MEDIA_SERVICE` instance in the workspace. Set `MEDIA_SERVICE` to `viewer`, `craftstudio`, `contentscanner`, `config`, `moderator`, `kiosk`, or `carriernode` to select the route set while keeping the same auth, database, migration, file-safety, and worker implementation.
|
||||
|
||||
From this directory:
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
type Service string
|
||||
|
||||
const (
|
||||
Viewer Service = "viewer"
|
||||
Tools Service = "tools"
|
||||
Analyzer Service = "analyzer"
|
||||
ConfigService Service = "config"
|
||||
Moderator Service = "moderator"
|
||||
Kiosk Service = "kiosk"
|
||||
CarrierNode Service = "carriernode"
|
||||
Viewer Service = "viewer"
|
||||
CraftStudio Service = "craftstudio"
|
||||
ContentScanner Service = "contentscanner"
|
||||
ConfigService Service = "config"
|
||||
Moderator Service = "moderator"
|
||||
Kiosk Service = "kiosk"
|
||||
CarrierNode Service = "carriernode"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -89,7 +89,7 @@ func Load() (*Config, error) {
|
||||
MediaRoots: roots,
|
||||
InputRoot: filepath.Clean(envOr("INPUT_DIR", "./input")),
|
||||
CopyRoot: filepath.Clean(envOr("UPLOAD_COPY_DIR", "./copy")),
|
||||
WorkflowsRoot: filepath.Clean(envOr("WORKFLOWS_DIR", filepath.Join("..", "MediaTools", "public", "workflows"))),
|
||||
WorkflowsRoot: filepath.Clean(envOr("WORKFLOWS_DIR", filepath.Join("..", "CraftStudio", "public", "workflows"))),
|
||||
ThumbnailRoot: filepath.Clean(envOr("THUMBNAIL_DIR", "./thumbnails")),
|
||||
OutputRoot: filepath.Clean(envOr("OUTPUT_DIR", "./output")),
|
||||
DownloadsRoot: filepath.Clean(envOr("DOWNLOADS_DIR", "./downloads")),
|
||||
@@ -124,10 +124,10 @@ func normalizeService(value string) Service {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "viewer", "mediaviewer":
|
||||
return Viewer
|
||||
case "tools", "mediatools":
|
||||
return Tools
|
||||
case "analyzer", "mediaanalyzer":
|
||||
return Analyzer
|
||||
case "craftstudio":
|
||||
return CraftStudio
|
||||
case "contentscanner":
|
||||
return ContentScanner
|
||||
case "config", "mediaconfig", "projectconfigurator":
|
||||
return ConfigService
|
||||
case "moderator", "mediamoderator":
|
||||
@@ -145,10 +145,10 @@ func serviceName(service Service) string {
|
||||
switch service {
|
||||
case Viewer:
|
||||
return "MediaViewer"
|
||||
case Tools:
|
||||
return "MediaTools"
|
||||
case Analyzer:
|
||||
return "MediaAnalyzer"
|
||||
case CraftStudio:
|
||||
return "CraftStudio"
|
||||
case ContentScanner:
|
||||
return "ContentScanner"
|
||||
case ConfigService:
|
||||
return "ProjectConfigurator"
|
||||
case Moderator:
|
||||
|
||||
@@ -311,7 +311,7 @@ CREATE INDEX IF NOT EXISTS media_analysis_tasks_status_idx ON media_analysis_tas
|
||||
-- to make repeated analysis runs idempotent instead of piling up duplicate tag rows.
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS media_tags_ai_tag_unique ON media_tags (media_key, tag) WHERE user_id IS NULL;
|
||||
|
||||
-- Speeds up the MediaAnalyzer dashboard/pipelines/history/live-status queries: analyzerStats and
|
||||
-- Speeds up the ContentScanner dashboard/pipelines/history/live-status queries: analyzerStats and
|
||||
-- analyzerPipelineBreakdown group active media by type (and join it against thumbnails), and
|
||||
-- analyzerHistory sorts media_worker_jobs by queued_at with no status filter, none of which the
|
||||
-- existing media/media_worker_jobs indexes above actually cover.
|
||||
|
||||
@@ -290,11 +290,11 @@ var serviceTabsByService = map[config.Service][]tabOption{
|
||||
config.Viewer: {
|
||||
{"Library", "/"}, {"Feed", "/feed"}, {"Tags", "/tags"}, {"Playlists", "/playlists"}, {"About", "/about"},
|
||||
},
|
||||
config.Tools: {
|
||||
config.CraftStudio: {
|
||||
{"Generator", "/"}, {"Downloader", "/downloader"}, {"Converter", "/converter"},
|
||||
{"Schedules", "/schedules"}, {"Library", "/library"}, {"About", "/about"},
|
||||
},
|
||||
config.Analyzer: {
|
||||
config.ContentScanner: {
|
||||
{"Dashboard", "/"}, {"Discover", "/discover"}, {"Images", "/images"}, {"Videos", "/videos"},
|
||||
{"Audios", "/audios"}, {"Funscripts", "/funscripts"}, {"Schedules", "/schedules"}, {"About", "/about"},
|
||||
},
|
||||
@@ -310,8 +310,8 @@ var serviceTabsByService = map[config.Service][]tabOption{
|
||||
// mount "type" values each service's own tab accepts when configuring its mounts.
|
||||
var serviceMountTypesByService = map[config.Service][]string{
|
||||
config.Viewer: {"media", "thumbnails", "funscripts"},
|
||||
config.Tools: {"downloads", "generated", "converted", "converter input", "generator input", "generator copy"},
|
||||
config.Analyzer: {"images", "videos", "audios", "funscripts", "models", "thumbnails"},
|
||||
config.CraftStudio: {"downloads", "generated", "converted", "converter input", "generator input", "generator copy"},
|
||||
config.ContentScanner: {"images", "videos", "audios", "funscripts", "models", "thumbnails"},
|
||||
config.Moderator: {"media", "thumbnails"},
|
||||
config.Kiosk: {"media"},
|
||||
config.CarrierNode: {"media", "output"},
|
||||
@@ -538,7 +538,7 @@ func (s *Server) mountMappings(ctx context.Context) map[string]any {
|
||||
// opposed to a project-specific working directory like "downloads", "generated",
|
||||
// "thumbnails", or "models", which have their own dedicated Root config fields instead and
|
||||
// are deliberately left out here. A path is entered under whichever project's tab happens to
|
||||
// need it (MediaAnalyzer's "images"/"videos"/"audios", MediaViewer/MediaKiosk's "media", ...)
|
||||
// need it (ContentScanner's "images"/"videos"/"audios", MediaViewer/MediaKiosk's "media", ...)
|
||||
// but they're all describing locations CarrierNode itself has to walk, since it's the only
|
||||
// service with the volume mounted - see effectiveMediaRoots.
|
||||
var mediaLibraryMountTypes = map[string]bool{
|
||||
@@ -964,7 +964,7 @@ func (s *Server) writeCarrierNodeFiles(w http.ResponseWriter, r *http.Request, r
|
||||
if recent {
|
||||
sort.Slice(files, func(i, j int) bool { return files[i].Mtime > files[j].Mtime })
|
||||
}
|
||||
// Internal callers (e.g. MediaAnalyzer discovery) need to list an entire real-sized library
|
||||
// Internal callers (e.g. ContentScanner discovery) need to list an entire real-sized library
|
||||
// in one pass; the public 1000-item cap stays in place for anyone without the shared secret.
|
||||
maxLimit := 1000
|
||||
if s.cfg.InternalServiceSecret != "" && r.Header.Get("X-Internal-Auth") == s.cfg.InternalServiceSecret {
|
||||
@@ -1175,7 +1175,7 @@ func (s *Server) carrierNodeStore(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// resolveStoreFile is CarrierNode's own local-filesystem lookup for /api/store, which catalogs a
|
||||
// file MediaTools already pushed into one of CarrierNode's mounts (InputRoot, MediaRoots,
|
||||
// file CraftStudio already pushed into one of CarrierNode's mounts (InputRoot, MediaRoots,
|
||||
// DownloadsRoot, OutputRoot) - unlike everything else in this file, it's called with a path that
|
||||
// isn't necessarily under MediaRoots, so it can't just use resolveMediaPath.
|
||||
func (s *Server) resolveStoreFile(value string) (string, error) {
|
||||
|
||||
@@ -1501,7 +1501,7 @@ func hasFunscriptSidecar(filePath string) bool {
|
||||
}
|
||||
|
||||
// funscriptSidecarExists is hasFunscriptSidecar for callers without local filesystem access
|
||||
// (MediaAnalyzer) - it checks for the sidecar on CarrierNode instead of statting a local path.
|
||||
// (ContentScanner) - it checks for the sidecar on CarrierNode instead of statting a local path.
|
||||
func (s *Server) funscriptSidecarExists(ctx context.Context, key string) bool {
|
||||
base := strings.TrimSuffix(key, filepath.Ext(key))
|
||||
for _, candidate := range []string{base + ".funscript", base + ".json"} {
|
||||
|
||||
@@ -433,7 +433,7 @@ type analysisSidecarRequest struct {
|
||||
}
|
||||
|
||||
// callAnalyzerModelsService calls the AnalyzerModels sidecar (a separate process in the same
|
||||
// container, not baked into this binary - see ANALYZER_MODELS_URL and MediaAnalyzer/Dockerfile),
|
||||
// container, not baked into this binary - see ANALYZER_MODELS_URL and ContentScanner/Dockerfile),
|
||||
// the same way executeGeneration already calls out to ComfyUI for image generation. Video frames
|
||||
// are analyzed through the image endpoint since by the time this runs the video has already been
|
||||
// reduced to a still frame.
|
||||
|
||||
@@ -211,9 +211,9 @@ func (s *Server) mountServiceRoutes(r chi.Router) {
|
||||
switch s.cfg.Service {
|
||||
case config.Viewer:
|
||||
s.mountViewerRoutes(r)
|
||||
case config.Tools:
|
||||
case config.CraftStudio:
|
||||
s.mountToolsRoutes(r)
|
||||
case config.Analyzer:
|
||||
case config.ContentScanner:
|
||||
s.mountAnalyzerRoutes(r)
|
||||
case config.ConfigService:
|
||||
s.mountConfigRoutes(r)
|
||||
@@ -337,7 +337,7 @@ func (s *Server) listenAndServe(ctx context.Context) error {
|
||||
|
||||
func (s *Server) Run(ctx context.Context) error {
|
||||
go s.resumeWorkflowJobs(ctx)
|
||||
if s.cfg.Service == config.Analyzer {
|
||||
if s.cfg.Service == config.ContentScanner {
|
||||
go s.runAnalyzerScheduler(ctx)
|
||||
}
|
||||
if s.cfg.Service == config.ConfigService {
|
||||
|
||||
@@ -441,7 +441,7 @@ func firstString(values map[string]any, keys ...string) string {
|
||||
|
||||
// workflowFileCarrierNodePaths mirrors the search order resolveWorkflowFile used to walk locally
|
||||
// (InputRoot, MediaRoots, DownloadsRoot, OutputRoot) but as CarrierNode-side mount prefixes, since
|
||||
// MediaTools no longer has any of those roots mounted on its own filesystem.
|
||||
// CraftStudio no longer has any of those roots mounted on its own filesystem.
|
||||
var workflowFileCarrierNodePaths = []string{"/mount/inputs/", "/media/", "/media/downloads/", "/mount/generated/"}
|
||||
|
||||
// fetchWorkflowFileFromCarrierNode locates a converter input under any of CarrierNode's mounts and
|
||||
|
||||
Reference in new issue
Block a user