goydl

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

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

Go to latest
Published: Jul 6, 2017 License: MIT Imports: 11 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goydl

A simple youtube-dl library for go.

CircleCI Go Report Card Sourcegraph

See the main page for youtube-dl for more information.

Get the package

go get github.com/BrianAllred/goydl

Use the code

See the documentation for youtube-dl first to understand what it does and how it does it.

  1. Create a new youtubeDl client:

     youtubeDl := goydl.NewYoutubeDl()
    
  2. The Options object contains the various youtube-dl download parameters:

     youtubeDl.Options.Output.Value = "/path/to/downloads/video.mp3"
     youtubeDl.Options.ExtractAudio.Value = true
     youtubeDl.Options.AudioFormat.Value = "mp3"
    
     // Or update the binary
     youtubeDl.Options.Update.Value = true
    
     // Optional, required if binary is not in $PATH
     youtubeDl.YoutubeDlPath = "/path/to/youtube-dl"
    
  3. Listen to console output (optional, but recommended):

     go io.Copy(os.Stdout, youtubeDl.Stdout)
     go io.Copy(os.Stderr, youtubeDl.Stderr)
    
  4. Start the download:

     cmd, err := youtubeDl.Download("http://videosite.com/videoURL")
    
     if err != nil {
         log.Fatal(err)
     }
    
  5. Check the video's info:

     fmt.Printf("Title: %s\n", youtubeDl.Info.Title)
    
  6. Wait for the download to finish:

     // Synchronously:
     cmd.Wait()
    
     // Asynchronously:
     defer cmd.Wait()
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileSizeRateFromString

func FileSizeRateFromString(fileSizeRateString string) fileSizeRate

FileSizeRateFromString creates a new FileSizeRate from a string

func FileSizeRateFromValues

func FileSizeRateFromValues(sizeRate float64, unit rune) fileSizeRate

FileSizeRateFromValues creates a new FileSizeRate from values (float64, rune)

func NewOptions

func NewOptions() options

Returns a new options object with the various options initialized with their params

func NewYoutubeDl

func NewYoutubeDl() youtubeDl

NewYoutubeDl returns a newly instantiated youtubeDl object

Types

type BoolOption

type BoolOption struct {
	Value bool
	// contains filtered or unexported fields
}

func (BoolOption) OptionString

func (boolOpt BoolOption) OptionString() string

type FileSizeRateOption

type FileSizeRateOption struct {
	Value fileSizeRate
	// contains filtered or unexported fields
}

func (FileSizeRateOption) OptionString

func (fsrOpt FileSizeRateOption) OptionString() string

type Info

type Info struct {
	ID          string      `json:"id"`
	Uploader    string      `json:"uploader"`
	UploaderID  string      `json:"uploader_id"`
	UploaderURL string      `json:"uploader_url"`
	UploadDate  string      `json:"upload_date"`
	License     string      `json:"license"`
	Creator     interface{} `json:"creator"`
	Title       string      `json:"title"`
	AltTitle    interface{} `json:"alt_title"`
	Thumbnail   string      `json:"thumbnail"`
	Description string      `json:"description"`
	Categories  []string    `json:"categories"`
	Tags        []string    `json:"tags"`
	Subtitles   struct {
	} `json:"subtitles"`
	AutomaticCaptions struct {
	} `json:"automatic_captions"`
	Duration      int         `json:"duration"`
	AgeLimit      int         `json:"age_limit"`
	Annotations   interface{} `json:"annotations"`
	Chapters      interface{} `json:"chapters"`
	WebpageURL    string      `json:"webpage_url"`
	ViewCount     int         `json:"view_count"`
	LikeCount     int         `json:"like_count"`
	DislikeCount  int         `json:"dislike_count"`
	AverageRating float64     `json:"average_rating"`
	Formats       []struct {
		Ext         string      `json:"ext"`
		FormatNote  string      `json:"format_note"`
		Acodec      string      `json:"acodec"`
		Abr         int         `json:"abr,omitempty"`
		Container   string      `json:"container,omitempty"`
		FormatID    string      `json:"format_id"`
		URL         string      `json:"url"`
		ManifestURL string      `json:"manifest_url,omitempty"`
		Width       interface{} `json:"width,omitempty"`
		Height      interface{} `json:"height,omitempty"`
		Tbr         float64     `json:"tbr,omitempty"`
		Asr         int         `json:"asr,omitempty"`
		Fps         interface{} `json:"fps,omitempty"`
		Language    interface{} `json:"language,omitempty"`
		Filesize    int         `json:"filesize,omitempty"`
		Vcodec      string      `json:"vcodec"`
		Format      string      `json:"format"`
		Protocol    string      `json:"protocol"`
		HTTPHeaders struct {
			UserAgent      string `json:"User-Agent"`
			AcceptCharset  string `json:"Accept-Charset"`
			Accept         string `json:"Accept"`
			AcceptEncoding string `json:"Accept-Encoding"`
			AcceptLanguage string `json:"Accept-Language"`
		} `json:"http_headers"`
		PlayerURL  string `json:"player_url,omitempty"`
		Resolution string `json:"resolution,omitempty"`
	} `json:"formats"`
	IsLive             interface{} `json:"is_live"`
	StartTime          interface{} `json:"start_time"`
	EndTime            interface{} `json:"end_time"`
	Series             interface{} `json:"series"`
	SeasonNumber       interface{} `json:"season_number"`
	EpisodeNumber      interface{} `json:"episode_number"`
	Extractor          string      `json:"extractor"`
	WebpageURLBasename string      `json:"webpage_url_basename"`
	ExtractorKey       string      `json:"extractor_key"`
	Playlist           interface{} `json:"playlist"`
	PlaylistIndex      interface{} `json:"playlist_index"`
	Thumbnails         []struct {
		URL string `json:"url"`
		ID  string `json:"id"`
	} `json:"thumbnails"`
	DisplayID          string      `json:"display_id"`
	RequestedSubtitles interface{} `json:"requested_subtitles"`
	RequestedFormats   []struct {
		Ext         string      `json:"ext"`
		Height      int         `json:"height,omitempty"`
		FormatNote  string      `json:"format_note"`
		Vcodec      string      `json:"vcodec"`
		FormatID    string      `json:"format_id"`
		URL         string      `json:"url"`
		ManifestURL string      `json:"manifest_url,omitempty"`
		Width       int         `json:"width,omitempty"`
		Tbr         float64     `json:"tbr"`
		Asr         interface{} `json:"asr,omitempty"`
		Fps         int         `json:"fps,omitempty"`
		Language    interface{} `json:"language,omitempty"`
		Filesize    int         `json:"filesize"`
		Acodec      string      `json:"acodec"`
		Format      string      `json:"format"`
		Protocol    string      `json:"protocol"`
		HTTPHeaders struct {
			UserAgent      string `json:"User-Agent"`
			AcceptCharset  string `json:"Accept-Charset"`
			Accept         string `json:"Accept"`
			AcceptEncoding string `json:"Accept-Encoding"`
			AcceptLanguage string `json:"Accept-Language"`
		} `json:"http_headers"`
		PlayerURL string `json:"player_url,omitempty"`
		Abr       int    `json:"abr,omitempty"`
	} `json:"requested_formats"`
	Format         string      `json:"format"`
	FormatID       string      `json:"format_id"`
	Width          int         `json:"width"`
	Height         int         `json:"height"`
	Resolution     interface{} `json:"resolution"`
	Fps            int         `json:"fps"`
	Vcodec         string      `json:"vcodec"`
	Vbr            interface{} `json:"vbr"`
	StretchedRatio interface{} `json:"stretched_ratio"`
	Acodec         string      `json:"acodec"`
	Abr            int         `json:"abr"`
	Ext            string      `json:"ext"`
	Fulltitle      string      `json:"fulltitle"`
	Filename       string      `json:"_filename"`
}

Info is an object representing the JSON returned from a -J download (dump-single-json)

type IntOption

type IntOption struct {
	Value int
	// contains filtered or unexported fields
}

func (IntOption) OptionString

func (intOpt IntOption) OptionString() string

type IpOption

type IpOption struct {
	Value net.IP
	// contains filtered or unexported fields
}

func (IpOption) OptionString

func (ipOpt IpOption) OptionString() string

type Option

type Option interface {
	OptionString() string
}

Option interface represents a CLI parameter that can be passed to youtube-dl The String method returns what would be passed to youtube-dl

type StringArrayOption

type StringArrayOption struct {
	Values []string
	// contains filtered or unexported fields
}

func (StringArrayOption) OptionString

func (stringArrOpt StringArrayOption) OptionString() string

type StringOption

type StringOption struct {
	Value string
	// contains filtered or unexported fields
}

func (StringOption) OptionString

func (stringOpt StringOption) OptionString() string

type TimeOption

type TimeOption struct {
	Value time.Time
	// contains filtered or unexported fields
}

func (TimeOption) OptionString

func (timeOpt TimeOption) OptionString() string

type UintOption

type UintOption struct {
	Value uint
	// contains filtered or unexported fields
}

func (UintOption) OptionString

func (uintOpt UintOption) OptionString() string

Jump to

Keyboard shortcuts

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