1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Merge pull request #108 from delaosa/master

Fix enclosureType for audio and YoutubeDL output template
This commit is contained in:
Maksym Pavlenko
2020-04-07 14:44:47 -07:00
committed by GitHub
2 changed files with 9 additions and 6 deletions

View File

@ -83,7 +83,7 @@ func Build(ctx context.Context, feed *model.Feed, cfg *config.Feed, provider url
enclosureType := itunes.MP4
if feed.Format == model.FormatAudio {
enclosureType = itunes.MP4
enclosureType = itunes.MP3
}
episodeName := EpisodeName(cfg, episode)

View File

@ -55,11 +55,8 @@ func (dl YoutubeDl) Download(ctx context.Context, feedConfig *config.Feed, episo
return nil, errors.Wrap(err, "failed to get temp dir for download")
}
ext := "mp4"
if feedConfig.Format == model.FormatAudio {
ext = "mp3"
}
filePath := filepath.Join(tmpDir, fmt.Sprintf("%s.%s", episode.ID, ext))
// filePath with YoutubeDl template format
filePath := filepath.Join(tmpDir, fmt.Sprintf("%s.%s", episode.ID, "%(ext)s"))
args := buildArgs(feedConfig, episode, filePath)
output, err := dl.exec(ctx, args...)
@ -74,6 +71,12 @@ func (dl YoutubeDl) Download(ctx context.Context, feedConfig *config.Feed, episo
return nil, errors.New(output)
}
ext := "mp4"
if feedConfig.Format == model.FormatAudio {
ext = "mp3"
}
// filePath now with the final extension
filePath = filepath.Join(tmpDir, fmt.Sprintf("%s.%s", episode.ID, ext))
f, err := os.Open(filePath)
if err != nil {
return nil, errors.Wrap(err, "failed to open downloaded file")