All Products
Search
Document Center

Media asset management

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see InitVodClient.

Search for media asset information

For more information about the request and response parameters, see SearchMedia.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MySearchMedia(client *vod.Client) (response *vod.SearchMediaResponse, err error) {
    request := vod.CreateSearchMediaRequest()
    request.Fields = "Title,CoverURL,Status"
    request.Match = "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')"
    request.PageNo = "1"
    request.PageSize = "10"
    request.SearchType = "video"
    request.SortBy = "CreationTime:Desc"
    request.AcceptFormat = "JSON"

    return client.SearchMedia(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MySearchMedia(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    //fmt.Println(response.MediaList)
}

Obtain video information

For more information about the request and response parameters, see GetVideoInfo.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetVideoInfo(client *vod.Client) (response *vod.GetVideoInfoResponse, err error) {
    request := vod.CreateGetVideoInfoRequest()
    request.VideoId = "<videoId>"
    request.AcceptFormat = "JSON"

    return client.GetVideoInfo(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetVideoInfo(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    //fmt.Println(response.Video)
}

Obtain the information about multiple videos

For more information about the request and response parameters, see GetVideoInfos.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetVideoInfos(client *vod.Client) (response *vod.GetVideoInfosResponse, err error) {
    request := vod.CreateGetVideoInfosRequest()
    request.VideoIds = "VideoId1,VideoId2"
    request.AcceptFormat = "JSON"

    return client.GetVideoInfos(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetVideoInfos(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.NonExistVideoIds)
    //fmt.Println(response.VideoList)
}

Modify video information

For more information about the request and response parameters, see UpdateVideoInfo.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyUpdateVideoInfo(client *vod.Client) (response *vod.UpdateVideoInfoResponse, err error) {
    request := vod.CreateUpdateVideoInfoRequest()
    request.VideoId = "<videoId>"
    request.Title = "new Title"
    request.Description = "new Description"
    request.Tags = "new Tag1,new Tag2"
    request.AcceptFormat = "JSON"

    return client.UpdateVideoInfo(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyUpdateVideoInfo(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}

Modify the information about multiple videos

For more information about the request and response parameters, see UpdateVideoInfos.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
    "encoding/json"
)

func MyUpdateVideoInfos(client *vod.Client) (response *vod.UpdateVideoInfosResponse, err error) {
    request := vod.CreateUpdateVideoInfosRequest()

    updateContent := []map[string]interface{}{}
    updateItem1 := map[string]interface{}{"VideoId":"<VideoId1>", "Title":"New Title 1", "Tags": "NewTag1,NewTag2"} 
    updateItem2 := map[string]interface{}{"VideoId":"<VideoId2>", "Title":"New Title 2", "Tags": "NewTag1,NewTag2"} 
    updateContent = append(updateContent, updateItem1, updateItem2)
    jsonContent, err := json.Marshal(updateContent)
    if err ! = nil {
        fmt.Println("json.Marshal failed:", err)
        return
    }
    request.UpdateContent = string(jsonContent)
    request.AcceptFormat = "JSON"

    return client.UpdateVideoInfos(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyUpdateVideoInfos(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.NonExistVideoIds)
    fmt.Println(response.RequestId)
}

Delete videos

For more information about the request and response parameters, see DeleteVideo.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyDeleteVideo(client *vod.Client) (response *vod.DeleteVideoResponse, err error) {
    request := vod.CreateDeleteVideoRequest()
    // Specifies one or more IDs of the videos to be deleted. Separate multiple video IDs with a comma (,).
    request.VideoIds = "VideoId1,VideoId2"
    request.AcceptFormat = "JSON"

    return client.DeleteVideo(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyDeleteVideo(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}

Obtain mezzanine file information (including the mezzanine file download URL)

For more information about the request and response parameters, see GetMezzanineInfo.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetMezzanineInfo(client *vod.Client) (response *vod.GetMezzanineInfoResponse, err error) {
    request := vod.CreateGetMezzanineInfoRequest()
    request.VideoId = "<VideoId>"
    request.AuthTimeout = "86400"
    //request.OutputType = "oss"
    request.AcceptFormat = "JSON"

    return client.GetMezzanineInfo(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetMezzanineInfo(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    fmt.Println(response.Mezzanine.FileURL)
}

Obtain a video list

For more information about the request and response parameters, see GetVideoList.

Note: Set the time parameters to UTC time. China Standard Time (UTC+8) is 8 hours ahead of UTC time. For example, a value of 2018-01-01T12:00:00Z indicates 20:00:00 on January 1, 2018, China Standard Time.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetVideoList(client *vod.Client) (response *vod.GetVideoListResponse, err error) {
    request := vod.CreateGetVideoListRequest()
    request.StartTime = "2018-12-01T06:00:00Z"
    request.EndTime = "2018-12-25T06:00:00Z"
    //request.Status = "Uploading,Normal,Transcoding"
    request.PageNo = "1"
    request.PageSize = "10"
    request.SortBy = "CreationTime:Desc"
    request.AcceptFormat = "JSON"

    return client.GetVideoList(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetVideoList(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    videoList := response.VideoList.Video
    for _, video := range videoList {
        fmt.Printf("%s: %s\n", video.VideoId, video.Title)
    }
}

Delete media streams

For more information about the request and response parameters, see DeleteStream.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyDeleteStream(client *vod.Client) (response *vod.DeleteStreamResponse, err error) {
    request := vod.CreateDeleteStreamRequest()
    request.VideoId = "<VideoId>"
    request.JobIds = "JobId1,JobId2"
    request.AcceptFormat = "JSON"

    return client.DeleteStream(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
    if err ! = nil {
        panic(err)
    }

    response, err := MyDeleteStream(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}

Delete multiple mezzanine files

For more information about the request and response parameters, see DeleteMezzanines.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyDeleteMezzanines(client *vod.Client) (response *vod.DeleteMezzaninesResponse, err error) {
    request := vod.CreateDeleteMezzaninesRequest()
    request.VideoIds = "VideoId1,VideoId2"
    request.Force = "false"
    request.AcceptFormat = "JSON"

    return client.DeleteMezzanines(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyDeleteMezzanines(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    fmt.Println(response.NonExistVideoIds)
}

Update the information about multiple images

For more information about the request and response parameters, see UpdateImageInfos.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
    "encoding/json"
)

func MyUpdateImageInfos(client *vod.Client) (response *vod.UpdateImageInfosResponse, err error) {
    request := vod.CreateUpdateImageInfosRequest()

    updateContent := []map[string]interface{}{}
    updateItem1 := map[string]interface{}{"ImageId":"<ImageId1>", "Title":"New Title 1", "Tags": "NewTag1,NewTag2"} 
    updateItem2 := map[string]interface{}{"ImageId":"<ImageId2>", "Title":"New Title 2", "Tags": "NewTag1,NewTag2"} 
    updateContent = append(updateContent, updateItem1, updateItem2)
    jsonContent, err := json.Marshal(updateContent)
    if err ! = nil {
        fmt.Println("json.Marshal failed:", err)
        return
    }
    request.UpdateContent = string(jsonContent)
    request.AcceptFormat = "JSON"

    return client.UpdateImageInfos(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyUpdateImageInfos(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    fmt.Println(response.NonExistImageIds)
}

Obtain image information

For more information about the request and response parameters, see GetImageInfo.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetImageInfo(client *vod.Client) (response *vod.GetImageInfoResponse, err error) {
    request := vod.CreateGetImageInfoRequest()
    request.ImageId = "<ImageId>"
    request.AuthTimeout = "86400"
    request.AcceptFormat = "JSON"

    return client.GetImageInfo(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetImageInfo(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
    fmt.Println(response.ImageInfo.URL)
}

Delete images

For more information about the request and response parameters, see DeleteImage.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyDeleteImage(client *vod.Client) (response *vod.DeleteImageResponse, err error) {
    request := vod.CreateDeleteImageRequest()

    // Deletes image files based on image IDs.
    request.DeleteImageType = "ImageId"
    request.ImageIds = "ImageId1,ImageId2"

    /*
    // Deletes image files based on image URLs.
    request.DeleteImageType = "ImageURL"
    request.ImageURLs = "http://out-20170320144157164-bjsdu4mihp.oss-cn-shanghai.aliyuncs.com.gif"

    // Deletes image files of the specified image type based on a video ID.
    request.DeleteImageType = "VideoId"
    request.VideoId = "<VideoId>"
    request.ImageType = "SpriteSnapshot"
    */

    request.AcceptFormat = "JSON"

    return client.DeleteImage(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
    if err ! = nil {
        panic(err)
    }

    response, err := MyDeleteImage(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.RequestId)
}