This package is a Youtube video download package, for more detail refer https://github.com/rg3/youtube-dl for more download option.
- Parse the video ID you input in URL
- ex:
https://www.youtube.com/watch?v=rFejpH_tAHM
, the video id isrFejpH_tAHM
- ex:
- Get video information via video id.
- Use URL:
http://youtube.com/get_video_info?video_id=
- Use URL:
- Parse and decode video information.
- Download URL in "url="
- title in "title="
- Need sinature in "sig="
- Download video from URL
- Need the string combination of "url+sig"
go get github.com/kkdai/youtube
package main
import (
"flag"
"fmt"
"log"
"os/user"
"path/filepath"
. "github.com/kkdai/youtube"
)
func main() {
flag.Parse()
log.Println(flag.Args())
usr, _ := user.Current()
currentDir := fmt.Sprintf("%v/Movies/youtubedr", usr.HomeDir)
log.Println("download to dir=", currentDir)
y := NewYoutube(true)
arg := flag.Arg(0)
if err := y.DecodeURL(arg); err != nil {
fmt.Println("err:", err)
}
if err := y.StartDownload(filepath.Join(currentDir, "dl.mp4")); err != nil {
fmt.Println("err:", err)
}
}
go get github.com/kkdai/youtube/youtubedr
Download video from dotGo 2015 - Rob Pike - Simplicity is Complicated
youtubedr https://www.youtube.com/watch?v=rFejpH_tAHM
It is one of my project 52.
This package is licensed under MIT license. See LICENSE for details.