i said PLS no multi handle file

main
bel 2025-05-09 07:52:36 -06:00
parent 61f9b9c724
commit 2e4e4b9b06
2 changed files with 21 additions and 5 deletions

25
main.go
View File

@ -218,24 +218,33 @@ func RunWith(ctx context.Context, outd, ind string, patterns []string, overrides
if err != nil {
return err
}
done := map[int]bool{}
for _, pattern := range patterns {
for _, entry := range entries {
for i, entry := range entries {
if done[i] {
continue
}
if !entry.Type().IsRegular() && !(Debug && Dry) {
continue
}
if err := one(ctx, outd, path.Join(ind, entry.Name()), []string{pattern}, overrides, mvNLn); err != nil {
if match, err := one(ctx, outd, path.Join(ind, entry.Name()), []string{pattern}, overrides, mvNLn); err != nil {
return err
} else if match {
done[i] = true
}
}
}
return nil
}
func one(ctx context.Context, outd, inf string, patterns []string, overrides Fields, mvNLn MvNLn) error {
func one(ctx context.Context, outd, inf string, patterns []string, overrides Fields, mvNLn MvNLn) (bool, error) {
f := path.Base(inf)
for _, pattern := range patterns {
found, match := Parse(f, pattern)
if !match {
if Debug {
log.Printf("%q does not match %q", pattern, f)
}
continue
}
@ -250,14 +259,20 @@ func one(ctx context.Context, outd, inf string, patterns []string, overrides Fie
}
if found.Title == "" || found.Season == "" || found.Episode == "" {
if Debug {
log.Printf("%q does not match all %q: %+v", pattern, f, found)
}
continue
}
found.Title = strings.ReplaceAll(found.Title, ".", " ")
found.Title = strings.Join(strings.Fields(found.Title), "_")
return foundOne(ctx, outd, inf, found, mvNLn)
if Debug {
log.Printf("%q matches %q as %+v", pattern, f, found)
}
return true, foundOne(ctx, outd, inf, found, mvNLn)
}
return nil
return false, nil
}
func Parse(f string, pattern string) (Fields, bool) {

View File

@ -264,6 +264,7 @@ func TestRecursive(t *testing.T) {
notExists(t, path.Join(outd, "D", "title_S02E04.d"))
notExists(t, path.Join(outd, "title_S03E06.e"))
exists(t, path.Join(outd, "F", "Dr_Stone_S04E12.mkv"))
notExists(t, path.Join(outd, "F", "[Yameii]_Dr_Stone_-_S04E12.mkv"))
}
func write(f string, b ...string) {