Trying to use google/youtube official guide developers site to create video upload code but getting

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I tried to use youtube apis developers official site: http://code.google.com/intl/fr/apis/youtube/2.0/developers_guide_dotnet.html#Uploading_Videos
http://code.google.com/intl/fr/apis/youtube/2.0/developers_guide_dotnet.html#Uploading_Videos
Then i used a code sample by them to upload videos to youtube :


<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using System.IO;
<span style="color:Blue; using Google.GData.Client;
<span style="color:Blue; using Google.GData.Extensions;
<span style="color:Blue; using Google.GData.YouTube;
<span style="color:Blue; using Google.GData.Extensions.MediaRss;
<span style="color:Blue; using Google.YouTube;


<span style="color:Blue; namespace YouTube_Manager
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class Form1 : Form
{
<span style="color:Blue; string developerKey = <span style="color:#A31515; "AI39si6xhSQXx95FTYIACWPfq-lLIphblgaReuz9z6VEjR1Q6YjrV6FRN2U6FN6P6-lGF2OYaUZhCVOKJ_MCk4o6kPeUszvf5A";
YouTubeRequestSettings settings;
YouTubeRequest request;
Video newVideo;

<span style="color:Blue; public Form1()
{
InitializeComponent();

settings = <span style="color:Blue; new YouTubeRequestSettings(<span style="color:#A31515; "example app", developerKey,<span style="color:#A31515; "myusernameREMOVED",<span style="color:#A31515; "mypasswordREMOVED");<span style="color:Green; //, (String)SessionToken);
request = <span style="color:Blue; new YouTubeRequest(settings);

newVideo = <span style="color:Blue; new Video();

newVideo.Title = <span style="color:#A31515; "My Test Movie";
newVideo.Tags.Add(<span style="color:Blue; new MediaCategory(<span style="color:#A31515; "Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = <span style="color:#A31515; "cars, funny"; newVideo.Description = <span style="color:#A31515; "My description";
newVideo.YouTubeEntry.Private = <span style="color:Blue; false; newVideo.Tags.Add(<span style="color:Blue; new MediaCategory(<span style="color:#A31515; "mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
<span style="color:Green; //newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
<span style="color:Green; // alternatively, you could just specify a descriptive string//
newVideo.YouTubeEntry.setYouTubeExtension(<span style="color:#A31515; "location", <span style="color:#A31515; "Mountain View, CA");
newVideo.YouTubeEntry.MediaSource = <span style="color:Blue; new MediaFileSource(<span style="color:#A31515; "d:\P9170031.mov", <span style="color:#A31515; "video/quicktime"); Video createdVideo = request.Upload(newVideo);
}

<span style="color:Blue; private <span style="color:Blue; void Form1_Load(<span style="color:Blue; object sender, EventArgs e)
{

}
}
}
[/code]
<br/>

Just to show here the code i removed from it my user name and password !

I ran the program first time to test and:
After few minutes the program is running and then im getting exception message on the line: Video createdVideo = request.Upload(newVideo);
The exceptiion error say: Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads
https://uploads.gdata.youtube.com/feeds/api/users/default/uploads

The full exception message:

Google.GData.Client.GDataRequestException was unhandled<br/>
Message=Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads
https://uploads.gdata.youtube.com/feeds/api/users/default/uploads <br/>
Source=Google.GData.Client<br/>
StackTrace:<br/>
at Google.GData.Client.GDataRequest.Execute()<br/>
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)<br/>
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)<br/>
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)<br/>
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)<br/>
at Google.GData.Client.GDataGAuthRequest.Execute()<br/>
at Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)<br/>
at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)<br/>
at Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)<br/>
at Google.GData.YouTube.YouTubeService.Upload(String userName, YouTubeEntry entry)<br/>
at Google.YouTube.YouTubeRequest.Upload(String userName, Video v)<br/>
at Google.YouTube.YouTubeRequest.Upload(Video v)<br/>
at YouTube_Manager.Form1..ctor() in D:C-SharpYouTube_ManagerYouTube_ManagerYouTube_ManagerForm1.cs:line 42<br/>
at YouTube_Manager.Program.Main() in D:C-SharpYouTube_ManagerYouTube_ManagerYouTube_ManagerProgram.cs:line 18<br/>
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)<br/>
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br/>
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br/>
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br/>
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)<br/>
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br/>
at System.Threading.ThreadHelper.ThreadStart()<br/>
InnerException: System.Net.WebException<br/>
Message=The operation has timed out<br/>
Source=System<br/>
StackTrace:<br/>
at System.Net.HttpWebRequest.GetResponse()<br/>
at Google.GData.Client.GDataRequest.Execute()<br/>
InnerException:


Tried to google for it didnt find any solution.

Thanks. <hr class="sig danieli

View the full article
 
Back
Top