savevideo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiveBroadcastContentLive      = "live"
	LiveBroadcastContentCompleted = "completed"
	LiveBroadcastContentNone      = "none"
	LiveBroadcastContentUpcoming  = "upcoming"

	DefaultTemplateName = "ytfeed-savestream-filename"

	DownloadingVideoStatus = true

	DefaultTemporaryDownloadDirectoryPermission = 0755

	ErrFileAlreadyExistsFormat = "file %s already exists"
)
View Source
const (
	ErrInvalidVideoQuality   = "invalid video quality: %s"
	ErrInvalidVideoExtension = "invalid video extension: %s"

	// for regular video
	// youtube-dl -f "bestvideo[ext=%s][height=%s]+bestaudio[ext=%s]" --merge-output-format ext -o temporaryfiledir/randomname url
	// for live download
	// youtube-dl -f "[height=%s]" -o temporaryfiledir/randomname https://www.youtube.com/watch?v=yF2va6QbnOs
	YoutubeDLCommand         = "youtube-dl"
	FormatArg                = "-f"
	FormatArgValueFormat     = "bestvideo[ext=%s][height=%s]+bestaudio[ext=%s]"
	FormatArgValueLiveFormat = "[height=%s]"
	MergeOutputFormatArg     = "--merge-output-format"
	OutputArg                = "-o"

	AudioM4A  = "m4a"
	AudioWebm = "webm"
	AudioMP4  = "mp4"

	ExtensionMP4  = "mp4"
	ExtensionWebm = "webm"
	ExtensionMKV  = "mkv"

	Quality1080 = "1080"
	Quality720  = "720"
	Quality640  = "640"
	Quality480  = "480"
	Quality360  = "360"
	Quality240  = "240"
	Quality144  = "144"
)

Variables

This section is empty.

Functions

func IsErrorAlreadyExists

func IsErrorAlreadyExists(err error) bool

Types

type DataSaver

type DataSaver interface {
	SaveAs(ctx context.Context, name string, r io.Reader) (int64, error)
	Delete(ctx context.Context, name string) error
	Exists(ctx context.Context, name string) (bool, error)
}

type Entry

type Entry struct {
	Author                         string
	LinkURL                        string
	Title                          string
	VideoID                        string
	ChannelID                      string
	Published                      string
	PublishedYear                  int
	PublishedMonth                 string
	PublishedDay                   int
	PublishedHour                  int
	PublishedMinute                int
	PublishedSecond                int
	PublishedNanosecond            int
	PublishedTimeZone              string
	PublishedTimeZoneOffsetSeconds int
	VideoExtension                 string
	VideoQuality                   string
}

type FilenameTemplater

type FilenameTemplater interface {
	Execute(w io.Writer, data interface{}) error
}

type SaveVideo

type SaveVideo struct {
	// contains filtered or unexported fields
}

func New

func New(
	logger ytfeed.Logger, vs YoutubeVideoLister, dataSaver DataSaver,
	tmpDir, filenameTemplate, quality, ext string,
) (s *SaveVideo, err error)

func (*SaveVideo) DataHandler

func (s *SaveVideo) DataHandler(ctx context.Context, d *ytfeed.Data)

func (*SaveVideo) DownloadVideo

func (s *SaveVideo) DownloadVideo(ctx context.Context, videoName, url, quality, ext string, isLive bool, dataSaver DataSaver) (err error)

func (*SaveVideo) DownloadVideoWithRetries

func (s *SaveVideo) DownloadVideoWithRetries(ctx context.Context, retryDelay time.Duration, maxRetries int, videoName, url, quality, ext string, isLive bool, dataSaver DataSaver) (err error)

func (*SaveVideo) SetRetries

func (s *SaveVideo) SetRetries(retryDelay time.Duration, maxRetries int)

SetRetry because retries is optional, it doesn't have to be present at constructor function

func (*SaveVideo) SetStreamScheduler

func (s *SaveVideo) SetStreamScheduler(sc StreamScheduler)

SetStreamScheduler because stream scheduler is optional, it doesn't have to be present at constructor function

type StreamScheduler

type StreamScheduler interface {
	RegisterSchedule(runAt time.Time, data *ytfeed.Data) error
}

type YoutubeVideoLister

type YoutubeVideoLister interface {
	List(part []string) *youtube.VideosListCall
}

Jump to

Keyboard shortcuts

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