Skip to content

Commit

Permalink
Updated to v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Feb 25, 2022
1 parent e28939b commit ec1fc16
Show file tree
Hide file tree
Showing 6 changed files with 699 additions and 88 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ or
Use go get.

```bash
$ go get -u github.com/tanaikech/goodls
$ go install github.com/tanaikech/goodls@latest
```

- `GO111MODULE=on`

# Usage

<a name="downloadsharedfiles"></a>
Expand Down Expand Up @@ -355,4 +357,10 @@ If you have any questions and commissions for me, feel free to tell me.

1. Recently, it seems that the specification the process for downloading the shared file on Google Drive has been changed. So I updated goodls for reflecting this. The usage of goodls is not changed.

<a name="v130"></a>

- v2.0.0 (February 25, 2022)

1. By changing the specification of methods, `drive.New()` and `transport.APIKey` were deprecated. By this, I updated [go-getfilelist](https://github.com/tanaikech/go-getfilelist). In this version, I used this updated library to goodls. And also, `drive.NewService()` is used instead of `drive.New()`.

[TOP](#top)
20 changes: 7 additions & 13 deletions getfilesfromfolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand All @@ -17,7 +18,7 @@ import (

getfilelist "github.com/tanaikech/go-getfilelist"
drive "google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi/transport"
"google.golang.org/api/option"
)

const (
Expand All @@ -32,14 +33,6 @@ func mime2ext(mime string) string {
return res
}

// ext2mime : Convert extension to mimeType.
func ext2mime(ext string) string {
var obj map[string]interface{}
json.Unmarshal([]byte(extVsmime), &obj)
res, _ := obj[ext].(string)
return res
}

// downloadFileByAPIKey : Download file using API key.
func (p *para) downloadFileByAPIKey(file *drive.File) error {
u, err := url.Parse(driveAPI)
Expand Down Expand Up @@ -280,14 +273,15 @@ func (p *para) dupChkFoldersFiles(fileList *getfilelist.FileListDl) {

// getFilesFromFolder: This method is the main method for downloading all files in a shread folder.
func (p *para) getFilesFromFolder() error {
client := &http.Client{
Transport: &transport.APIKey{Key: p.APIKey},
srv, err := drive.NewService(context.Background(), option.WithAPIKey(p.APIKey))
if err != nil {
return err
}
fileList, err := func() (*getfilelist.FileListDl, error) {
if len(p.InputtedMimeType) > 0 {
return getfilelist.Folder(p.SearchID).MimeType(p.InputtedMimeType).Do(client)
return getfilelist.Folder(p.SearchID).MimeType(p.InputtedMimeType).Do(srv)
}
return getfilelist.Folder(p.SearchID).Do(client)
return getfilelist.Folder(p.SearchID).Do(srv)
}()
if err != nil {
return err
Expand Down
29 changes: 29 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module github.com/tanaikech/goodls

go 1.17

require (
github.com/tanaikech/go-getfilelist v2.0.0+incompatible
github.com/urfave/cli v1.22.5
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
google.golang.org/api v0.70.0
)

require (
cloud.google.com/go/compute v1.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
Loading

0 comments on commit ec1fc16

Please sign in to comment.