全部产品
云市场

媒资管理

更新时间:2018-12-29 09:46:35

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

搜索媒资信息

接口参数和返回字段请参考 SearchMedia

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("SearchMedia", {
  4. Fields: 'Title,CoverURL,Status',
  5. Match: "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')",
  6. PageNo: 1,
  7. PageSize: 10,
  8. SearchType: 'video',
  9. SortBy: 'CreationTime:Desc'
  10. }, {}).then(function (response) {
  11. console.log("Total = " + response.Total);
  12. console.log("ScrollToken = " + response.ScrollToken);
  13. if (response.MediaList && response.MediaList && response.MediaList.length > 0){
  14. for (var i=0; i<response.MediaList.length; i++){
  15. console.log("MediaId = " + response.MediaList[i].MediaId);
  16. console.log("MediaType = " + response.MediaList[i].MediaType);
  17. console.log("CreationTime = " + response.MediaList[i].CreationTime);
  18. console.log("Title = " + response.MediaList[i].Video.Title);
  19. console.log("CoverURL = " + response.MediaList[i].Video.CoverURL);
  20. console.log("Status = " + response.MediaList[i].Video.Status);
  21. }
  22. }
  23. console.log('RequestId = ' + response.RequestId);
  24. }).catch(function (response) {
  25. console.log('ErrorCode = ' + response.data.Code);
  26. console.log('ErrorMessage = ' + response.data.Message);
  27. console.log('RequestId = ' + response.data.RequestId);
  28. });

获取视频信息

接口参数和返回字段请参考 GetVideoInfo

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("GetVideoInfo", {
  4. VideoId: 'VideoId'
  5. }, {}).then(function (response) {
  6. if (response.Video){
  7. console.log("Title = " + response.Video.Title);
  8. console.log("Description = " + response.Video.Description);
  9. }
  10. console.log('RequestId = ' + response.RequestId);
  11. }).catch(function (response) {
  12. console.log('ErrorCode = ' + response.data.Code);
  13. console.log('ErrorMessage = ' + response.data.Message);
  14. console.log('RequestId = ' + response.data.RequestId);
  15. });

批量获取视频信息

接口参数和返回字段请参考 GetVideoInfos

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("GetVideoInfos", {
  4. VideoIds: 'Video1,Video2'
  5. }, {}).then(function (response) {
  6. if (response.VideoList && response.VideoList.length > 0){
  7. console.log("===== exist video infos : =====");
  8. for (var i=0; i<response.VideoList.length; i++) {
  9. var video = response.VideoList[i];
  10. console.log("VideoId = " + video.VideoId);
  11. console.log("Title = " + video.Title);
  12. console.log("Description = " + video.Description);
  13. console.log("Tags = " + video.Tags);
  14. console.log("CreationTime = " + video.CreationTime);
  15. }
  16. }
  17. if (response.NonExistVideoIds && response.NonExistVideoIds.length > 0){
  18. console.log("===== nonexistent videoIds : =====");
  19. for (var i=0; i<response.NonExistVideoIds.length; i++) {
  20. console.log("VideoId = " + response.NonExistVideoIds[i]);
  21. }
  22. }
  23. console.log('RequestId = ' + response.RequestId);
  24. }).catch(function (response) {
  25. console.log('ErrorCode = ' + response.data.Code);
  26. console.log('ErrorMessage = ' + response.data.Message);
  27. console.log('RequestId = ' + response.data.RequestId);
  28. });

修改视频信息

接口参数和返回字段请参考 UpdateVideoInfo

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("UpdateVideoInfo", {
  4. VideoId: 'VideoId',
  5. Title: 'new Title',
  6. Description: 'new Description',
  7. Tags: 'new Tag1,new Tag2'
  8. }, {}).then(function (response) {
  9. console.log('RequestId = ' + response.RequestId);
  10. }).catch(function (response) {
  11. console.log('ErrorCode = ' + response.data.Code);
  12. console.log('ErrorMessage = ' + response.data.Message);
  13. console.log('RequestId = ' + response.data.RequestId);
  14. });

批量修改视频信息

接口参数和返回字段请参考 UpdateVideoInfos

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. var updateContent = [{
  4. VideoId: 'VideoId1',
  5. Title: 'new Title',
  6. Tags: 'new Tag1,new Tag2'
  7. },{
  8. VideoId: 'VideoId2',
  9. Title: 'new Title',
  10. Tags: 'new Tag1,new Tag2'
  11. }];
  12. client.request("UpdateVideoInfos", {
  13. UpdateContent: JSON.stringify(updateContent)
  14. }, {}).then(function (response) {
  15. if (response.NonExistVideoIds && response.NonExistVideoIds.length > 0){
  16. console.log("===== nonexistent videoIds : =====");
  17. for (var i=0; i<response.NonExistVideoIds.length; i++) {
  18. console.log("VideoId = " + response.NonExistVideoIds[i]);
  19. }
  20. }
  21. console.log('RequestId = ' + response.RequestId);
  22. }).catch(function (response) {
  23. console.log('ErrorCode = ' + response.data.Code);
  24. console.log('ErrorMessage = ' + response.data.Message);
  25. console.log('RequestId = ' + response.data.RequestId);
  26. });

删除视频

接口参数和返回字段请参考 DeleteVideo

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("DeleteVideo", {
  4. VideoIds: 'Video1,Video2'
  5. }, {}).then(function (response) {
  6. console.log('RequestId = ' + response.RequestId);
  7. }).catch(function (response) {
  8. console.log('ErrorCode = ' + response.data.Code);
  9. console.log('ErrorMessage = ' + response.data.Message);
  10. console.log('RequestId = ' + response.data.RequestId);
  11. });

获取源文件信息(含源片下载地址)

接口参数和返回字段请参考 GetMezzanineInfo

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("GetMezzanineInfo", {
  4. VideoId: 'VideoId',
  5. AuthTimeout: 3600 // 源片下载地址过期时间
  6. }, {}).then(function (response) {
  7. if (response.Mezzanine){
  8. console.log('Mezzanine.VideoId = ' + response.Mezzanine.VideoId);
  9. console.log('Mezzanine.FileURL = ' + response.Mezzanine.FileURL);
  10. console.log('Mezzanine.Width = ' + response.Mezzanine.Width);
  11. console.log('Mezzanine.Height = ' + response.Mezzanine.Height);
  12. console.log('Mezzanine.Size = ' + response.Mezzanine.Size);
  13. }
  14. console.log('RequestId = ' + response.RequestId);
  15. }).catch(function (response) {
  16. console.log('ErrorCode = ' + response.data.Code);
  17. console.log('ErrorMessage = ' + response.data.Message);
  18. console.log('RequestId = ' + response.data.RequestId);
  19. });

获取视频列表

接口参数和返回字段请参考 GetVideoList

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("GetVideoList", {
  4. StartTime: '2018-12-28T06:00:00Z',
  5. EndTime: '2018-12-28T14:00:00Z',
  6. PageNo: 1,
  7. PageSize: 2
  8. }, {}).then(function (response) {
  9. // 根据指定筛选条件查询到的视频总数
  10. console.log('Total = ' + response.Total);
  11. if (response.VideoList && response.VideoList.Video && response.VideoList.Video.length > 0){
  12. for (var i=0; i<response.VideoList.Video.length; i++){
  13. var video = response.VideoList.Video[i];
  14. console.log('Title = ' + video.Title);
  15. console.log('Description = ' + video.Description);
  16. console.log('Tags = ' + video.Tags);
  17. console.log('CreationTime = ' + video.CreationTime);
  18. }
  19. }
  20. console.log('RequestId = ' + response.RequestId);
  21. }).catch(function (response) {
  22. console.log('ErrorCode = ' + response.data.Code);
  23. console.log('ErrorMessage = ' + response.data.Message);
  24. console.log('RequestId = ' + response.data.RequestId);
  25. });

删除媒体流

接口参数和返回字段请参考 DeleteStream

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("DeleteStream", {
  4. VideoId: 'VideoId',
  5. JobIds: 'JobId1,JobId2'
  6. }, {}).then(function (response) {
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

批量删除源文件

接口参数和返回字段请参考 DeleteMezzanines

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("DeleteMezzanines", {
  4. VideoIds: 'VideoId',
  5. Force: false
  6. }, {}).then(function (response) {
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

批量更新图片信息

接口参数和返回字段请参考 UpdateImageInfos

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. var updateContent = [{
  4. ImageId: 'ImageId1',
  5. Title: 'new title',
  6. Tags: 'new Tag1,new Tag2'
  7. },{
  8. ImageId: 'ImageId2',
  9. Title: 'new title',
  10. Tags: 'new Tag1,new Tag2'
  11. }];
  12. client.request("UpdateImageInfos", {
  13. UpdateContent: JSON.stringify(updateContent)
  14. }, {}).then(function (response) {
  15. if (response.NonExistImageIds && response.NonExistImageIds.ImageId && response.NonExistImageIds.ImageId.length > 0) {
  16. console.log("======nonexistent ImageIds : ======");
  17. console.log('ImageId = ' + response.NonExistImageIds.ImageId);
  18. }
  19. console.log('RequestId = ' + response.RequestId);
  20. }).catch(function (response) {
  21. console.log('ErrorCode = ' + response.data.Code);
  22. console.log('ErrorMessage = ' + response.data.Message);
  23. console.log('RequestId = ' + response.data.RequestId);
  24. });

获取图片信息

接口参数和返回字段请参考 GetImageInfo

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. client.request("GetImageInfo", {
  4. ImageId: 'ImageId1'
  5. }, {}).then(function (response) {
  6. if (response.ImageInfo) {
  7. console.log('ImageId = ' + response.ImageInfo.ImageId);
  8. console.log('Title = ' + response.ImageInfo.Title);
  9. console.log('CreationTime = ' + response.ImageInfo.CreationTime);
  10. console.log('FileURL = ' + response.ImageInfo.Mezzanine.FileURL);
  11. }
  12. console.log('RequestId = ' + response.RequestId);
  13. }).catch(function (response) {
  14. console.log('ErrorCode = ' + response.data.Code);
  15. console.log('ErrorMessage = ' + response.data.Message);
  16. console.log('RequestId = ' + response.data.RequestId);
  17. });

删除图片

接口参数和返回字段请参考 DeleteImage

  1. // 请求示例
  2. var client = initVodClient('<Your AccessKeyId>', '<Your AccessKeySecret>');
  3. // 根据ImageURL删除图片文件
  4. var paras = {
  5. DeleteImageType: 'ImageURL',
  6. ImageURLs: 'http://sample.aliyun.com/cover.jpg'
  7. };
  8. // 根据ImageId删除图片文件
  9. // var paras = {
  10. // DeleteImageType: 'ImageId',
  11. // ImageIds: 'ImageId1,ImageId2'
  12. // };
  13. // 根据VideoId删除指定ImageType的图片文件
  14. // var paras = {
  15. // DeleteImageType: 'VideoId',
  16. // VideoId: 'http://sample.aliyun.com/cover.jpg',
  17. // ImageType: 'SpriteSnapshot'
  18. // };
  19. client.request("DeleteImage", paras, {}).then(function (response) {
  20. console.log('RequestId = ' + response.RequestId);
  21. }).catch(function (response) {
  22. console.log('ErrorCode = ' + response.data.Code);
  23. console.log('ErrorMessage = ' + response.data.Message);
  24. console.log('RequestId = ' + response.data.RequestId);
  25. });