+ Reply to Thread
Results 1 to 2 of 2

Thread: Youtube API <Upload Video>

  1. #1
    Junior Member
    Join Date
    May 2012

    Youtube API <Upload Video>

    I'd like to know how can i upload videos to youtube using the Youtube API.

    I just need an example.
    Last edited by cpro; 11-02-2012 at 12:36 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Google has an API for youtube and we are going to use that to upload videos to youtube account.

    So , you need these stuff before begining :
    1) Youtube Account
    2) Download the Youtube SDK & Google Data API from here : http://code.google.com/p/google-gdata/downloads/list

    After you have downloaded the SDK , install it and import the libraries into your debug folder where the application exist

    NameSpaces :
    	// Add these
        using Google.GData.Client;
        using Google.GData.Extensions.MediaRss;
        using Google.GData.YouTube;
        using Google.YouTube;
    We will be using the Background worker for more effieciency.

    Upload Function :
            private static BackgroundWorker uploader;
            private static YouTubeRequestSettings settings;
            static void UploaderDoWork(object sender, DoWorkEventArgs e)
                var request = new YouTubeRequest(settings);
                var newVideo = new Video { Title = "Test" };
                newVideo.Tags.Add(new MediaCategory("Animals", YouTubeNameTable.CategorySchema));
                newVideo.Description = "Testing Testing Testing";
                newVideo.YouTubeEntry.Private = true;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\Wildlife.wmv", "video/x-ms-wmv");            
                catch (Exception exception)
                    MessageBox.Show("Upload failed: " + exception.Message);
    Example :
            private void button1_Click(object sender, RoutedEventArgs e)
                settings = new YouTubeRequestSettings("app","devkey","email","password");
                uploader = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
                uploader.DoWork += UploaderDoWork;
                uploader.RunWorkerCompleted += delegate { MessageBox.Show("Upload completed!"); };
                MessageBox.Show("Initiated upload process...");
    Note :
    - Be careful when writing the settings because wrong settings will lead to 401 Unauthorized Execption.

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts