fixed double ext and playlist title detection (#106)

This commit is contained in:
Marco
2023-11-22 11:14:58 +01:00
committed by GitHub
parent fe6519773e
commit f478754b6f
3 changed files with 35 additions and 4 deletions

View File

@@ -84,9 +84,11 @@ func (p *Process) Start() {
}
if p.Output.Filename != "" {
out.Filename = p.Output.Filename + ".%(ext)s"
out.Filename = p.Output.Filename
}
buildFilename(&p.Output)
params := append([]string{
strings.Split(p.Url, "?list")[0], //no playlist
"--newline",
@@ -298,3 +300,16 @@ func (p *Process) SetMetadata() error {
func (p *Process) getShortId() string {
return strings.Split(p.Id, "-")[0]
}
func buildFilename(o *DownloadOutput) {
if o.Filename != "" && strings.Contains(o.Filename, ".%(ext)s") {
o.Filename += ".%(ext)s"
}
o.Filename = strings.Replace(
o.Filename,
".%(ext)s.%(ext)s",
".%(ext)s",
1,
)
}