mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 13:56:37 +08:00
refactor: split modules and harden scraping workflows
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/model"
|
||||
@@ -36,3 +37,34 @@ func TestWriteMediaNFOUsesMappedDestinationPath(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteMediaNFOUsesEpisodeTitleForEpisodeDetails(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mediaPath := filepath.Join(root, "剧集", "间谍过家家", "Season 02", "间谍过家家 - S02E01.mkv")
|
||||
if err := os.MkdirAll(filepath.Dir(mediaPath), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(mediaPath, []byte("media"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
got, err := WriteMediaNFO(&model.Media{
|
||||
Title: "间谍过家家",
|
||||
OriginalName: "SPY×FAMILY",
|
||||
EpisodeTitle: "任务代号: 猫",
|
||||
Path: mediaPath,
|
||||
SeasonNum: 2,
|
||||
EpisodeNum: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body, err := os.ReadFile(got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
text := string(body)
|
||||
if !strings.Contains(text, "<title>任务代号: 猫</title>") || !strings.Contains(text, "<showtitle>间谍过家家</showtitle>") {
|
||||
t.Fatalf("episode nfo did not keep episode/show titles separate:\n%s", text)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user