sunsheng 8 months ago
parent
commit
e91df9a167
4 changed files with 1 additions and 219 deletions
  1. 0 170
      src/api/huawei.go
  2. 0 30
      src/api/utils.go
  3. 1 2
      src/go.mod
  4. 0 17
      src/go.sum

+ 0 - 170
src/api/huawei.go

@@ -1,170 +0,0 @@
-package api
-
-import (
-	"errors"
-	"fmt"
-	"spu3d/log"
-	"strings"
-
-	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
-	mpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1"
-	hwmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1/model"
-	region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1/region"
-)
-
-var (
-	Ak                = "RA1D7CFVCVKUFX1FHHPB"
-	Endpoint          = "mpc.cn-east-3.myhuaweicloud.com"
-	Sk                = "cDrR2NgAF2KaA4MRkcK19r93P3P6hLKOPhHvPu9p"
-	SourceObjectUrl   = "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queenshow/"
-	VideoThumbnailUrl = "https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/thumb-video/"
-)
-
-func NewHwClient() *mpc.MpcClient {
-	ak := Ak
-	sk := Sk
-
-	auth := basic.NewCredentialsBuilder().
-		WithAk(ak).
-		WithSk(sk).
-		Build()
-
-	return mpc.NewMpcClient(
-		mpc.MpcClientBuilder().
-			WithRegion(region.ValueOf("cn-east-3")).
-			WithCredential(auth).
-			Build())
-
-}
-
-func VideoThumbnails(videoURL string) (string, error) {
-	request := &hwmodel.CreateThumbnailsTaskRequest{}
-	var listDotsThumbnailPara = []int32{
-		int32(2),
-	}
-	_thum := strings.Split(videoURL, "/")
-	videoFileName := _thum[len(_thum)-1]
-	thumImageName := fmt.Sprintf("%s%s", strings.Split(videoFileName, ".")[0], ".jpg")
-	fmt.Println(videoFileName)
-	outputFilenameThumbnailPara := thumImageName
-
-	typeThumbnailPara := hwmodel.GetThumbnailParaTypeEnum().DOTS
-	thumbnailParabody := &hwmodel.ThumbnailPara{
-		Type:           &typeThumbnailPara,
-		Dots:           &listDotsThumbnailPara,
-		OutputFilename: &outputFilenameThumbnailPara,
-	}
-	outputbody := &hwmodel.ObsObjInfo{
-		Bucket:   "sku3d-test",
-		Location: "cn-east-3",
-		Object:   "thumb-video", // jpg
-	}
-	outPutImageUrl := fmt.Sprintf("%s%s", VideoThumbnailUrl, thumImageName)
-
-	inputbody := &hwmodel.ObsObjInfo{
-		Bucket:   "sku3d-test",
-		Location: "cn-east-3",
-		Object:   "queenshow/" + videoFileName, // mp4地址
-	}
-	request.Body = &hwmodel.CreateThumbReq{
-		ThumbnailPara: thumbnailParabody,
-		Output:        outputbody,
-		Input:         inputbody,
-	}
-	client := NewHwClient()
-	if client != nil {
-		res, err := client.CreateThumbnailsTask(request)
-		if err != nil {
-			log.Error(err)
-			fmt.Println(err)
-			return "", errors.New("视频截图失败!")
-		}
-		log.Infof("视频截图[%s]=>taskId:", videoURL, *res.TaskId)
-
-	} else {
-		return "", errors.New("获取华为客户端错误")
-	}
-	return outPutImageUrl, nil
-}
-
-type VideoCutParams struct {
-	SourceVideoUrl string
-	DestVideoName  string
-	Start          string
-	End            string
-}
-
-type VideoCutOutRes struct {
-	Url   string `json:"url"`
-	JobId string `json:"jobId"`
-}
-
-func VideoCutOut(params *VideoCutParams) (VideoCutOutRes, error) {
-	_thum := strings.Split(params.SourceVideoUrl, "/")
-	sourceVideoName := _thum[len(_thum)-1]
-	request := &hwmodel.CreateEditingJobRequest{}
-	// 不带后缀
-	fileNameOutput := params.DestVideoName
-	outputOutputSetting := &hwmodel.ObsObjInfo{
-		Bucket:   "sku3d-test",
-		Location: "cn-east-3",
-		Object:   "queenshow",
-		FileName: &fileNameOutput,
-	}
-	outputSettingbody := &hwmodel.OutputSetting{
-		Output: outputOutputSetting,
-	}
-	inputClips := &hwmodel.ObsObjInfo{
-		Bucket:   "sku3d-test",
-		Location: "cn-east-3",
-		Object:   "queenshow/" + sourceVideoName,
-	}
-	timelineStartClips := params.Start
-	timelineEndClips := params.End
-	var listClipsbody = []hwmodel.ClipInfo{
-		{
-			Input:         inputClips,
-			TimelineStart: &timelineStartClips,
-			TimelineEnd:   &timelineEndClips,
-		},
-	}
-	var listEditTypebody = []string{
-		"CLIP",
-	}
-	request.Body = &hwmodel.CreateEditingJobReq{
-		OutputSetting: outputSettingbody,
-		Clips:         &listClipsbody,
-		EditType:      &listEditTypebody,
-	}
-	outPutVideoUrl := fmt.Sprintf("%s%s.mp4", SourceObjectUrl, fileNameOutput)
-	client := NewHwClient()
-	jobId := ""
-	if client != nil {
-		res, err := client.CreateEditingJob(request)
-		if err != nil {
-			log.Error(err)
-			fmt.Println(err)
-			return VideoCutOutRes{}, errors.New("视频裁剪失败!")
-		}
-		jobId = *res.JobId
-		log.Infof("视频裁剪[%s]=>jobId:", params.SourceVideoUrl, *res.JobId)
-
-	} else {
-		return VideoCutOutRes{}, errors.New("获取华为客户端错误!")
-	}
-	return VideoCutOutRes{Url: outPutVideoUrl, JobId: jobId}, nil
-}
-
-// 查询裁剪任务
-func QueryByJobId(jobId string) (*hwmodel.ListEditingJobResponse, error) {
-	client := NewHwClient()
-	if client == nil {
-		return nil, errors.New("获取华为客户端错误!")
-	}
-	request := &hwmodel.ListEditingJobRequest{}
-	var listJobId = []string{
-		jobId,
-	}
-	request.JobId = &listJobId
-	return client.ListEditingJob(request)
-}

+ 0 - 30
src/api/utils.go

@@ -9,36 +9,6 @@ import (
 	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
-type UserInfo struct {
-	Id       primitive.ObjectID
-	IsSystem bool
-	// 是不是自己查询自己
-	IsOwner bool
-	Scope   string // queenshow spu3d
-}
-
-var SystemCategoryUserId = "64b0e7409d7adb3612011fa1"
-
-const IPV6_API = "https://api.vore.top/api/IPv6?v6="
-const IPV4_API = "https://api.vore.top/api/IPv4?v4="
-
-type IPVRes struct {
-	Msg    string  `json:"msg"`
-	IpData *IpArea `json:"ipdata"`
-}
-
-type IpArea struct {
-	Province string `json:"info1"`
-	City     string `json:"info2"`
-	District string `json:"info3"`
-	Isp      string `json:"isp"`
-}
-
-type IpInfo struct {
-	Ip string `json:"ip"`
-	IPVRes
-}
-
 func getUserRole(_ *gin.Context, apictx *ApiSession) ([]string, error) {
 	if apictx.User != nil {
 		userId, _ := primitive.ObjectIDFromHex(apictx.User.Parent)

+ 1 - 2
src/go.mod

@@ -18,7 +18,7 @@ require (
 
 require (
 	github.com/nats-io/nats.go v1.22.1 // indirect
-	gopkg.in/yaml.v3 v3.0.1 // indirect
+	github.com/stretchr/testify v1.8.4 // indirect
 )
 
 require (
@@ -42,7 +42,6 @@ require (
 	github.com/hashicorp/errwrap v1.1.0 // indirect
 	github.com/hashicorp/go-multierror v1.1.1 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
-	github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.49
 	github.com/jessevdk/go-flags v1.5.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect

+ 0 - 17
src/go.sum

@@ -700,8 +700,6 @@ github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn
 github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
 github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
-github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.49 h1:y/H5T7c0dJC/f+izhe4lFj2PL1sJaYscSu9+y48HR8U=
-github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.49/go.mod h1:bsqx6o47Kl4YsniIjPwuoeqiIB5Fc3JbSpB2b3o3WFQ=
 github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
@@ -1132,8 +1130,6 @@ github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
-github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
-github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -1141,8 +1137,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
@@ -1350,7 +1344,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
-golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1420,9 +1413,7 @@ golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qx
 golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
-golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
 golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -1583,8 +1574,6 @@ golang.org/x/sys v0.0.0-20220317061510-51cd9980dadf/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
 golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
@@ -1592,9 +1581,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
-golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
-golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1606,7 +1592,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
 golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
 golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1701,7 +1686,6 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
-golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
 golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1921,7 +1905,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
-gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg=
 gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
 gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=