i said PLS no multi handle file
parent
61f9b9c724
commit
2e4e4b9b06
25
main.go
25
main.go
|
|
@ -218,24 +218,33 @@ func RunWith(ctx context.Context, outd, ind string, patterns []string, overrides
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
done := map[int]bool{}
|
||||||
for _, pattern := range patterns {
|
for _, pattern := range patterns {
|
||||||
for _, entry := range entries {
|
for i, entry := range entries {
|
||||||
|
if done[i] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !entry.Type().IsRegular() && !(Debug && Dry) {
|
if !entry.Type().IsRegular() && !(Debug && Dry) {
|
||||||
continue
|
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
|
return err
|
||||||
|
} else if match {
|
||||||
|
done[i] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
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)
|
f := path.Base(inf)
|
||||||
for _, pattern := range patterns {
|
for _, pattern := range patterns {
|
||||||
found, match := Parse(f, pattern)
|
found, match := Parse(f, pattern)
|
||||||
if !match {
|
if !match {
|
||||||
|
if Debug {
|
||||||
|
log.Printf("%q does not match %q", pattern, f)
|
||||||
|
}
|
||||||
continue
|
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 found.Title == "" || found.Season == "" || found.Episode == "" {
|
||||||
|
if Debug {
|
||||||
|
log.Printf("%q does not match all %q: %+v", pattern, f, found)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found.Title = strings.ReplaceAll(found.Title, ".", " ")
|
found.Title = strings.ReplaceAll(found.Title, ".", " ")
|
||||||
found.Title = strings.Join(strings.Fields(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) {
|
func Parse(f string, pattern string) (Fields, bool) {
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,7 @@ func TestRecursive(t *testing.T) {
|
||||||
notExists(t, path.Join(outd, "D", "title_S02E04.d"))
|
notExists(t, path.Join(outd, "D", "title_S02E04.d"))
|
||||||
notExists(t, path.Join(outd, "title_S03E06.e"))
|
notExists(t, path.Join(outd, "title_S03E06.e"))
|
||||||
exists(t, path.Join(outd, "F", "Dr_Stone_S04E12.mkv"))
|
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) {
|
func write(f string, b ...string) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue