go-get-youtube icon indicating copy to clipboard operation
go-get-youtube copied to clipboard

Example fails with video size returned as 0 Bytes

Open skekre98 opened this issue 4 years ago • 2 comments

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 avatar Oct 18 '20 23:10 skekre98

@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.

cofonseca avatar Dec 01 '20 15:12 cofonseca

@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"

incafox avatar Mar 05 '21 04:03 incafox