Skip to content

Commit

Permalink
remove csrf token and change username
Browse files Browse the repository at this point in the history
  • Loading branch information
gnojus committed May 9, 2023
1 parent 25a3a4b commit 285de0d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# wedl
[![Test latest release](https://github.com/nojus297/wedl/actions/workflows/test.yml/badge.svg)](https://github.com/nojus297/wedl/actions/workflows/test.yml)
[![Test latest release](https://github.com/gnojus/wedl/actions/workflows/test.yml/badge.svg)](https://github.com/gnojus/wedl/actions/workflows/test.yml)

## Command line utility to download from wetransfer
Easily download from wetransfer.com in the command line.
Expand All @@ -25,15 +25,15 @@ Options:
```

## Instaling
Download binaries from [here](https://github.com/nojus297/wedl/releases).
Download binaries from [here](https://github.com/gnojus/wedl/releases).

Or compile from source:
```bash
$ git clone https://github.com/nojus297/wedl.git
$ git clone https://github.com/gnojus/wedl.git
$ cd wedl
$ make
```
Or just go get:
```bash
$ go get github.com/nojus297/wedl
```
$ go get github.com/gnojus/wedl
```
4 changes: 2 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"

"github.com/cheggaaa/pb"
"github.com/nojus297/wedl/transfer"
"github.com/gnojus/wedl/transfer"
)

func Eval(opts map[string]interface{}) (err error) {
Expand Down Expand Up @@ -52,4 +52,4 @@ func Eval(opts map[string]interface{}) (err error) {
io.Copy(writer, resp.Body)
}
return
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/nojus297/wedl
module github.com/gnojus/wedl

go 1.18

Expand Down
8 changes: 1 addition & 7 deletions transfer/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type requestData struct {

type transferData struct {
transferId string
csrfToken string
wtSession string
reqData requestData
}
Expand Down Expand Up @@ -82,7 +81,6 @@ func FilenameFromUrl(URL string) string {
func getDownloadLink(client *http.Client, data transferData) (URL string, err error) {
url := fmt.Sprintf("%s/transfers/%s/download", baseApi, data.transferId)
req, err := createRequest("POST", url, headers{
"X-CSRF-Token": data.csrfToken,
"content-type": "application/json",
"X-Requested-With": "XMLHttpRequest",
}, data.reqData)
Expand Down Expand Up @@ -118,11 +116,10 @@ func getDownloadLink(client *http.Client, data transferData) (URL string, err er

func getTransferData(resp *http.Response) (out transferData, err error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
return
}
var ok bool
matches := urlRegex.FindStringSubmatch(resp.Request.URL.String())
if len(matches) < 4 {
return out, errors.New("Unable to parse download url")
Expand All @@ -131,9 +128,6 @@ func getTransferData(resp *http.Response) (out transferData, err error) {
out.reqData.RecipientId = matches[3]
out.reqData.SecurityHash = matches[4]

if out.csrfToken, ok = findVar(`<meta name="csrf-token" content="`, body); !ok {
return out, errors.New("Unable to get csrf token")
}
out.reqData.Intent = "entire_transfer"

return
Expand Down
4 changes: 2 additions & 2 deletions wedl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/docopt/docopt-go"
"github.com/nojus297/wedl/cli"
"github.com/gnojus/wedl/cli"
)

var version string = "unspecified"
Expand All @@ -32,4 +32,4 @@ Options:
}
os.Exit(1)
}
}
}

0 comments on commit 285de0d

Please sign in to comment.