Skip to content

Commit

Permalink
fix: fixed struct alloc
Browse files Browse the repository at this point in the history
Signed-off-by: gryffyn <[email protected]>
  • Loading branch information
gryffyn committed Mar 30, 2023
1 parent f41ff84 commit 8332581
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions osiris.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ type args struct {
}

var (
seriesTemplate = "{{ .Title }}{{if .Options.SeriesYear}} ({{ .Year }}){{end}} - {{ .Episode}}{{if ." +
"EpisodeTitle}} - {{ .EpisodeTitle}}{{end}}{{if .Options.Scene }} ({{ .Scene }}){{end}}"
filmTemplate = "{{ .Title }} ({{ .Year }}){{if .Options.Scene }} ({{ .Scene }}){{end}}"
seriesTemplate = "{{ .Title }}{{if .Options.SeriesYear}} ({{ .Year }}){{end}} - {{ .Episode}}{{if .EpisodeTitle}} - {{ .EpisodeTitle}}{{end}}{{if .Options.Scene }} ({{ .Scene }}){{end}}"
filmTemplate = "{{ .Title }} ({{ .Year }}){{if .Options.Scene }} ({{ .Scene }}){{end}}"
)

func main() {
Expand Down Expand Up @@ -164,7 +163,7 @@ func getFilename(filepath string, re *regexp.Regexp, cfg *config, year, title st
return strings.ReplaceAll(s, ".", " ")
})

r := release{
r := &release{
Title: strings.TrimSpace(strings.ReplaceAll(metadata["title"], ".", " ")),
Year: strings.TrimSpace(metadata["year"]),
Episode: strings.TrimSpace(strings.ToUpper(metadata["ep"])),
Expand Down Expand Up @@ -198,9 +197,12 @@ func getFilename(filepath string, re *regexp.Regexp, cfg *config, year, title st
}
}

releaseTemplate, _ := template.New("release").Parse(tmpl)
releaseTemplate, err := template.New("release").Parse(tmpl)
if err != nil {
log.Fatalln(err)
}
var newname bytes.Buffer
err := releaseTemplate.Execute(&newname, &r)
err = releaseTemplate.Execute(&newname, &r)
if err != nil {
log.Fatalln(err)
}
Expand Down

0 comments on commit 8332581

Please sign in to comment.