diff --git a/drivers/baidu_photo/help.go b/drivers/baidu_photo/help.go index bf234534c90..e9b9331b7e0 100644 --- a/drivers/baidu_photo/help.go +++ b/drivers/baidu_photo/help.go @@ -4,7 +4,6 @@ import ( "fmt" "math" "math/rand" - "regexp" "strings" "time" @@ -16,11 +15,6 @@ func getTid() string { return fmt.Sprintf("3%d%.0f", time.Now().Unix(), math.Floor(9000000*rand.Float64()+1000000)) } -// 检查名称 -func checkName(name string) bool { - return len(name) <= 50 && regexp.MustCompile("[\u4e00-\u9fa5A-Za-z0-9_-]").MatchString(name) -} - func toTime(t int64) *time.Time { tm := time.Unix(t, 0) return &tm diff --git a/drivers/baidu_photo/utils.go b/drivers/baidu_photo/utils.go index 15761036c65..9715bdbfdf6 100644 --- a/drivers/baidu_photo/utils.go +++ b/drivers/baidu_photo/utils.go @@ -2,7 +2,6 @@ package baiduphoto import ( "context" - "errors" "fmt" "net/http" @@ -22,10 +21,6 @@ const ( FILE_API_URL_V2 = API_URL + "/file/v2" ) -var ( - ErrNotSupportName = errors.New("only chinese and english, numbers and underscores are supported, and the length is no more than 50") -) - func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) { req := base.RestyClient.R(). SetQueryParam("access_token", d.AccessToken) @@ -48,6 +43,8 @@ func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallba return nil, fmt.Errorf("you have joined album") case 50820: return nil, fmt.Errorf("no shared albums found") + case 50100: + return nil, fmt.Errorf("illegal title, only supports 50 characters") case -6: if err = d.refreshToken(); err != nil { return nil, err @@ -188,9 +185,6 @@ func (d *BaiduPhoto) GetAllAlbumFile(ctx context.Context, album *Album, passwd s // 创建相册 func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, error) { - if !checkName(name) { - return nil, ErrNotSupportName - } var resp JoinOrCreateAlbumResp _, err := d.Post(ALBUM_API_URL+"/create", func(r *resty.Request) { r.SetContext(ctx).SetResult(&resp) @@ -208,10 +202,6 @@ func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, erro // 相册改名 func (d *BaiduPhoto) SetAlbumName(ctx context.Context, album *Album, name string) (*Album, error) { - if !checkName(name) { - return nil, ErrNotSupportName - } - _, err := d.Post(ALBUM_API_URL+"/settitle", func(r *resty.Request) { r.SetContext(ctx) r.SetFormData(map[string]string{