0

Hi i want to create an uploading video program using youtube api I think I missed something. I search for some examples on how to upload using .net but cant seem to find an answer.

Heres my code:

` Imports Google.YouTube Imports Google.GData.Client Imports Google.GData.Extensions Imports Google.GData.Extensions.MediaRss Imports Google.GData.YouTube Imports Google.GData.Extensions.Location

Public Class Form1





    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim settings As YouTubeRequestSettings Dim request As YouTubeRequest

settings = New YouTubeRequestSettings("youtube uploader", "AI39si4NwqS3ISLGVjlHBCdC8BfiJJSJWqqcJEvZOLbFohZAslQ4uhgrnFOJKdxGju55g2xoSImzEhXPGE5syMV9X0fh8NEHGg", txtuser.Text, txtpass.Text) request = New YouTubeRequest(settings)

Try Dim newVideo As Video = New Video() newVideo.Title = "Hangover Sample Movie" newVideo.Tags.Add(New MediaCategory("Sample", YouTubeNameTable.CategorySchema)) newVideo.Keywords = "hangover, funny" newVideo.Description = "Hangover" newVideo.YouTubeEntry.Private = False newVideo.Tags.Add(New MediaCategory("hangover, funny, comedy", YouTubeNameTable.DeveloperTagSchema)) newVideo.YouTubeEntry.Location = New GeoRssWhere(37, -122) ' alternatively, you could just specify a descriptive string ' newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA"); newVideo.YouTubeEntry.MediaSource = New MediaFileSource(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\sample.avi", "video/avi") request.Upload(newVideo) Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class`

but it produces this error Execution of request failed https://uploads.gdata.youtube.com/feeds/api/users/default/uploads

0

3 Answers 3

1

The primary problem I'm noticing is that your code is specifying a media source that is a *.avi file and assigning it a MIME type of "video/quicktime." So far as I am aware, QuickTime videos are commonly indicated by *.mov extension. When YouTube receives this information, it is likely to use a transcoder to turn your movie content into its own native format and failing because it is attempting to make sense of the movie as if it were a QuickTime file. You should probably change the MIME type to "video/avi".

Additionally, your sample code is not calling request.Upload().

Sign up to request clarification or add additional context in comments.

1 Comment

thanks. I have that line I forgot to copy the request.Upload(newVideo) line sorry Ill update it and I tried to change the "video/avi" but it has same results.
1

The first thing that comes to mind is that you are creating a request object at initialization, but not using it until a button is clicked. This might be a problem, the C# example I saw for this did them one after the other.

But the most like problem is that you seem to be setting some values for the setting object using form controls, and doing this at form initialization time, where such controls generally don't have usable values. If you're hard coding values into the controls, it would be better to just do so for the setting object. If you're not hard coding the values into your control at design time, then that's probably your problem (which fits in nicely with your authentication error).

2 Comments

yeah sorry about that. I hard coded the username and pass but output is still the same.
@jko: No problem. Still, I would say that your problem is with creating the settings. I would verify all of the arguements you pass to the constructor.
0

I just found out that the problem with my code is that youtube havent asked me a username(but i do have my youtube account, crazy... XD)...then i tried again the code and it works. thanks also to @jmoreno.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.