Skip to content

Commit

Permalink
Updated to v1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Aug 21, 2020
1 parent 06b8221 commit 3c78fe8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ $ goodls -u [URL of shared file on Google Drive]
- `https://docs.google.com/presentation/d/#####/edit?usp=sharing`
- In the case of except for Google Docs
- `https://drive.google.com/file/d/#####/view?usp=sharing`
- In the case of webContentLink
- `https://drive.google.com/uc?export=download&id=###`

### File with several URLs

Expand Down Expand Up @@ -335,4 +337,10 @@ If you have any questions and commissions for me, feel free to tell me.
1. When the files are downloaded from the shared folder, if an error occurs, the download was stopped. In [this thread](https://github.com/tanaikech/goodls/issues/9), a request for skipping this error was proposed. This request was implemented at v1.2.6. Please try the option of `--skiperror` like below.
- `$ goodls -u https://drive.google.com/drive/folders/###?usp=sharing --skiperror`

<a name="v127"></a>

- v1.2.7 (August 21, 2020)

1. As the URL for downloading the files, `webContentLink` was added. So from this version, the URL of `https://drive.google.com/uc?export=download&id=###` got to be able to be used. This is the request from [this thread](https://github.com/tanaikech/goodls/issues/13).

[TOP](#top)
19 changes: 18 additions & 1 deletion goodls.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"mime"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -189,6 +190,7 @@ func (p *para) fetch(url string) (*http.Response, error) {
func (p *para) checkURL(s string) error {
var err error
r := regexp.MustCompile(`google\.com\/(\w.+)\/d\/(\w.+)\/`)
r2 := regexp.MustCompile(`drive.google.com\/uc\?(export\=\w+|id\=([\w\S]+))&(export\=\w+|id\=([\w\S]+))`)
if r.MatchString(s) {
res := r.FindAllStringSubmatch(s, -1)
p.Kind = res[0][1]
Expand Down Expand Up @@ -220,6 +222,21 @@ func (p *para) checkURL(s string) error {
}
return nil
}
} else if r2.MatchString(s) {
u, err := url.Parse(s)
if err != nil {
return err
}
q := u.Query()
p.Kind = "file"
p.ID = q["id"][0]
p.URL = anyurl + "&id=" + p.ID
if p.APIKey != "" && p.ShowFileInf {
if err := p.showFileInf(); err != nil {
return err
}
return nil
}
} else {
folder := regexp.MustCompile(`google\.com\/drive\/folders\/([a-zA-Z0-9-_]+)`)
if folder.MatchString(s) {
Expand Down Expand Up @@ -364,7 +381,7 @@ func createHelp() *cli.App {
{Name: "tanaike [ https://github.com/tanaikech/" + appname + " ] ", Email: "[email protected]"},
}
a.UsageText = "Download shared files on Google Drive."
a.Version = "1.2.6"
a.Version = "1.2.7"
a.Flags = []cli.Flag{
&cli.StringFlag{
Name: "url, u",
Expand Down

0 comments on commit 3c78fe8

Please sign in to comment.