Reputation: 347
How to disable comments when uploading a video with Youtube API, in java ?
Upvotes: 1
Views: 482
Reputation: 1095
After a quick Google, I found this.
What you want to do is add an yt:accessControl element to the video entry, with an action attribute of "comment" and a permission attribute of "moderated". I don't believe that there is native support or the yt:accessControl element in the Java client library yet, so this would have to be done "by hand". Here's some example code that assumes you've just created a new video, and then performs a partial update to set the yt:accessControl value for that video:
VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
String atomXml = "<?xml version='1.0'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' gd:fields='yt:accessControl' xmlns:yt='http://gdata.youtube.com/schemas/2007'><yt:accessControl action='comment' permission='moderated'/></entry>";
GDataRequest request = service.createPatchRequest(new URL(createdEntry.getEditLink().getHref()));
request.getRequestStream().write(atomXml.getBytes("UTF-8"));
request.execute();
createdEntry = service.parseResponseData(request, VideoEntry.class);
// createdEntry now contains the updated VideoEntry, and the access control should be set on it.
Upvotes: 3