go-get-youtube
go-get-youtube copied to clipboard
Example fails with video size returned as 0 Bytes
import (
"fmt"
"strings"
// "errors"
"github.com/pkg/browser"
"github.com/spf13/cobra"
yt "github.com/knadh/go-get-youtube/youtube"
)
func youtubeDownload(url string) error {
video, err := yt.Get(url)
if err != nil {
return err
}
options := &yt.Option{
Rename: true, // rename file using video title
Resume: true, // resume cancelled download
Mp3: true, // extract audio to MP3
}
video.Download(0, "video.mp4", options)
return nil
}
Tried implementing youtube download functionality in my program, but the example is returning empty mp4 files on all videos I have tried including the one in the example. The actual code runs fine and somehow is not throwing any errors. Perhaps there is a missing error check somewhere?
@skekre98 I think you're probably seeing the same issue as #14 . You are indeed missing an error check! video.Download() returns an error, so make sure you're checking for an err when using video.Download(). For example:
err := vid.Download(0, "C:/Users/jsmith/Downloads/video.mp4", options)
if err != nil {
fmt.Println(err)
}
Hope this helps.
@skekre98 I think you're probably seeing the same issue as #14 . You are indeed missing an error check! video.Download() returns an error, so make sure you're checking for an err when using video.Download(). For example:
err := vid.Download(0, "C:/Users/jsmith/Downloads/video.mp4", options) if err != nil { fmt.Println(err) }
Hope this helps.
"unsupported protocol scheme"