hmm i want an autosuggest pattern list
parent
b696251895
commit
81d1ce1dde
2
main.go
2
main.go
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -58,6 +59,7 @@ func one(ctx context.Context, outd, inf string, patterns []string, overrides map
|
||||||
if found["title"] == "" || found["season"] == "" || found["episode"] == "" {
|
if found["title"] == "" || found["season"] == "" || found["episode"] == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
found["title"] = strings.Join(strings.Fields(found["title"]), "_")
|
||||||
|
|
||||||
if err := mvNLn(ctx, outd, inf, found["title"], found["season"], found["episode"]); err != nil {
|
if err := mvNLn(ctx, outd, inf, found["title"], found["season"], found["episode"]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@ func TestRun(t *testing.T) {
|
||||||
"[SubsPlease] Tokidoki Bosotto Russia-go de Dereru Tonari no Alya-san - 01 (720p) [A12844D5].mkv",
|
"[SubsPlease] Tokidoki Bosotto Russia-go de Dereru Tonari no Alya-san - 01 (720p) [A12844D5].mkv",
|
||||||
"[SubsPlease] Tokidoki Bosotto Russia-go de Dereru Tonari no Alya-san - 02 (720p) [2608F490].mkv",
|
"[SubsPlease] Tokidoki Bosotto Russia-go de Dereru Tonari no Alya-san - 02 (720p) [2608F490].mkv",
|
||||||
},
|
},
|
||||||
|
patterns: []string{
|
||||||
|
`^\[[^\]]*\] (?P<title>.*) - (?<episode>[0-9]*)`,
|
||||||
|
},
|
||||||
|
overrides: map[string]string{
|
||||||
|
"season": "01",
|
||||||
|
},
|
||||||
want: []string{
|
want: []string{
|
||||||
"Tokidoki_Bosotto_Russia-go_de_Dereru_Tonari_no_Alya-san_S01E01.mkv",
|
"Tokidoki_Bosotto_Russia-go_de_Dereru_Tonari_no_Alya-san_S01E01.mkv",
|
||||||
"Tokidoki_Bosotto_Russia-go_de_Dereru_Tonari_no_Alya-san_S01E02.mkv",
|
"Tokidoki_Bosotto_Russia-go_de_Dereru_Tonari_no_Alya-san_S01E02.mkv",
|
||||||
|
|
@ -74,6 +80,7 @@ func TestRun(t *testing.T) {
|
||||||
t.Error("failed to list outdir: %w", err)
|
t.Error("failed to list outdir: %w", err)
|
||||||
} else {
|
} else {
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
|
t.Logf("%s", entry.Name())
|
||||||
if !slices.Contains(c.want, path.Base(entry.Name())) {
|
if !slices.Contains(c.want, path.Base(entry.Name())) {
|
||||||
t.Errorf("unexpected %s", entry.Name())
|
t.Errorf("unexpected %s", entry.Name())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue