goutube

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

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

Go to latest
Published: May 30, 2015 License: MIT Imports: 9 Imported by: 0

README

Goutube

Go library to get download links for Youtube videos.

Features

  • Extracts links for below formats:
    • video/webm
    • video/mp4
    • video/x-flv
    • video/3gpp
    • audio/webm
    • audio/mp4 (MPEG)

Installation

go get github.com/sreejithr/goutube

Usage

Below is the barebones basic.

import "github.com/sreejithr/goutube"

// Channel to report failure
errorChan := make(chan error)

resultChan := goutube.Youtube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

for _, link := range <-resultChan {
	// `link` is a struct btw
	fmt.Println(link)
}

With error management.

// Channel to report failure
errorChan := make(chan error)

resultChan := goutube.Youtube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

select {
case links := <-resultChan:
    for _, link := range <-resultChan {
    	fmt.Println(link)
    }
case err := <-errorChan:
    fmt.Println(err)
}

API

Constants
type MediaType int
const (
	VIDEO MediaType = iota
	AUDIO
)
func Youtube

func Youtube(link string, err chan error) result chan Link

Get download links for the given youtube url. Might return multiple links of different quality and format. Check Type of link which maybe goutube.VIDEO or goutube.AUDIO

type Link struct {
	URL          string
	Type         MediaType
	Signature    string
	Quality      string
	Format       MediaFormat
}
type MediaFormat
type MediaFormat struct {
	Type         string
	VideoCodec   string
	AudioCodec   string
	Raw          string
}

TODO

  • Better error management (especially in network outage).
  • Download from minified URLs.
  • Return file size of each link.
  • Download all videos from a page (embedded in pages and Youtube search results)
  • Download whole playlists.

Contributing

  • Can I?

    • Yes, please :)
  • How?

    • Feel free to post issues, take up issues, ask questions, propose features.
  • I'm new to open source. So...

    • Learn Git.
    • Fork the repo.
    • Make pull request.
    • Welcome aboard :)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptSignature

func DecryptSignature(args YoutubeConfigArgs, signature string) (string, error)

func ExtractJSHelperObject

func ExtractJSHelperObject(args YoutubeConfigArgs, sigBody string) string

func ExtractJSSignatureFunc

func ExtractJSSignatureFunc(args YoutubeConfigArgs) string

func Youtube

func Youtube(link string, errorChan chan error) <-chan []Link

Types

type Link struct {
	URL       string
	Type      MediaType
	Signature string
	Quality   string
	Format    MediaFormat
}
func GetLinks(args YoutubeConfigArgs) ([]Link, error)

func (Link) String

func (t Link) String() string

type MediaFormat

type MediaFormat struct {
	Type       string
	VideoCodec string
	AudioCodec string
	Raw        string
}

type MediaType

type MediaType int
const (
	VIDEO MediaType = iota
	AUDIO
)

func (MediaType) String

func (t MediaType) String() string

type Result

type Result struct {
	Done  chan bool
	Error chan error
	Links []Link
}

type YoutubeConfigArgs

type YoutubeConfigArgs struct {
	VideoID           string
	VideoFormats      string
	VideoAdaptFormats string
	VideoManifestURL  string
	PlayerSource      string
}

func GetYoutubeConfigArgs

func GetYoutubeConfigArgs(link string) (YoutubeConfigArgs, error)

Jump to

Keyboard shortcuts

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