package main import ( "context" "flag" "fmt" "log" "git.netflux.io/rob/clipper/youtube" youtubev2 "github.com/kkdai/youtube/v2" ) func main() { var ( verbose bool audioOnly bool videoOnly bool ) flag.BoolVar(&verbose, "v", false, "verbose output") flag.BoolVar(&audioOnly, "audio", false, "only print audio formats") flag.BoolVar(&videoOnly, "video", false, "only print video formats") flag.Parse() videoID := flag.Arg(0) ctx := context.Background() var youtubeClient youtubev2.Client video, err := youtubeClient.GetVideoContext(ctx, videoID) if err != nil { log.Fatal(err) } formats := video.Formats switch { case audioOnly: formats = youtube.SortAudio(formats) case videoOnly: formats = youtube.SortVideo(formats) } fmt.Println("In descending order of preference:") for n, f := range formats { fmt.Printf("%d: %s\n", n+1, youtube.FormatDebugString(&f, verbose)) } }