stub cmd.asses

This commit is contained in:
Bel LaPointe
2025-05-08 15:30:51 -06:00
parent 64c4d1908a
commit 137fdf07ed
2 changed files with 59 additions and 3 deletions

View File

@@ -2,15 +2,51 @@ package asses
import (
"context"
"io"
"io/fs"
"path"
"path/filepath"
"show-rss/src/asses"
"show-rss/src/cron"
)
var rootDs = []string{
"/volume1/video/Bel/Anime",
"/volume1/video/QT/TV",
}
type CB func(context.Context, string) error
func Main(ctx context.Context) error {
return cron.Cron(ctx, asses.Next, One)
}
func One(ctx context.Context) error {
return io.EOF
return OneWith(ctx, rootDs, asses.One)
}
func OneWith(ctx context.Context, rootds []string, cb CB) error {
for _, rootd := range rootds {
if err := one(ctx, rootd, cb); err != nil {
return err
}
}
return nil
}
func one(ctx context.Context, rootd string, cb CB) error {
return filepath.WalkDir(rootd, func(p string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
if path.Ext(p) != ".mkv" {
return nil
}
return cb(ctx, p)
})
}