53 lines
870 B
Go
53 lines
870 B
Go
package asses
|
|
|
|
import (
|
|
"context"
|
|
"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 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)
|
|
})
|
|
}
|