Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cli.Command{ Name: "youtube", Usage: "Interact with YouTube", Subcommands: []*cli.Command{CmdDownload, CmdCut}, }
View Source
var CmdCut = &cli.Command{ Name: "cut", Usage: "Crop YouTube video", Flags: cutFlags, Action: func(ctx *cli.Context) error { params, err := getDownloadParams(ctx) if err != nil { return err } videoFile, _, err := download.YouTube(ctx.Context, params) if err != nil { if e, ok := err.(errors.BusinessError); ok && e.ErrorCode == download.ErrExist.ErrorCode { pterm.Warning.Println(e.Error()) } else { return err } } pterm.Success.Printfln("Done: %s", videoFile.NameRelative()) cfg := config.Ctx(ctx.Context) start := ctx.Duration("start") finish := ctx.Duration("finish") cutParams, err := cfg.Cut.Apply(cut.Params{ Source: videoFile.Filename, Start: start, Finish: finish, }) if err != nil { return err } croppedFile, err := cut.Video(ctx.Context, cutParams) if err != nil { return err } pterm.Success.Printfln("Done: %s", croppedFile.NameRelative()) if ctx.Bool("extract-audio") { extractParams, err := cfg.Audio.Apply(audios.Params{ Source: croppedFile.Filename, }) if err != nil { return err } audioFile, err := audios.Extract(ctx.Context, extractParams) if err != nil { return err } pterm.Success.Printfln("Done: %s", audioFile.NameRelative()) } if err == nil { pterm.Success.Printfln("All done") } return err }, }
View Source
var CmdDownload = &cli.Command{ Name: "download", Usage: "Download a video from YouTube", Flags: []cli.Flag{ &cli.StringFlag{ Name: "output_dir", }, &cli.StringFlag{ Name: "quality", }, &cli.StringFlag{ Name: "mime_type", }, }, Action: func(ctx *cli.Context) error { params, err := getDownloadParams(ctx) if err != nil { return err } _, _, err = download.YouTube(ctx.Context, params) if err != nil { return err } pterm.Success.Println("Done") return err }, }
View Source
var ErrorMissingSourceArgument = errors.Business("Missing 'source' arg (eg.: https://www.youtube.com/watch?v=8yAbX8W3Caw)", "DCD:001") //nolint:lll
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.