From 9755a8684819786398e2dea89ac9bfc02faa0bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nojus=20Gudinavi=C4=8Dius?= Date: Wed, 28 Oct 2020 17:30:59 +0200 Subject: [PATCH] Add intent to request and ommit empty recipient fields. Fix #2 --- transfer/download.go | 12 +++++++++--- wedl.go | 5 +++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/transfer/download.go b/transfer/download.go index 4876771..bd1be85 100644 --- a/transfer/download.go +++ b/transfer/download.go @@ -16,8 +16,9 @@ type headers map[string]string type requestData struct { Security_hash string `json:"security_hash"` - Domain_user_id string `json:"domain_user_id"` - RecipientId string `json:"recipient_id"` + Domain_user_id string `json:"domain_user_id,omitempty"` + RecipientId string `json:"recipient_id,omitempty"` + Intent string `json:"intent"` } type transferData struct { @@ -92,7 +93,11 @@ func getDownloadLink(client *http.Client, data transferData) (URL string, err er if URL, ok := result["direct_link"].(string); ok { return URL, nil } - return "", errors.New("Unable to find direct link") + message := "Unable to get direct link" + if e, ok := result["message"].(string); ok { + message += ": " + e + } + return "", errors.New(message) } func getTransferData(resp *http.Response) (out transferData, err error) { @@ -115,6 +120,7 @@ func getTransferData(resp *http.Response) (out transferData, err error) { return out, errors.New("Unable to get domain user id") } out.req_data.RecipientId, _ = findVar(`"recipient_id":"`, body) + out.req_data.Intent = "entire_transfer" if out.wt_session, ok = getCookieValue("_wt_session", resp); !ok { return out, errors.New("Unable to get _wt_session cookie") diff --git a/wedl.go b/wedl.go index 90cd64b..aa6159b 100644 --- a/wedl.go +++ b/wedl.go @@ -2,12 +2,13 @@ package main import ( "fmt" + "os" + "github.com/Nojus297/wedl/cli" "github.com/docopt/docopt-go" - "os" ) -var version string = "v0.1.0" +var version string = "unspecified" func main() { usage := `