32 lines
588 B
Go
32 lines
588 B
Go
package logic
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"git.milar.in/milarin/anilist"
|
|
"git.milar.in/nyaanime/model"
|
|
)
|
|
|
|
type AnimePathPatternData struct {
|
|
Anime *anilist.Media
|
|
Episode int
|
|
Ext string
|
|
}
|
|
|
|
func GetAnimeEpFilepath(animeEp model.AnimeEpisode, ext string) string {
|
|
ext = strings.TrimPrefix(ext, ".")
|
|
|
|
tmplData := AnimePathPatternData{
|
|
Anime: animeEp.Anime,
|
|
Episode: animeEp.Episode,
|
|
Ext: ext,
|
|
}
|
|
|
|
b := new(strings.Builder)
|
|
if err := AnimeEpFilepathPattern.Execute(b, tmplData); err != nil {
|
|
panic(err)
|
|
}
|
|
return filepath.Join(AnimePath, b.String())
|
|
}
|