I'm trying to upload videos to Youtube. Successfully uploaded videos to account's channel. After that I created new channel with name "Deneme1". And I tried to upload to that channel with api; but uploaded to main.
My code:
public static string UploadVideo(string FilePath, string Title, string Description)
{
YouTubeRequestSettings settings;
YouTubeRequest request;
string devkey = "api key";
string username = "[email protected]";
string password = "password";
settings = new YouTubeRequestSettings("Deneme1", devkey, username, password) { Timeout = 10000000 };
request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = Title;
newVideo.Description = Description;
newVideo.Private = true;
newVideo.YouTubeEntry.Private = false;
newVideo.Keywords = "asd";
newVideo.Tags.Add(new MediaCategory("Sports", YouTubeNameTable.CategorySchema));
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/flv");
Video createdVideo = request.Upload(newVideo);
return createdVideo.VideoId;
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
string videopath, videotitle, videodesc;
videopath = @"C:\Users\Ercin\Dropbox\Cloudy\Visual Studio\Projects\videoupload\videoupload\badstart.flv";
videotitle = "test title";
videodesc = "test description";
UploadVideo(videopath, videotitle, videodesc);
}
catch (Exception exception)
{
Response.Write("Upload failed: " + exception.Message);
}
Any help will be fantastic!
This code bellow work's fine for me, to upload to specific channel I put of ChannelId in username.