mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-08 22:36:37 +08:00
fix: improve media grouping and bot startup
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/model"
|
||||
@@ -34,6 +35,42 @@ func (o *OrganizerService) SmartClassify(ctx context.Context, m *model.Media) st
|
||||
return o.classifyMedia(ctx, m, lib.Type)
|
||||
}
|
||||
|
||||
func (o *OrganizerService) smartClassifySourceFile(ctx context.Context, src, sourceRoot, mediaType, title, parsedTitle string, metadataMatch *Match) string {
|
||||
if o == nil || !o.isSmartClassifyEnabled(ctx) {
|
||||
return ""
|
||||
}
|
||||
seriesLike := isSeriesLibraryType(mediaType)
|
||||
input := mediaClassifyInput{
|
||||
MediaType: mediaType,
|
||||
Title: strings.Join([]string{title, parsedTitle, filepath.Base(src)}, " "),
|
||||
Category: strings.Join(organizeDirectoryCategoryCandidates(src, sourceRoot), " "),
|
||||
}
|
||||
if metadataMatch != nil {
|
||||
input.Title = strings.Join([]string{
|
||||
metadataMatch.OriginalName,
|
||||
title,
|
||||
parsedTitle,
|
||||
filepath.Base(src),
|
||||
}, " ")
|
||||
input.Languages = metadataMatch.Languages
|
||||
input.Countries = metadataMatch.Countries
|
||||
input.Genres = metadataMatch.Genres
|
||||
if metadataMatch.NSFW {
|
||||
input.MediaType = "adult"
|
||||
}
|
||||
}
|
||||
if meta, err := ReadLocalMetadata(src, sourceRoot, seriesLike); err == nil && meta != nil && meta.HasNFO {
|
||||
input.Title = strings.Join([]string{meta.Title, meta.OriginalName, title, parsedTitle, filepath.Base(src)}, " ")
|
||||
input.Languages = parseCommaList(meta.Languages)
|
||||
input.Countries = parseCommaList(meta.Countries)
|
||||
input.Genres = parseCommaList(meta.Genres)
|
||||
if meta.NSFW {
|
||||
input.MediaType = "adult"
|
||||
}
|
||||
}
|
||||
return sanitizeFilename(classifyMediaCategory(input, o.categoryMap()))
|
||||
}
|
||||
|
||||
// parseCommaList splits a comma-separated string into trimmed non-empty values.
|
||||
func parseCommaList(s string) []string {
|
||||
if s == "" {
|
||||
|
||||
Reference in New Issue
Block a user