logic/anime_episode_filepath.go

25 lines
471 B
Go

package logic
import (
"path/filepath"
"strings"
"git.milar.in/nyaanime/model"
)
func GetAnimeEpFilepath(animeEp model.AnimeEpisode, ext string) string {
ext = strings.TrimPrefix(ext, ".")
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())
}