diff --git a/main.go b/main.go index 45845f3..760be2e 100644 --- a/main.go +++ b/main.go @@ -151,7 +151,7 @@ func main() { } // good to have early on - templates, err := yt.FetchTemplates() + templates, err := yt.FetchTemplates(path.Join(userConfigDir, "vodular", "templates")) if err != nil { log.Fatalf("Failed to fetch templates: %v", err) os.Exit(1) diff --git a/youtube/youtube.go b/youtube/youtube.go index 79641fa..c6ace15 100644 --- a/youtube/youtube.go +++ b/youtube/youtube.go @@ -113,11 +113,6 @@ var videoYtCategory = map[CategoryType]string { CATEGORY_ENTERTAINMENT: YT_CATEGORY_ENTERTAINMENT, } -var templateDir = "templates" -var tagsPath = path.Join(templateDir, "tags.txt") -var titlePath = path.Join(templateDir, "title.txt") -var descriptionPath = path.Join(templateDir, "description.txt") - const defaultTitleTemplate = "{{.Title}} - {{FormatTime .Date \"02 Jan 2006\"}}" const defaultDescriptionTemplate = @@ -135,9 +130,13 @@ var templateFuncs = template.FuncMap{ }, } -func FetchTemplates() (*Template, error) { +func FetchTemplates(templateDir string) (*Template, error) { tmpl := Template{} + var tagsPath = path.Join(templateDir, "tags.txt") + var titlePath = path.Join(templateDir, "title.txt") + var descriptionPath = path.Join(templateDir, "description.txt") + // tags if tagsFile, err := os.ReadFile(tagsPath); err == nil { tmpl.Tags = strings.Split(string(tagsFile), "\n")