我正在尝试通过 youtube direct upload 将视频上传到 youtube。效果很好。然后我创建了一个带有很长描述的视频。然后我收到以下错误;
com.google.gdata.util.InvalidEntryException:错误请求
<?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:validation</domain><code>too_long</code><location type='xpath'>media:group/media:description/text()</location></error></errors>
我想知道这是由于描述的长度还是其他原因?
下面是我的代码
private String uploadVideo(YouTubeService service, String videoLocation,String mimeType,String title) throws InterruptedException, ExecutionException, TimeoutException, ServiceException, IOException {
String id = "";
File videoFile = new File(videoLocation);
if (!videoFile.exists()) {
System.out.println("Sorry, that video doesn't exist.");
}
String videoTitle = title;
VideoEntry newEntry = new VideoEntry();
YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
mg.setTitle(new MediaTitle());
mg.getTitle().setPlainTextContent(videoTitle);
mg.setKeywords(new MediaKeywords());
mg.getKeywords().addKeyword("yt:crop=16:9");
mg.setDescription(new MediaDescription());
mg.getDescription().setHtmlContent(attributionDocument);
mg.setPrivate(true);
mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Tech"));
MediaFileSource ms = new MediaFileSource(videoFile, "video/quicktime");
newEntry.setMediaSource(ms);
String uploadUrl =
"http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
id =createdEntry.getId();
return id;
}
如果有人能帮助我解决这个问题,我将非常感激。
提前致谢。
最佳答案
响应 XML 表示关于“media:group/media:description/text()”的“too_long”。这对我来说是非常确定的。
使用较短的描述,问题就会消失。
<小时/>FWIW,this link说明 media:description
应该包含什么内容,并提到有大小限制。
关于java - 通过 Youtube API 上传 Youtube 视频时出现长描述错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6423011/