From fcfd4acd74c983663c3bb15cc9be4fd1035ad9ec Mon Sep 17 00:00:00 2001 From: Galiley Date: Wed, 16 Aug 2023 11:58:20 +0200 Subject: [PATCH] edit default value --- goutubedl.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/goutubedl.go b/goutubedl.go index 7ee38f7..7475010 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -434,8 +434,7 @@ type DownloadResult struct { // Download is a shortcut of DownloadOptions where the options use the default value func (result Result) Download(ctx context.Context, filter string) (*DownloadResult, error) { return result.DownloadWithOptions(ctx, DownloadOptions{ - Filter: filter, - PlaylistIndex: -1, + Filter: filter, }) } @@ -444,15 +443,14 @@ type DownloadOptions struct { // If filter is empty, then youtube-dl will use its default format selector. Filter string // The index of the entry to download from the playlist that would be - // passed to youtube-dl wia --playlist-items. - // The index value starts at 1 + // passed to youtube-dl wia --playlist-items. The index value starts at 1 PlaylistIndex int } func (result Result) DownloadWithOptions(ctx context.Context, options DownloadOptions) (*DownloadResult, error) { debugLog := result.Options.DebugLog - if (result.Info.Type == "playlist" || result.Info.Type == "multi_video") && options.PlaylistIndex < 0 { + if (result.Info.Type == "playlist" || result.Info.Type == "multi_video") && options.PlaylistIndex == 0 { return nil, fmt.Errorf("can't download a playlist when the playlist index options is not set") } @@ -487,7 +485,7 @@ func (result Result) DownloadWithOptions(ctx context.Context, options DownloadOp cmd.Args = append(cmd.Args, "-f", options.Filter) } - if options.PlaylistIndex >= 0 { + if options.PlaylistIndex > 0 { cmd.Args = append(cmd.Args, "--playlist-items", fmt.Sprint(options.PlaylistIndex)) }