我正在尝试将视频上传到Youtube。已成功将视频上传到帐户的频道。之后,我创建了名为“Deneme1”的新频道。我试图用api上传到那个频道;但上传到主。
我的代码:
public static string UploadVideo(string FilePath, string Title, string Description)
{
YouTubeRequestSettings settings;
YouTubeRequest request;
string devkey = "api key";
string username = "mail@gmail.com";
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);
}
任何帮助都会很棒!