You need to enable JavaScript to run this app.
导航
媒资管理
最近更新时间:2024.10.28 15:41:54首次发布时间:2021.02.23 10:42:40

本文为您提供了服务端 Go SDK 的媒资管理模块的接口调用示例。

前提条件

调用接口前,请先完成 SDK 的安装初始化

调用示例

获取媒资信息

接口请求参数和返回参数详见 OpenAPI:获取媒资信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_GetMediaInfos20230701(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodGetMediaInfosRequest{
                Vids: "your Vids",
        }

        resp, status, err := instance.GetMediaInfos20230701(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

更新媒资信息

接口请求参数和返回参数详见 OpenAPI:更新媒资信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_UpdateMediaInfo(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateMediaInfoRequest{
                Vid:              "your Vid",
                PosterUri:        nil,
                Title:            nil,
                Description:      nil,
                Tags:             nil,
                ClassificationId: nil,
                ExpireTime:       nil,
        }

        resp, status, err := instance.UpdateMediaInfo(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

修改媒资发布状态

接口请求参数和返回参数详见 OpenAPI:修改媒资发布状态

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_UpdateMediaPublishStatus(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateMediaPublishStatusRequest{
                Vid:    "your Vid",
                Status: "your Status",
        }

        resp, status, err := instance.UpdateMediaPublishStatus(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

修改媒资存储类型

接口请求参数和返回参数详见 OpenAPI:修改媒资存储类型

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_UpdateMediaStorageClass(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateMediaStorageClassRequest{
                Vids:         "your Vids",
                FileIds:      "your FileIds",
                StorageClass: "your StorageClass",
                CallbackArgs: "your CallbackArgs",
        }

        resp, status, err := instance.UpdateMediaStorageClass(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

获取封面候选结果

接口请求参数和返回参数详见 OpenAPI:获取封面候选结果

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_GetRecommendedPoster(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodGetRecommendedPosterRequest{
                Vids: "your Vids",
        }

        resp, status, err := instance.GetRecommendedPoster(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

删除完整媒资

接口请求参数和返回参数详见 OpenAPI:批量删除完整媒资

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_DeleteMedia(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDeleteMediaRequest{
                Vids:         "your Vids",
                CallbackArgs: "your CallbackArgs",
        }

        resp, status, err := instance.DeleteMedia(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

删除媒体处理输出文件

接口请求参数和返回参数详见 OpenAPI:删除媒体处理输出文件

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_DeleteTranscodes(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDeleteTranscodesRequest{
                Vid:          "your Vid",
                FileIds:      "your FileIds",
                CallbackArgs: "your CallbackArgs",
        }

        resp, status, err := instance.DeleteTranscodes(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

删除素材文件

接口请求参数和返回参数说明详见删除素材文件

func Test_DeleteMaterial(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDeleteMaterialRequest{
                Mid:       "your Mid",
                SpaceName: "your SpaceName",
        }

        resp, status, err := instance.DeleteMaterial(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

获取音视频信息

接口请求参数和返回参数详见 OpenAPI:获取音视频信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_GetMediaList(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodGetMediaListRequest{
                SpaceName:         "your SpaceName",
                Vid:               "your Vid",
                Status:            "your Status",
                Order:             "your Order",
                Tags:              "your Tags",
                StartTime:         "your StartTime",
                EndTime:           "your EndTime",
                Offset:            "your Offset",
                PageSize:          "your PageSize",
                ClassificationIds: "your ClassificationIds",
                TosStorageClasses: "your TosStorageClasses",
                VodUploadSources:  "your VodUploadSources",
        }

        resp, status, err := instance.GetMediaList(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

获取字幕文件

接口请求参数和返回参数详见 OpenAPI:获取字幕文件

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_GetSubtitleInfoList(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodGetSubtitleInfoListRequest{
                Vid:         "your Vid",
                FileIds:     "your FileIds",
                Languages:   "your Languages",
                Formats:     "your Formats",
                LanguageIds: "your LanguageIds",
                SubtitleIds: "your SubtitleIds",
                Status:      "your Status",
                Title:       "your Title",
                Tag:         "your Tag",
                Offset:      "your Offset",
                PageSize:    "your PageSize",
                Ssl:         "your Ssl",
        }

        resp, status, err := instance.GetSubtitleInfoList(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

修改字幕发布状态

接口请求参数和返回参数详见 OpenAPI:修改字幕发布状态

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)


func Test_UpdateSubtitleStatus(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateSubtitleStatusRequest{
                Vid:       "your Vid",
                FileIds:   "your FileIds",
                Languages: "your Languages",
                Formats:   "your Formats",
                Status:    "your Status",
        }

        resp, status, err := instance.UpdateSubtitleStatus(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

更新字幕信息

接口请求参数和返回参数详见 OpenAPI:更新字幕信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_UpdateSubtitleInfo(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateSubtitleInfoRequest{
                Vid:      "your Vid",
                FileId:   "your FileId",
                Language: "your Language",
                Format:   "your Format",
                Title:    nil,
                Tag:      nil,
        }

        resp, status, err := instance.UpdateSubtitleInfo(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

签发字幕鉴权 Token

func TestVod_GetSubtitleAuthToken(t *testing.T) {
        instance := vod.NewInstance()
        // call below method if you dont set ak and sk in ~/.volc/config
        //vod.NewInstance().SetCredential(base.Credentials{
        //        AccessKeyID:     "your ak",
        //        SecretAccessKey: "your sk",
        //})
        // or set ak and ak as follow
        // instance.SetAccessKey("")
        // instance.SetSecretKey("")

        // Media Info
        query := &request.VodGetSubtitleInfoListRequest{
                Vid: "your search vid",
        }
        expireSeconds := 100 // expire time duration: (s)
        token, err := instance.GetSubtitleAuthToken(query, expireSeconds)
        fmt.Println("token ===> ", token)
        fmt.Println("err ===> ", err)
}

获取截图结果

接口请求参数和返回参数详见 OpenAPI:获取截图结果

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_ListSnapshots(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodListSnapshotsRequest{
                Vid: "your Vid",
        }

        resp, status, err := instance.ListSnapshots(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

提交跨空间文件迁移任务

接口请求参数和返回参数详见 OpenAPI:提交跨空间文件迁移任务

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func TestSubmitMoveObjectTask(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodSubmitMoveObjectTaskRequest{
                SourceSpace:      "sourceSpace",
                SourceFileName:   "sourceFileName",
                TargetSpace:      "targetSpace",
                TargetFileName:   "",
                SaveSourceObject: false,
                ForceOverwrite:   false,
        }

        resp, status, err := instance.SubmitMoveObjectTask(query)
        if err != nil {
                fmt.Println(err)
        }

        fmt.Println(status)
        fmt.Println(resp.String())

}

查询跨空间文件迁移任务状态

接口请求参数和返回参数详见 OpenAPI:查询跨空间文件迁移任务状态

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_QueryMoveObjectTaskInfo(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodQueryMoveObjectTaskInfoRequest{
                TaskId:      "dd76ff82ac254***8ac7b5a20def3bbe",
                SourceSpace: "sourceSpace",
                TargetSpace: "targetSpace",
        }

        resp, status, err := instance.QueryMoveObjectTaskInfo(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

媒资分类

创建视频分类

接口请求参数和返回参数详见 OpenAPI:创建视频分类

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_CreateVideoClassification(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodCreateVideoClassificationRequest{
                SpaceName:      "your SpaceName",
                Level:          0,
                ParentId:       0,
                Classification: "your Classification",
        }

        resp, status, err := instance.CreateVideoClassification(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

查询视频分类

接口请求参数和返回参数详见 OpenAPI:查询视频分类

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_ListVideoClassifications(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodListVideoClassificationsRequest{
                SpaceName:        "your SpaceName",
                ClassificationId: 0,
        }

        resp, status, err := instance.ListVideoClassifications(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

更新视频分类

接口请求参数和返回参数详见 OpenAPI:更新视频分类

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)


func Test_UpdateVideoClassification(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateVideoClassificationRequest{
                SpaceName:        "your SpaceName",
                ClassificationId: 0,
                Classification:   "your Classification",
        }

        resp, status, err := instance.UpdateVideoClassification(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

删除视频分类

接口请求参数和返回参数详见 OpenAPI:删除视频分类

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_DeleteVideoClassification(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDeleteVideoClassificationRequest{
                SpaceName:        "your SpaceName",
                ClassificationId: 0,
        }

        resp, status, err := instance.DeleteVideoClassification(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

DirectUrl 模式

根据文件路径获取文件信息

接口请求参数和返回参数详见 OpenAPI:根据文件路径获取文件信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_GetFileInfos(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodGetFileInfosRequest{
                SpaceName:        "your SpaceName",
                EncodedFileNames: "your EncodedFileNames",
                BucketName:       "your BucketName",
        }

        resp, status, err := instance.GetFileInfos(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

根据文件路径获取媒资信息

接口请求参数和返回参数详见 OpenAPI:根据文件路径获取媒资信息

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_ListFileMetaInfosByFileNames(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodListFileMetaInfosByFileNamesRequest{
                SpaceName:        "your SpaceName",
                FileNameEncodeds: "your FileNameEncodeds",
                BucketName:       "your BucketName",
        }

        resp, status, err := instance.ListFileMetaInfosByFileNames(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

根据文件路径修改媒资存储类型

接口请求参数和返回参数详见 OpenAPI:根据文件路径修改媒资存储类型

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_UpdateFileStorageClass(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodUpdateFileStorageClassRequest{
                SpaceName:       "your SpaceName",
                FileUpdateInfos: nil,
                BucketName:      "your BucketName",
        }

        resp, status, err := instance.UpdateFileStorageClass(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}

根据文件路径删除媒体文件

接口请求参数和返回参数详见 OpenAPI:根据文件路径删除媒体文件

package vod

import (
        "fmt"
        "testing"

        "github.com/volcengine/volc-sdk-golang/base"
        "github.com/volcengine/volc-sdk-golang/service/vod"
        "github.com/volcengine/volc-sdk-golang/service/vod/models/request"
)

func Test_DeleteMediaTosFile(t *testing.T) {
        // Create a VOD instance in the specified region.
        // instance := vod.NewInstanceWithRegion("cn-north-1")
        instance := vod.NewInstance()

        // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see  https://www.volcengine.com/docs/4/65655.
        // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
        // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
        // instance.SetCredential(base.Credentials{
        // AccessKeyID:     "your ak",
        // SecretAccessKey: "your sk",
        //})

        query := &request.VodDeleteMediaTosFileRequest{
                FileNames: []string{"your FileNames"},
                SpaceName: "your SpaceName",
        }

        resp, status, err := instance.DeleteMediaTosFile(query)
        fmt.Println(status)
        fmt.Println(err)
        fmt.Println(resp.String())
}