This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
/
kantv_cli.go
120 lines (115 loc) · 2.95 KB
/
kantv_cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package kantv
import (
"fmt"
"log"
"os"
"github.com/MewX/KanTV-downloader-cli/kantv/util"
"github.com/urfave/cli/v2"
)
// Cli is the entry of the command line interface.
func Cli() {
app := &cli.App{
Name: "KanTV Downloader CLI",
Version: "0.1.0",
Usage: "The downloader for downloading KanTV videos via command line.",
Action: func(c *cli.Context) error {
fmt.Println("Interactive CLI be done!")
return nil
},
Before: func(c *cli.Context) error {
// Initialise all global flags.
util.VerboseMode = c.Bool(FlagVerbose)
return nil
},
// TODO: clear those global flags.
Flags: []cli.Flag{
&cli.BoolFlag{
Name: FlagVerbose,
Usage: "Print all debug information.",
Value: false,
},
&cli.StringFlag{
Name: "email",
Usage: "Your email address registered in Kantv website. Alternatively, you could use mobile phone number.",
},
&cli.StringFlag{
Name: "phone_number",
Usage: "Your phone number registered in Kantv website. Alternatively, you could use email address.",
},
&cli.StringFlag{
Name: "password",
Usage: "Your password for logging in. If not specified, you will be prompted to type your password.",
},
&cli.StringFlag{
Name: "set",
Usage: "Set a configurable item. e.g. outdir=~/kantv",
},
&cli.BoolFlag{
Name: "anonymous",
Usage: "Add this flag to not use your login credentials and keeps anonymous.",
},
&cli.StringFlag{
Name: "proxy",
Usage: "Specify a proxy. http/https/socks5://<address>.",
},
&cli.StringFlag{
Name: "outdir",
Usage: "Output directory. File name will be generated based on the resource you are downloading.",
},
&cli.StringFlag{
Name: "cookies",
Usage: "Specify the cookies.txt file path.",
},
&cli.StringFlag{
Name: "iso_code",
Value: "AU",
Usage: "Specify the country of the account.",
},
},
Commands: []*cli.Command{
CmdCountry,
CmdDownload,
{
Name: "register",
Usage: "Register a new account.",
Action: func(c *cli.Context) error {
// TODO: jump to website for a lazy implementation
fmt.Println("registering.")
return nil
},
},
{
Name: "login",
Usage: "Use your email or phone number to log in.",
Action: func(c *cli.Context) error {
// TODO
fmt.Println("logging in.")
return nil
},
},
{
Name: "info",
Aliases: []string{"config"},
Action: func(c *cli.Context) error {
// TODO: support those flags - n_thread, user_agent, cache_size, max_parallel, max_download_file
fmt.Println("configuring")
return nil
},
},
{
Name: "play",
Aliases: []string{"p", "pl"},
Action: func(c *cli.Context) error {
// TODO
// This option provides the streaming link or link to a local player to play the video directly.
fmt.Println("playing...")
return nil
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}