2023-01-13 10:39:59 +01:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"git.milar.in/nyaanime/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetAnimeEpFilepath(animeEp model.AnimeEpisode, ext string) string {
|
2023-01-13 11:27:09 +01:00
|
|
|
ext = strings.TrimPrefix(ext, ".")
|
|
|
|
|
2023-01-13 10:39:59 +01:00
|
|
|
tmplData := AnimePathPatternData{
|
|
|
|
Title: animeEp.Anime.Title,
|
|
|
|
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())
|
|
|
|
}
|