From 79184ff28f03d57f8b83a9fc283ca0ca31b091f4 Mon Sep 17 00:00:00 2001 From: xiaozhou26 Date: Wed, 27 Dec 2023 16:52:51 +0800 Subject: [PATCH] Change aliyundrive.com to alipan.com to support ipv6 acceleration --- README.md | 4 ++-- README_cn.md | 4 ++-- README_ja.md | 4 ++-- drivers/aliyundrive/driver.go | 22 +++++++++++----------- drivers/aliyundrive/util.go | 16 ++++++++-------- drivers/aliyundrive_open/meta.go | 2 +- drivers/aliyundrive_share/driver.go | 8 ++++---- drivers/aliyundrive_share/util.go | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 5f4d8ef4270..ef68e01656b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ English | [中文](./README_cn.md)| [日本語](./README_ja.md) | [Contributing] - [x] Multiple storages - [x] Local storage - - [x] [Aliyundrive](https://www.aliyundrive.com/) + - [x] [Aliyundrive](https://www.alipan.com/) - [x] OneDrive / Sharepoint ([global](https://www.office.com/), [cn](https://portal.partner.microsoftonline.cn),de,us) - [x] [189cloud](https://cloud.189.cn) (Personal, Family) - [x] [GoogleDrive](https://drive.google.com/) @@ -66,7 +66,7 @@ English | [中文](./README_cn.md)| [日本語](./README_ja.md) | [Contributing] - [x] [Quark](https://pan.quark.cn) - [x] [Thunder](https://pan.xunlei.com) - [x] [Lanzou](https://www.lanzou.com/) - - [x] [Aliyundrive share](https://www.aliyundrive.com/) + - [x] [Aliyundrive share](https://www.alipan.com/) - [x] [Google photo](https://photos.google.com/) - [x] [Mega.nz](https://mega.nz) - [x] [Baidu photo](https://photo.baidu.com/) diff --git a/README_cn.md b/README_cn.md index 6af8aeaf1af..a5dfab47f45 100644 --- a/README_cn.md +++ b/README_cn.md @@ -45,7 +45,7 @@ - [x] 多种存储 - [x] 本地存储 - - [x] [阿里云盘](https://www.aliyundrive.com/) + - [x] [阿里云盘](https://www.alipan.com/) - [x] OneDrive / Sharepoint([国际版](https://www.office.com/), [世纪互联](https://portal.partner.microsoftonline.cn),de,us) - [x] [天翼云盘](https://cloud.189.cn) (个人云, 家庭云) - [x] [GoogleDrive](https://drive.google.com/) @@ -65,7 +65,7 @@ - [x] [夸克网盘](https://pan.quark.cn) - [x] [迅雷网盘](https://pan.xunlei.com) - [x] [蓝奏云](https://www.lanzou.com/) - - [x] [阿里云盘分享](https://www.aliyundrive.com/) + - [x] [阿里云盘分享](https://www.alipan.com/) - [x] [谷歌相册](https://photos.google.com/) - [x] [Mega.nz](https://mega.nz) - [x] [一刻相册](https://photo.baidu.com/) diff --git a/README_ja.md b/README_ja.md index b873947fc86..3bcdd8de3d5 100644 --- a/README_ja.md +++ b/README_ja.md @@ -45,7 +45,7 @@ - [x] マルチストレージ - [x] ローカルストレージ - - [x] [Aliyundrive](https://www.aliyundrive.com/) + - [x] [Aliyundrive](https://www.alipan.com/) - [x] OneDrive / Sharepoint ([グローバル](https://www.office.com/), [cn](https://portal.partner.microsoftonline.cn),de,us) - [x] [189cloud](https://cloud.189.cn) (Personal, Family) - [x] [GoogleDrive](https://drive.google.com/) @@ -66,7 +66,7 @@ - [x] [Quark](https://pan.quark.cn) - [x] [Thunder](https://pan.xunlei.com) - [x] [Lanzou](https://www.lanzou.com/) - - [x] [Aliyundrive share](https://www.aliyundrive.com/) + - [x] [Aliyundrive share](https://www.alipan.com/) - [x] [Google photo](https://photos.google.com/) - [x] [Mega.nz](https://mega.nz) - [x] [Baidu photo](https://photo.baidu.com/) diff --git a/drivers/aliyundrive/driver.go b/drivers/aliyundrive/driver.go index 83c3f522452..eab38f58e1c 100644 --- a/drivers/aliyundrive/driver.go +++ b/drivers/aliyundrive/driver.go @@ -52,7 +52,7 @@ func (d *AliDrive) Init(ctx context.Context) error { return err } // get driver id - res, err, _ := d.request("https://api.aliyundrive.com/v2/user/get", http.MethodPost, nil, nil) + res, err, _ := d.request("https://api.alipan.com/v2/user/get", http.MethodPost, nil, nil) if err != nil { return err } @@ -106,7 +106,7 @@ func (d *AliDrive) Link(ctx context.Context, file model.Obj, args model.LinkArgs "file_id": file.GetID(), "expire_sec": 14400, } - res, err, _ := d.request("https://api.aliyundrive.com/v2/file/get_download_url", http.MethodPost, func(req *resty.Request) { + res, err, _ := d.request("https://api.alipan.com/v2/file/get_download_url", http.MethodPost, func(req *resty.Request) { req.SetBody(data) }, nil) if err != nil { @@ -114,14 +114,14 @@ func (d *AliDrive) Link(ctx context.Context, file model.Obj, args model.LinkArgs } return &model.Link{ Header: http.Header{ - "Referer": []string{"https://www.aliyundrive.com/"}, + "Referer": []string{"https://www.alipan.com/"}, }, URL: utils.Json.Get(res, "url").ToString(), }, nil } func (d *AliDrive) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error { - _, err, _ := d.request("https://api.aliyundrive.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { + _, err, _ := d.request("https://api.alipan.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "check_name_mode": "refuse", "drive_id": d.DriveId, @@ -139,7 +139,7 @@ func (d *AliDrive) Move(ctx context.Context, srcObj, dstDir model.Obj) error { } func (d *AliDrive) Rename(ctx context.Context, srcObj model.Obj, newName string) error { - _, err, _ := d.request("https://api.aliyundrive.com/v3/file/update", http.MethodPost, func(req *resty.Request) { + _, err, _ := d.request("https://api.alipan.com/v3/file/update", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "check_name_mode": "refuse", "drive_id": d.DriveId, @@ -156,7 +156,7 @@ func (d *AliDrive) Copy(ctx context.Context, srcObj, dstDir model.Obj) error { } func (d *AliDrive) Remove(ctx context.Context, obj model.Obj) error { - _, err, _ := d.request("https://api.aliyundrive.com/v2/recyclebin/trash", http.MethodPost, func(req *resty.Request) { + _, err, _ := d.request("https://api.alipan.com/v2/recyclebin/trash", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "drive_id": d.DriveId, "file_id": obj.GetID(), @@ -216,7 +216,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, streamer model.Fil } var resp UploadResp - _, err, e := d.request("https://api.aliyundrive.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { + _, err, e := d.request("https://api.alipan.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { req.SetBody(reqBody) }, &resp) @@ -270,7 +270,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, streamer model.Fil n, _ := io.NewSectionReader(localFile, o.Int64(), 8).Read(buf[:8]) reqBody["proof_code"] = base64.StdEncoding.EncodeToString(buf[:n]) - _, err, e := d.request("https://api.aliyundrive.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { + _, err, e := d.request("https://api.alipan.com/adrive/v2/file/createWithFolders", http.MethodPost, func(req *resty.Request) { req.SetBody(reqBody) }, &resp) if err != nil && e.Code != "PreHashMatched" { @@ -309,7 +309,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, streamer model.Fil } } var resp2 base.Json - _, err, e = d.request("https://api.aliyundrive.com/v2/file/complete", http.MethodPost, func(req *resty.Request) { + _, err, e = d.request("https://api.alipan.com/v2/file/complete", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "drive_id": d.DriveId, "file_id": resp.FileId, @@ -334,10 +334,10 @@ func (d *AliDrive) Other(ctx context.Context, args model.OtherArgs) (interface{} } switch args.Method { case "doc_preview": - url = "https://api.aliyundrive.com/v2/file/get_office_preview_url" + url = "https://api.alipan.com/v2/file/get_office_preview_url" data["access_token"] = d.AccessToken case "video_preview": - url = "https://api.aliyundrive.com/v2/file/get_video_preview_play_info" + url = "https://api.alipan.com/v2/file/get_video_preview_play_info" data["category"] = "live_transcoding" data["url_expire_sec"] = 14400 default: diff --git a/drivers/aliyundrive/util.go b/drivers/aliyundrive/util.go index b36900fb964..0e81b082bb9 100644 --- a/drivers/aliyundrive/util.go +++ b/drivers/aliyundrive/util.go @@ -26,7 +26,7 @@ func (d *AliDrive) createSession() error { state.retry = 0 return fmt.Errorf("createSession failed after three retries") } - _, err, _ := d.request("https://api.aliyundrive.com/users/v1/users/device/create_session", http.MethodPost, func(req *resty.Request) { + _, err, _ := d.request("https://api.alipan.com/users/v1/users/device/create_session", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "deviceName": "samsung", "modelName": "SM-G9810", @@ -42,7 +42,7 @@ func (d *AliDrive) createSession() error { } // func (d *AliDrive) renewSession() error { -// _, err, _ := d.request("https://api.aliyundrive.com/users/v1/users/device/renew_session", http.MethodPost, nil, nil) +// _, err, _ := d.request("https://api.alipan.com/users/v1/users/device/renew_session", http.MethodPost, nil, nil) // return err // } @@ -58,7 +58,7 @@ func (d *AliDrive) sign() { // do others that not defined in Driver interface func (d *AliDrive) refreshToken() error { - url := "https://auth.aliyundrive.com/v2/account/token" + url := "https://auth.alipan.com/v2/account/token" var resp base.TokenResp var e RespErr _, err := base.RestyClient.R(). @@ -85,7 +85,7 @@ func (d *AliDrive) request(url, method string, callback base.ReqCallback, resp i req := base.RestyClient.R() state, ok := global.Load(d.UserID) if !ok { - if url == "https://api.aliyundrive.com/v2/user/get" { + if url == "https://api.alipan.com/v2/user/get" { state = &State{} } else { return nil, fmt.Errorf("can't load user state, user_id: %s", d.UserID), RespErr{} @@ -94,8 +94,8 @@ func (d *AliDrive) request(url, method string, callback base.ReqCallback, resp i req.SetHeaders(map[string]string{ "Authorization": "Bearer\t" + d.AccessToken, "content-type": "application/json", - "origin": "https://www.aliyundrive.com", - "Referer": "https://aliyundrive.com/", + "origin": "https://www.alipan.com", + "Referer": "https://alipan.com/", "X-Signature": state.signature, "x-request-id": uuid.NewString(), "X-Canary": "client=Android,app=adrive,version=v4.1.0", @@ -158,7 +158,7 @@ func (d *AliDrive) getFiles(fileId string) ([]File, error) { "video_thumbnail_process": "video/snapshot,t_0,f_jpg,ar_auto,w_300", "url_expire_sec": 14400, } - _, err, _ := d.request("https://api.aliyundrive.com/v2/file/list", http.MethodPost, func(req *resty.Request) { + _, err, _ := d.request("https://api.alipan.com/v2/file/list", http.MethodPost, func(req *resty.Request) { req.SetBody(data) }, &resp) @@ -172,7 +172,7 @@ func (d *AliDrive) getFiles(fileId string) ([]File, error) { } func (d *AliDrive) batch(srcId, dstId string, url string) error { - res, err, _ := d.request("https://api.aliyundrive.com/v3/batch", http.MethodPost, func(req *resty.Request) { + res, err, _ := d.request("https://api.alipan.com/v3/batch", http.MethodPost, func(req *resty.Request) { req.SetBody(base.Json{ "requests": []base.Json{ { diff --git a/drivers/aliyundrive_open/meta.go b/drivers/aliyundrive_open/meta.go index bd69211c77e..de9b45e01d6 100644 --- a/drivers/aliyundrive_open/meta.go +++ b/drivers/aliyundrive_open/meta.go @@ -36,7 +36,7 @@ var config = driver.Config{ func init() { op.RegisterDriver(func() driver.Driver { return &AliyundriveOpen{ - base: "https://openapi.aliyundrive.com", + base: "https://openapi.alipan.com", } }) } diff --git a/drivers/aliyundrive_share/driver.go b/drivers/aliyundrive_share/driver.go index 2e042ceef35..db2ff9ace16 100644 --- a/drivers/aliyundrive_share/driver.go +++ b/drivers/aliyundrive_share/driver.go @@ -105,7 +105,7 @@ func (d *AliyundriveShare) link(ctx context.Context, file model.Obj) (*model.Lin "share_id": d.ShareId, } var resp ShareLinkResp - _, err := d.request("https://api.aliyundrive.com/v2/file/get_share_link_download_url", http.MethodPost, func(req *resty.Request) { + _, err := d.request("https://api.alipan.com/v2/file/get_share_link_download_url", http.MethodPost, func(req *resty.Request) { req.SetHeader(CanaryHeaderKey, CanaryHeaderValue).SetBody(data).SetResult(&resp) }) if err != nil { @@ -113,7 +113,7 @@ func (d *AliyundriveShare) link(ctx context.Context, file model.Obj) (*model.Lin } return &model.Link{ Header: http.Header{ - "Referer": []string{"https://www.aliyundrive.com/"}, + "Referer": []string{"https://www.alipan.com/"}, }, URL: resp.DownloadUrl, }, nil @@ -128,9 +128,9 @@ func (d *AliyundriveShare) Other(ctx context.Context, args model.OtherArgs) (int } switch args.Method { case "doc_preview": - url = "https://api.aliyundrive.com/v2/file/get_office_preview_url" + url = "https://api.alipan.com/v2/file/get_office_preview_url" case "video_preview": - url = "https://api.aliyundrive.com/v2/file/get_video_preview_play_info" + url = "https://api.alipan.com/v2/file/get_video_preview_play_info" data["category"] = "live_transcoding" default: return nil, errs.NotSupport diff --git a/drivers/aliyundrive_share/util.go b/drivers/aliyundrive_share/util.go index a29f86f5522..899e15cec1b 100644 --- a/drivers/aliyundrive_share/util.go +++ b/drivers/aliyundrive_share/util.go @@ -16,7 +16,7 @@ const ( ) func (d *AliyundriveShare) refreshToken() error { - url := "https://auth.aliyundrive.com/v2/account/token" + url := "https://auth.alipan.com/v2/account/token" var resp base.TokenResp var e ErrorResp _, err := base.RestyClient.R(). @@ -47,7 +47,7 @@ func (d *AliyundriveShare) getShareToken() error { var resp ShareTokenResp _, err := base.RestyClient.R(). SetResult(&resp).SetError(&e).SetBody(data). - Post("https://api.aliyundrive.com/v2/share_link/get_share_token") + Post("https://api.alipan.com/v2/share_link/get_share_token") if err != nil { return err } @@ -116,7 +116,7 @@ func (d *AliyundriveShare) getFiles(fileId string) ([]File, error) { SetHeader("x-share-token", d.ShareToken). SetHeader(CanaryHeaderKey, CanaryHeaderValue). SetResult(&resp).SetError(&e).SetBody(data). - Post("https://api.aliyundrive.com/adrive/v3/file/list") + Post("https://api.alipan.com/adrive/v3/file/list") if err != nil { return nil, err }