Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore(main): some improvment.
1. don't import package as .
2. move all variable of flag to top

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jun 23, 2020
commit 6fc21413b2c035867958a6dbd466ab44f6c935f1
23 changes: 11 additions & 12 deletions youtubedr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ import (
"os/user"
"path/filepath"

. "github.com/kkdai/youtube"
"github.com/kkdai/youtube"
)

const usageString string = `Usage: youtubedr [OPTION] [URL]
Download a video from youtube.
Example: youtubedr -o "Campaign Diary".mp4 https://www.youtube.com/watch\?v\=XbNghLqsVwU
`

var (
outputFile string
outputDir string
outputQuality string
socks5Proxy string
itag int
itags bool
)

func main() {
flag.Usage = func() {
fmt.Println(usageString)
flag.PrintDefaults()
}
usr, _ := user.Current()
var outputFile string
flag.StringVar(&outputFile, "o", "", "The output file")
var outputDir string
flag.StringVar(&outputDir, "d",
filepath.Join(usr.HomeDir, "Movies", "youtubedr"),
"The output directory.")
var outputQuality string
flag.StringVar(&outputQuality, "q", "", "The output file quality (hd720, medium)")

var socks5Proxy string
flag.StringVar(&socks5Proxy, "p", "", "The Socks 5 proxy, e.g. 10.10.10.10:7878")

var itag int
flag.IntVar(&itag, "i", 0, "Specify itag number, e.g. 13, 17")

var itags bool
flag.BoolVar(&itags, "itags", false, "list available itags of video")

flag.Parse()
Expand All @@ -48,7 +48,7 @@ func main() {
}

log.Println("download to dir=", outputDir)
y := NewYoutubeWithSocks5Proxy(true, socks5Proxy)
y := youtube.NewYoutubeWithSocks5Proxy(true, socks5Proxy)
if len(y.Socks5Proxy) == 0 {
log.Println("Using http without proxy.")
}
Expand Down Expand Up @@ -76,5 +76,4 @@ func main() {
fmt.Println("err:", err)
}
}

}