-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
|
||
const ( | ||
appname = "goodls" | ||
envval = "GOODLS_APIKEY" | ||
anyurl = "https://drive.google.com/uc?export=download" | ||
docutl = "https://docs.google.com/" | ||
) | ||
|
@@ -138,6 +139,13 @@ func (p *para) getFilename(s *http.Response) error { | |
// downloadLargeFile : When a large size of file is downloaded, this method is used. | ||
func (p *para) downloadLargeFile() error { | ||
fmt.Println("Now downloading.") | ||
if p.APIKey != "" { | ||
dlfile, err := p.getFileInfFromP() | ||
if err != nil { | ||
return err | ||
} | ||
p.Size = dlfile.Size | ||
} | ||
res, err := p.fetch(p.URL + "&confirm=" + p.Code) | ||
if err != nil { | ||
return err | ||
|
@@ -298,6 +306,9 @@ func handler(c *cli.Context) { | |
WorkDir: workdir, | ||
DlFolder: false, | ||
} | ||
if envv := os.Getenv(envval); c.String("apikey") == "" && envv != "" { | ||
p.APIKey = strings.TrimSpace(envv) | ||
} | ||
if terminal.IsTerminal(int(syscall.Stdin)) { | ||
if c.String("url") == "" { | ||
createHelp().Run(os.Args) | ||
|
@@ -344,7 +355,7 @@ func createHelp() *cli.App { | |
a.Author = "tanaike [ https://github.com/tanaikech/" + appname + " ] " | ||
a.Email = "[email protected]" | ||
a.Usage = "Download shared files on Google Drive." | ||
a.Version = "1.2.0" | ||
a.Version = "1.2.1" | ||
a.Flags = []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "url, u", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters