Skip to content

Instantly share code, notes, and snippets.

@mrtrkmn
Created April 19, 2021 01:04
Show Gist options
  • Save mrtrkmn/e953cf6679a2c834629e84d6a9dcdfdc to your computer and use it in GitHub Desktop.
Save mrtrkmn/e953cf6679a2c834629e84d6a9dcdfdc to your computer and use it in GitHub Desktop.
package client
type YoutubeDL struct {
c *Client
}
// exec executes an ExecFunc using 'youtube-dl'.
func (ytdl *YoutubeDL) exec(args ...string) ([]byte, error) {
return ytdl.c.exec("youtube-dl", args...)
}
// DownloadWithOutputName generates Folder named with Playlist name
// downloads videos under given playlist url to Folder
func (ytdl *YoutubeDL) DownloadWithOutputName(folderName, url string) error {
cmds := []string{"-o", folderName + "/%(playlist_index)s - %(title)s.%(ext)s", url}
_, err := ytdl.exec(cmds...)
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment