fix media organize and subscription workflows

This commit is contained in:
ShukeBta
2026-06-30 20:18:02 +08:00
parent b41f62d572
commit 941bb273b9
107 changed files with 5420 additions and 526 deletions
+36
View File
@@ -2,6 +2,7 @@ package service
import (
"context"
"path/filepath"
"strings"
"github.com/ShukeBta/MediaStationGo/internal/model"
@@ -84,3 +85,38 @@ func (o *OrganizerService) autoAddLibraryEnabled(ctx context.Context) bool {
}
return parseBoolSetting(v, true)
}
func (o *OrganizerService) effectiveOrganizeOverrides(opts OrganizeOptions, explicitDest string) (string, string) {
mediaType := normalizeOrganizeMediaType(opts.MediaType)
category := sanitizeFilename(strings.TrimSpace(opts.MediaCategory))
hasExplicitLayout := mediaType != "" || category != ""
if category != "" {
if impliedType, normalizedCategory := o.mediaTypeForDirectoryCategory(category); impliedType != "" {
category = normalizedCategory
if mediaType == "" {
mediaType = impliedType
}
}
return mediaType, category
}
if hasExplicitLayout {
if layout := o.organizeLayoutFromDestPath(explicitDest); layout.Category != "" {
category = sanitizeFilename(layout.Category)
if mediaType == "" {
mediaType = layout.MediaType
}
}
}
return mediaType, category
}
func (o *OrganizerService) organizeLayoutFromDestPath(dest string) organizeDirectoryLayout {
dest = filepath.Clean(strings.TrimSpace(dest))
if dest == "" || dest == "." {
return organizeDirectoryLayout{}
}
if mediaType, category := o.mediaTypeForDirectoryCategory(filepath.Base(dest)); mediaType != "" && category != "" {
return organizeDirectoryLayout{MediaType: mediaType, Category: category}
}
return organizeDirectoryLayout{}
}