initial commit
This commit is contained in:
31
anime_episode_filepath.go
Normal file
31
anime_episode_filepath.go
Normal file
@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.tordarus.net/nyaanime/model"
|
||||
"git.tordarus.net/tordarus/anilist"
|
||||
)
|
||||
|
||||
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())
|
||||
}
|
Reference in New Issue
Block a user