From bda72cc7dbfe14c6e39a14b1e2b9f523afde3e16 Mon Sep 17 00:00:00 2001 From: milarin Date: Sun, 15 Jan 2023 22:32:01 +0100 Subject: [PATCH] AnimeEpFilepathPattern improved --- anime_episode_filepath.go | 9 ++++++++- envvars.go | 2 +- file_props.go | 7 ------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/anime_episode_filepath.go b/anime_episode_filepath.go index fe3d5e3..0037705 100644 --- a/anime_episode_filepath.go +++ b/anime_episode_filepath.go @@ -4,14 +4,21 @@ 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{ - Title: animeEp.Anime.Title, + Anime: animeEp.Anime, Episode: animeEp.Episode, Ext: ext, } diff --git a/envvars.go b/envvars.go index 5681d5d..5150ddc 100644 --- a/envvars.go +++ b/envvars.go @@ -21,7 +21,7 @@ var ( AnimeEpFilepathPattern = envvars.Object( "EPISODE_FILEPATH_PATTERN", - template.Must(template.New("anime-episode-filepath-pattern").Parse(`{{.Title.UserPreferred}}/{{.Title.UserPreferred}} Episode {{.Episode}}.{{.Ext}}`)), + template.Must(template.New("anime-episode-filepath-pattern").Parse(`{{.Anime.Title.UserPreferred}}/{{.Anime.Title.UserPreferred}} Episode {{.Episode}}.{{.Ext}}`)), template.New("anime-episode-filepath-pattern").Parse, ) diff --git a/file_props.go b/file_props.go index 981e39c..f7703cb 100644 --- a/file_props.go +++ b/file_props.go @@ -3,18 +3,11 @@ package logic import ( "path/filepath" - "git.milar.in/milarin/anilist" "git.milar.in/milarin/slices" "git.milar.in/nyaanime/model" "git.milar.in/nyaanime/parsers" ) -type AnimePathPatternData struct { - Title anilist.MediaTitle - Episode int - Ext string -} - func GetAnimeEpProps(animeEp model.AnimeEpisode) (*FilePriority, bool) { animeEpPath := GetAnimeEpFilepath(animeEp, "*") files, err := filepath.Glob(animeEpPath)