You need to enable JavaScript to run this app.
导航

媒资管理

最近更新时间2023.11.21 19:30:46

首次发布时间2021.02.23 10:42:40

本文为您提供了服务端 Go SDK 的媒资管理模块相关的 API 调用示例。主要包含: 查询媒资信息、修改媒资信息、修改媒资发布状态、获取封面候选结果、批量删除完整媒资、删除媒体文件、获取音视频列表等。

初始化

使用前请先完成初始化,参考初始化

查询媒资信息

接口请求参数和返回参数详见 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_GetMediaInfos(t *testing.T) {
        instance := vod.NewInstance()
        instance.SetCredential(base.Credentials{
                AccessKeyID:     "your ak",
                SecretAccessKey: "your sk",
        })

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

        resp, status, err := instance.GetMediaInfos(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) {
        instance := vod.NewInstance()
        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,
        }

        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) {
        instance := vod.NewInstance()
        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_GetRecommendedPoster(t *testing.T) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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())
}

获取音视频列表

接口请求参数和返回参数详见 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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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())
}

获取截图结果

接口请求参数和返回参数详见 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) {
        instance := vod.NewInstance()
        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 Test_CreateVideoClassification(t *testing.T) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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) {
        instance := vod.NewInstance()
        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())
}

修改媒资存储类型

接口请求参数和返回参数详见 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) {
        instance := vod.NewInstance()
        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_ListFileMetaInfosByFileNames(t *testing.T) {
        instance := vod.NewInstance()
        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())
}