Я пытаюсь загрузить видео на YouTube с помощью прямой загрузки на 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;
}
Буду очень признателен, если кто-нибудь сможет мне помочь с этим.
Заранее спасибо.