The method below uses the YouTube video obtained from the YouTube request service, as well as the permission type and new permissions.
private Video SetAccessControl(Video video, string type, string permission)
{
var exts = video.YouTubeEntry
.ExtensionElements
.Where(x => x is XmlExtension)
.Select(x => x as XmlExtension)
.Where(x => x.Node.Attributes["action"] != null && x.Node.Attributes["action"].InnerText == type);
var ext = exts.FirstOrDefault();
if (ext != null)
ext.Node.Attributes["permission"].InnerText = permission;
return video;
}
NOTE. This will only work on the extracted video, not if you transfer the "new video ()"
what it does is iterates over all the ExtentionElements that you use as part of the feed and retrieves the xml extension elements (since there is no extension in C # access control extension) takes elements that match the == type action then updates permission attribute to the desired value.
- YouTube, .