先将视频id从腾讯云视频点播导出,然后将视频id黏贴到空白的文本中(/Users/liqiang/Desktop/videoid.txt),然后执行本程序。
主程序
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.vod.v20180717.VodClient;
import com.tencentcloudapi.vod.v20180717.models.*;
import java.io.*;
public class modifyVideoClass {
public static void main(String[] args){
// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
Credential cred = new Credential("xxx", "xxx");
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("vod.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
VodClient client = new VodClient(cred, "", clientProfile);
int count=0;
try {
FileInputStream is=new FileInputStream("/Users/liqiang/Desktop/videoid.txt");
BufferedReader br=new BufferedReader(new InputStreamReader(is));
String re=null;
while ((re=br.readLine())!=null){
count++;
System.out.println("读取行数:"+count);
System.out.println("读到的数据为:"+re);
try{
// 实例化一个请求对象,每个接口都会对应一个request对象
ModifyMediaInfoRequest req = new ModifyMediaInfoRequest();
req.set("FileId",re);
req.set("ClassId",832425);
// 返回的resp是一个ModifyMediaInfoResponse的实例,与请求对象对应
ModifyMediaInfoResponse resp = client.ModifyMediaInfo(req);
// 输出json格式的字符串回包
System.out.println(ModifyMediaInfoResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>500li.cn</groupId>
<artifactId>modifyVideoClass</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
<!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
<version>3.1.322</version>
</dependency>
</dependencies>
</project>