1 // yt-mango: YT video metadata archiving utility
2 // Copyright (C) 2018 terorie
7 "github.com/spf13/cobra"
10 "github.com/terorie/yt-mango/cmd"
12 "github.com/terorie/yt-mango/api"
13 "github.com/terorie/yt-mango/net"
16 const Version
= "v0.1 -- dev"
19 // All diagnostics (logging) should go to stderr
20 log
.SetOutput(os
.Stderr
)
24 var concurrentRequests
uint
26 rootCmd
:= cobra
.Command
{
28 Short
: "YT-Mango is a scalable video metadata archiver",
29 Long
: "YT-Mango is a scalable video metadata archiving utility\n" +
30 "written by terorie for https://the-eye.eu/",
31 PreRun
: func(cmd
*cobra
.Command
, args
[]string) {
37 PersistentPreRun
: func(cmd
*cobra
.Command
, args
[]string) {
38 net
.MaxWorkers
= uint32(concurrentRequests
)
41 case "": api
.Main
= &api
.TempAPI
42 case "classic": api
.Main
= &api
.ClassicAPI
43 case "json": api
.Main
= &api
.JsonAPI
45 fmt
.Fprintln(os
.Stderr
, "Invalid API specified.\n" +
46 "Valid options are: \"classic\" and \"json\"")
52 rootCmd
.Flags().BoolVar(&printVersion
, "version", false,
53 fmt
.Sprintf("Print the version (" + Version
+") and exit"))
54 rootCmd
.Flags().StringVarP(&forceAPI
, "api", "a", "",
55 "Use the specified API for all calls.\n" +
56 "Possible options: \"classic\" and \"json\"")
57 rootCmd
.PersistentFlags().UintVarP(&concurrentRequests
, "concurrency", "c", 4,
58 "Number of maximum concurrent HTTP requests")
60 rootCmd
.AddCommand(&cmd
.Channel
)
61 rootCmd
.AddCommand(&cmd
.Video
)
63 if err
:= rootCmd
.Execute(); err
!= nil {
64 fmt
.Fprintln(os
.Stderr
, err
)