From 285de0d3984e94c70a6e0a766cba6d75a8dbe561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nojus=20Gudinavi=C4=8Dius?= Date: Tue, 9 May 2023 11:50:59 +0200 Subject: [PATCH] remove csrf token and change username --- README.md | 10 +++++----- cli/cli.go | 4 ++-- go.mod | 2 +- transfer/download.go | 8 +------- wedl.go | 4 ++-- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a2c464d..06c4f49 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 +``` \ No newline at end of file diff --git a/cli/cli.go b/cli/cli.go index 2485525..3ef8969 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -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) { @@ -52,4 +52,4 @@ func Eval(opts map[string]interface{}) (err error) { io.Copy(writer, resp.Body) } return -} +} \ No newline at end of file diff --git a/go.mod b/go.mod index 2d00492..67547e5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nojus297/wedl +module github.com/gnojus/wedl go 1.18 diff --git a/transfer/download.go b/transfer/download.go index e244776..7c31e5e 100644 --- a/transfer/download.go +++ b/transfer/download.go @@ -25,7 +25,6 @@ type requestData struct { type transferData struct { transferId string - csrfToken string wtSession string reqData requestData } @@ -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) @@ -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") @@ -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(`