Using the Youtube.net API to Download and Install Video as Unregistered

It seems the Youtube API for .net has not been updated after some time. Thus, there is no property or method subjected to setting the video as unregistered. Can anyone offer a job if they have encountered this problem before?

+3
source share
3 answers

I also had problems with this, so I thought that I would publish my findings for anyone looking for an answer to this question.

By this thread , support for yt: accessControl has been added to rev. 1118.

API, Google API. API (SVN Checkout).

, - :

Video newVideo = new Video();
newVideo.YouTubeEntry.AccessControls.Add(new YtAccessControl("list", "denied"));

!

+6

:

API- YouTube asp.net

, :

private Video SetAcessControl(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 != null && 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;
    }

, :

        YouTubeRequest request = CreateYouTubeRequest(configuration);
        Uri youTubeUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/users/default/uploads/{0}", youTubeVideoId));
        Video video = request.Retrieve<Video>(youTubeUrl);

        video = SetAcessControl(video, "list", "denied");  // removes the video from searches, thus making it Unlisted (what you're looking for)
        video = SetAcessControl(video, "comment", "denied");  // disables comments
        video = SetAcessControl(video, "commentVote", "denied"); // disables voting on comments
        video = SetAcessControl(video, "videoRespond", "denied"); // disables video responses
        video = SetAcessControl(video, "rate", "denied"); // disables rating

        Video updatedVideo = request.Update(video);

, , (.. () request.Upload(). , , .

, , , . URL: http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_yt:accessControl

, !

+2

Pass the username and password with " YouTubeRequestSettings".

Example

YouTubeRequestSettings settings = new YouTubeRequestSettings("My Channel", YouTubeDeveloperKey, "username", "password");

If you want to get the video "unregistered" or "private", you need to authenticate with your request.

+2
source

Source: https://habr.com/ru/post/1790673/


All Articles