mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-11 15:56:37 +08:00
Fix media scraping rename and compose pulls
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@@ -159,6 +160,49 @@ func TestOrganizeDirectoryHonorsMoviePilotStyleNamingFormat(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizeDirectoryUsesSeriesFolderWhenFileTitleIsOnlyReleaseTags(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
dest := filepath.Join(root, "media")
|
||||
src := filepath.Join(root, "downloads", "链锯人 总集篇 (2025)", "Season 1", "2025.2160p.120fps.WEB-DL.H265.10bit.DTS5.1.S01E01.mkv")
|
||||
writeOrgFile(t, src, "episode")
|
||||
|
||||
repos := newOrganizerTestRepo(t)
|
||||
template := "{{title}}{% if year %} ({{year}}){% endif %}/Season {{season}}/{{title}} - {{season_episode}}{% if video_format %} - {{video_format}}{% endif %}{{fileExt}}"
|
||||
if err := repos.Setting.Set(t.Context(), "organize.tv_format", template); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repos.Setting.Set(t.Context(), "organize.anime_format", template); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
organizer := NewOrganizerService(&config.Config{}, zap.NewNop(), repos)
|
||||
if _, err := organizer.OrganizeDirectory(t.Context(), OrganizeOptions{
|
||||
SourcePath: src,
|
||||
DestPath: dest,
|
||||
MediaType: "anime",
|
||||
MediaCategory: "日番",
|
||||
TransferMode: TransferCopy,
|
||||
}); err != nil {
|
||||
t.Fatalf("organize anime: %v", err)
|
||||
}
|
||||
|
||||
want := filepath.Join(dest, "电视剧", "日番", "链锯人 总集篇 (2025)", "Season 1", "链锯人 总集篇 - S01E01 - 2160p.120fps.WEB-DL.H265.10bit.DTS5.1.mkv")
|
||||
if _, err := os.Stat(want); err != nil {
|
||||
t.Fatalf("organize should use series folder title and keep video_format, want %q: %v", want, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizeNamingTemplateKeepsVideoFormatToken(t *testing.T) {
|
||||
rel := renderOrganizeNamingTemplate("{title} - {episode_tag} - {video_format}{fileExt}", organizeNamingData{
|
||||
Title: "链锯人 总集篇",
|
||||
EpisodeTag: "S01E01",
|
||||
VideoFormat: extractOrganizeReleaseTag("2025.2160p.120fps.WEB-DL.H265.10bit.DTS5.1.mkv"),
|
||||
FileExt: ".mkv",
|
||||
})
|
||||
if !strings.Contains(rel, "2160p.120fps.WEB-DL.H265.10bit.DTS5.1") {
|
||||
t.Fatalf("video_format was lost from rendered name: %q", rel)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizePipelineUsesSameNamingFormat(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
src := filepath.Join(root, "downloads", "Pipeline.Show.S01E02.2026.mkv")
|
||||
|
||||
Reference in New Issue
Block a user