youtube

package module
v0.0.0-...-e1f4efb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2018 License: MIT Imports: 11 Imported by: 1

README

Download Youtube Video in Golang

GitHub license GoDoc Build Status

This package is a Youtube video download package, for more detail refer https://github.com/rg3/youtube-dl for more download option.

How it works

  • Parse the video ID you input in URL
    • ex: https://www.youtube.com/watch?v=rFejpH_tAHM, the video id is rFejpH_tAHM
  • Get video information via video id.
    • Use URL: http://youtube.com/get_video_info?video_id=
  • 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"

Install

go get github.com/kkdai/youtube

Usage


package main

import (
	"flag"
	"log"
	"os"
	"path/filepath"

	. "github.com/kkdai/youtube"
)

func main() {
	currentFile, _ := filepath.Abs(os.Args[0])
	log.Println("download to file=", currentFile)

	// NewYoutube(debug) if debug parameter will set true we can log of messages
	y := NewYoutube(true)
	y.DecodeURL("https://www.youtube.com/watch?v=rFejpH_tAHM")
	y.StartDownload(currentFile)
}

Use the binary directly

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

Inspired

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogOutput

func SetLogOutput(w io.Writer)

Types

type Youtube

type Youtube struct {
	DebugMode  bool
	StreamList []stream
	VideoID    string

	DownloadPercent chan int64
	// contains filtered or unexported fields
}

func NewYoutube

func NewYoutube(debug bool) *Youtube

func (*Youtube) DecodeURL

func (y *Youtube) DecodeURL(url string) error

func (*Youtube) GetDownloadUrl

func (y *Youtube) GetDownloadUrl() string

func (*Youtube) StartDownload

func (y *Youtube) StartDownload(destFile string) error

func (*Youtube) Write

func (y *Youtube) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL