当前位置: 首页>>代码示例>>C#>>正文


C# YouTubeRequest.Upload方法代码示例

本文整理汇总了C#中YouTubeRequest.Upload方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.Upload方法的具体用法?C# YouTubeRequest.Upload怎么用?C# YouTubeRequest.Upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YouTubeRequest的用法示例。


在下文中一共展示了YouTubeRequest.Upload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: upload

        public void upload()
        {
            Random a = new Random();
            string id = a.Next(100000, 999999).ToString();
            YouTubeRequestSettings settings = new YouTubeRequestSettings(id, developerKey, hesapAdi, hesapSifresi);
            YouTubeRequest request = new YouTubeRequest(settings);

            Video newVideo = new Video();
            ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
            newVideo.Title = videoAdi;
            newVideo.Tags.Add(new MediaCategory(videoTur, YouTubeNameTable.CategorySchema));
            newVideo.Keywords = etiketler;
            newVideo.Description = aciklama;
                newVideo.YouTubeEntry.Private = false;
            newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoYolu, "video/x-flv");

            request.Upload(newVideo);
        }
开发者ID:voyl,项目名称:myprojects,代码行数:18,代码来源:up.cs

示例2: btnUploadYTVideo_Click

 protected void btnUploadYTVideo_Click(object sender, EventArgs e)
 {
     YouTubeRequestSettings ytsettings = new YouTubeRequestSettings("SonetReach", "AI39si4bVFP9AaDQuM12V5xTGF-pj87bxWApjm3KReLJFl67kkFfq3Jn32DikSJzRrqGo8mYY7Ww7XXD9JZDCezjMd9jUMtFCA", "[email protected]", "sonetreach123");
     ytsettings.Timeout = -1;
     YouTubeRequest ytReq = new YouTubeRequest(ytsettings);
     ((GDataRequestFactory)ytReq.Service.RequestFactory).Timeout = 60 * 60 * 1000;
     Video video = new Video();
     video.Title = "the best paint in the world";
     video.Description = "sonet reach";
     video.Tags.Add(new MediaCategory("Sports", YouTubeNameTable.CategorySchema));
     video.YouTubeEntry.Private = false;
     video.YouTubeEntry.MediaSource = new MediaFileSource("D:\\Test_Vid.mp4", "video/mp4");
     Video createdVideo = ytReq.Upload(video);
     string videoID = createdVideo.VideoId;
     string youtubelink = "http://www.youtube.com/watch?v=" + videoID;
     lblVidURL.Style.Add("color", "Voilet");
     lblVidURL.Style.Add("font-family", "Segoe UI Light,Segoe UI,Tahoma,Arial,Verdana,sans-serif");
     lblVidURL.Text = "Your video has been uploaded to : " + youtubelink;
 }
开发者ID:apreshchandra,项目名称:Test,代码行数:19,代码来源:CanvasAreaYoutubeVideoUpload.aspx.cs

示例3: UploadVideo

        public static void UploadVideo()
        {
            try
            {
            //                string developerKey = "AI39si72llWnlwlqjLA1XPfT1uz-ryd6n8Yb9KgjoHsjHda3tn5fANjJ1Ys73SFRUp0aV7oxdJESkICc1jveiBb4tD-zvKZnfw";
                String developerKey = "AIzaSyAWcrKx4meD6r3-SixVEMaMf_PCvUwA-rE";
                string username = "[email protected]";
                string password = "m123456&";
                YouTubeRequestSettings settings = new YouTubeRequestSettings("API Project", developerKey, username, password);
                YouTubeRequest request = new YouTubeRequest(settings);

                Video newVideo = new Video();

                newVideo.Title = _header;
                newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
                newVideo.Keywords = _keywords;
                newVideo.Description = _description;
                newVideo.YouTubeEntry.Private = false;

                newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", 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(@"C:\Users\nufar\Desktop\Final Project DAMN IT\SkeletalTracking\bin\Debug\EntireScreenCaptured.wmv",
                  "video/x-ms-wmv");

                Video createdVideo = request.Upload(newVideo);
                Status pop = new Status(createdVideo);
                pop.Show();
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
开发者ID:nofarshaked,项目名称:Live_Editing_System,代码行数:38,代码来源:uploadWindow.xaml.cs

示例4: YoutubeUpload

        private void YoutubeUpload()
        {
            try
            {
                Random a = new Random();
                string id = a.Next(100000, 999999).ToString();
                YouTubeRequestSettings settings = new YouTubeRequestSettings(id, developerkey, hesapadi, hesapsifresi);
                YouTubeRequest request = new YouTubeRequest(settings);

                Video newVideo = new Video();
                ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
                newVideo.Title = videoAdi;
                newVideo.Tags.Add(new MediaCategory("News", YouTubeNameTable.CategorySchema));
                newVideo.Keywords = etiket;
                newVideo.Description = aciklama;
                newVideo.YouTubeEntry.Private = false;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoismi, "video/x-flv");

                request.Upload(newVideo);
                AppendText(richTextBox1,Color.Azure,DateTime.Now.ToString() + " -> " + videoismi);
            }
            catch (Exception ex)
            {
                richTextBox2.Text += ex.ToString();
                AppendText(richTextBox1, Color.Red,"Yükleme Hatası." + Environment.NewLine);
            }
        }
开发者ID:voyl,项目名称:myprojects,代码行数:27,代码来源:Form2.cs

示例5: YouTubeRequestInsertTest

        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube Feed object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeRequestInsertTest()
        {
            Tracing.TraceMsg("Entering YouTubeRequestInsertTest");
            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            YouTubeRequest f = new YouTubeRequest(settings);

            Video v = new Video(); 
            v.Title = "Sample upload";
            v.Description = "This is a test with and & in it";

            MediaCategory category = new MediaCategory("Nonprofit");
            category.Attributes["scheme"] = YouTubeService.DefaultCategory;
            v.Tags.Add(category);
            v.Keywords = "math"; 
            v.YouTubeEntry.MediaSource = new MediaFileSource(this.resourcePath + "test_movie.mov", "video/quicktime");

            Video newVideo = f.Upload(this.ytUser, v); 

            newVideo.Title = "This test upload will soon be deleted";
            Video updatedVideo = f.Update(newVideo);

            Assert.AreEqual(updatedVideo.Description, newVideo.Description, "Description should be equal");
            Assert.AreEqual(updatedVideo.Keywords, newVideo.Keywords, "Keywords should be equal");

            newVideo.YouTubeEntry.MediaSource = new MediaFileSource(this.resourcePath + "test.mp4", "video/mp4");
            Video last = f.Update(updatedVideo);
            f.Delete(last);
        }
开发者ID:yodiz,项目名称:Avega.ContactSynchronizer,代码行数:34,代码来源:youtubetest.cs

示例6: YoutubeUpload

        private void YoutubeUpload()
        {
            bool aa = true;
            this.Text = "Video Yükleniyor..";


            try
            {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("Contentor", txdevkey.Text, txid.Text, txpw.Text);
                YouTubeRequest request = new YouTubeRequest(settings);


                Video newVideo = new Video();
                ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
                newVideo.Title = txvideoadi.Text;
                newVideo.Tags.Add(new MediaCategory("Entertainment", YouTubeNameTable.CategorySchema));
                newVideo.Keywords = txetiket.Text;
                newVideo.Description = txaciklama.Text;
                newVideo.YouTubeEntry.Private = false;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoismi, "video/x-flv");

                request.Upload(newVideo);
            }
            catch (Exception ex)
            {
                richTextBox1.Text += ex.ToString();
                this.Text = "Hata.";
                aa = false;
            }
            if (aa)
                label3.Text = (Convert.ToInt16(label3.Text) + 1).ToString();
            else
                label5.Text = (Convert.ToInt16(label5.Text) + 1).ToString();
        }
开发者ID:voyl,项目名称:myprojects,代码行数:34,代码来源:Form1.cs

示例7: YouTubeAccessControlTest

        public void YouTubeAccessControlTest() {
            Tracing.TraceMsg("Entering YouTubeAccessControlTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);
            YouTubeRequest f = new YouTubeRequest(settings);

            Video v = new Video();
            v.Title = "Sample upload";
            v.Description = "This is a test with different access control values";

            MediaCategory category = new MediaCategory("Nonprofit");
            category.Attributes["scheme"] = YouTubeService.DefaultCategory;
            v.Tags.Add(category);
            v.Keywords = "math";
            v.YouTubeEntry.MediaSource = new MediaFileSource(Path.Combine(this.resourcePath, "test_movie.mov"), "video/quicktime");

            v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.RateAction, YtAccessControl.DeniedPermission));
            v.YouTubeEntry.AccessControls.Add(new YtAccessControl(YtAccessControl.CommentAction, YtAccessControl.ModeratedPermission));

            Video newVideo = f.Upload(this.ytUser, v);
            ExtensionCollection<YtAccessControl> acl = newVideo.YouTubeEntry.AccessControls;
            for (int i = 0; i < acl.Count; i++) {
                YtAccessControl ac = acl[i];
                switch (ac.Action) {
                    case YtAccessControl.RateAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.DeniedPermission, "Rating should be denied");
                        break;
                    case YtAccessControl.CommentAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Comments should be moderated");
                        break;
                    case YtAccessControl.CommentVoteAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Comment rating should be allowed");
                        break;
                    case YtAccessControl.VideoRespondAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.ModeratedPermission, "Video responses should be moderated");
                        break;
                    case YtAccessControl.ListAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video listing should be allowed");
                        break;
                    case YtAccessControl.EmbedAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video embed should be allowed");
                        break;
                    case YtAccessControl.SyndicateAction:
                        Assert.AreEqual(ac.Permission, YtAccessControl.AllowedPermission, "Video syndicate should be allowed");
                        break;
                }
            }

            f.Delete(newVideo);
        }
开发者ID:saeedesmaeili,项目名称:google-gdata,代码行数:50,代码来源:youtubetest.cs

示例8: YoutubeUpload

        }//OK 22.05.2014
        #endregion

        private void YoutubeUpload()
        {
            try
            {
                listBox1.Items.Add(DateTime.Now.ToString()+" "+videoismi + " Yükleniyor..");
                Random a = new Random();
                string id = a.Next(100000, 999999).ToString();
                YouTubeRequestSettings settings = new YouTubeRequestSettings(id, developerkey, hesapadi, hesapsifresi);
                YouTubeRequest request = new YouTubeRequest(settings);

                Video newVideo = new Video();
                ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
                newVideo.Title = videoadi;
                string cat = "Entertainment";
                if (videoismi.Contains("liveleak"))
                    cat = "News";
                newVideo.Tags.Add(new MediaCategory(cat, YouTubeNameTable.CategorySchema));
                newVideo.Keywords = etiket;
                newVideo.Description = aciklama;
                newVideo.YouTubeEntry.Private = false;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoismi, "video/x-flv");

                request.Upload(newVideo);
                listBox1.Items.Add(DateTime.Now.ToString() + "   " + videoismi);
            }
            catch (Exception ex)
            {
                richTextBox4.Text += ex.ToString();
                AppendText(richTextBox1, Color.Red, kimde + " Yükleme Hatası." + Environment.NewLine);
            }
        }
开发者ID:voyl,项目名称:myprojects,代码行数:34,代码来源:Form1.cs

示例9: YoutubeUpload

        private void YoutubeUpload()
        {
            hesapadi = textBox1.Text;
            hesapsifresi = textBox2.Text;
            developerkey = textBox3.Text;
            try
            {
                listBox1.Items.Add(DateTime.Now.ToString() + " Video Yükleniyor..");
                Random a = new Random();
                string id = a.Next(100000, 999999).ToString();
                YouTubeRequestSettings settings = new YouTubeRequestSettings(id, developerkey, hesapadi, hesapsifresi);
                YouTubeRequest request = new YouTubeRequest(settings);

                Video newVideo = new Video();
                ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 9999999;
                newVideo.Title = videoadi;
                newVideo.Tags.Add(new MediaCategory("News", YouTubeNameTable.CategorySchema));
                newVideo.Keywords = etiket;
                if (checkBox1.Checked)
                    aciklama += richTextBox2.Text;
                newVideo.Description = aciklama;
                newVideo.YouTubeEntry.Private = false;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoismi, "video/x-flv");

                request.Upload(newVideo);
                listBox1.Items.Add(DateTime.Now.ToString() + "   " + videoismi);
            }
            catch (Exception ex)
            {
                richTextBox1.Text += ex.ToString();
            }
        }
开发者ID:voyl,项目名称:myprojects,代码行数:32,代码来源:Form1.cs

示例10: UploadToYoutube

        private bool UploadToYoutube(string filename)
        {
            try
            {
                YouTubeRequestSettings ytsettings = new YouTubeRequestSettings("SonetReach", "AI39si4bVFP9AaDQuM12V5xTGF-pj87bxWApjm3KReLJFl67kkFfq3Jn32DikSJzRrqGo8mYY7Ww7XXD9JZDCezjMd9jUMtFCA", "[email protected]", "sonetreach123");
                ytsettings.Timeout = -1;
                YouTubeRequest ytReq = new YouTubeRequest(ytsettings);
                ((GDataRequestFactory)ytReq.Service.RequestFactory).Timeout = 60 * 60 * 1000;
                Video video = new Video();
                video.Title = "SonetReach";
                video.Description = "Uploaded by SonetReach";
                video.Tags.Add(new MediaCategory("Sports", YouTubeNameTable.CategorySchema));
                video.YouTubeEntry.Private = false;
                video.YouTubeEntry.MediaSource = new MediaFileSource(Server.MapPath("./Youtube/" + SessionData.UserAction.SiteID1 + "/" + filename), "video/mp4");
                Video createdVideo = ytReq.Upload(video);
                string videoID = createdVideo.VideoId;
                string youtubelink = "http://www.youtube.com/watch?v=" + videoID;
                commonUtil.SendInfoMail("Your Youtube video is uploaded at :" + youtubelink, "Your Youtube Video", "", SessionData.Customer.SCustomerEmail);

                return true;
            }
            catch (Exception ex)
            {
                commonUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID);
            }
            return true;
        }
开发者ID:apreshchandra,项目名称:Test,代码行数:27,代码来源:CanvasAreaMuSite.aspx.cs

示例11: bw_DoWork

 private void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     YouTubeRequest req = new YouTubeRequest(mYoutubeReqSettings);
     try
     {
         req.Upload(uploadVideo);
     }
     catch (Google.GData.Client.GDataRequestException re)
     {
         MessageBox.Show("Youtube server is not avaiable!");
         e.Result = false;
     }
     e.Result = true;
 }
开发者ID:episodka,项目名称:mcg9,代码行数:14,代码来源:YouViewerUploadWindow.xaml.cs

示例12: Upload

        private static void Upload()
        {
            UserState us = UploadFiles.Dequeue();
            //Console.WriteLine("youtube: upload " + us.AbsoluteFilePath);

            var settings = new YouTubeRequestSettings("iSpy", MainForm.Conf.YouTubeKey, MainForm.Conf.YouTubeUsername, MainForm.Conf.YouTubePassword);
            var request = new YouTubeRequest(settings);

            var v = new Google.YouTube.Video
                        {
                            Title = "iSpy: " + us.CameraData.name,
                            Description = MainForm.Website+": free open source surveillance software: " +
                                          us.CameraData.description
                        };
            if (us.CameraData == null)
            {
                if (UploadFiles.Count > 0)
                    Upload();
                return;
            }
            v.Keywords = us.CameraData.settings.youtube.tags;
            if (v.Keywords.Trim() == "")
                v.Keywords = "ispyconnect"; //must specify at least one keyword
            v.Tags.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.YouTubeEntry.Private = !us.Ispublic;
            v.Media.Categories.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.Private = !us.Ispublic;
            v.Author = "iSpyConnect.com - Camera Security Software (open source)";

            if (us.EmailOnComplete != "")
                v.Private = false;

            string contentType = MediaFileSource.GetContentTypeForFileName(us.AbsoluteFilePath);
            v.YouTubeEntry.MediaSource = new MediaFileSource(us.AbsoluteFilePath, contentType);

            // add the upload uri to it
            //var link =
            //    new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" +
            //                 MainForm.Conf.YouTubeAccount + "/uploads") {Rel = ResumableUploader.CreateMediaRelation};
            //v.YouTubeEntry.Links.Add(link);

            bool success = false;
            ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 60 * 60 * 1000;
            Google.YouTube.Video vCreated = null;
            try
            {
                vCreated = request.Upload(v);
                success = true;
            }
            catch (GDataRequestException ex1)
            {
                Log.Error("YouTube Uploader: " + ex1.ResponseString+" ("+ex1.Message+")");
                if (ex1.ResponseString=="NoLinkedYouTubeAccount")
                {
                    Log.Warn(
                        "This is because the Google account you connected has not been linked to YouTube yet. The simplest way to fix it is to simply create a YouTube channel for that account: http://www.youtube.com/create_channel");
                }
            }
            catch (Exception ex)
            {
                Log.Error("",ex);//MainForm.LogExceptionToFile(ex);
            }
            if (success)
            {
                //Console.WriteLine("Uploaded: http://www.youtube.com/watch?v=" + vCreated.VideoId);

                string msg = "YouTube video uploaded: <a href=\"http://www.youtube.com/watch?v=" + vCreated.VideoId + "\">" +
                                vCreated.VideoId + "</a>";
                if (vCreated.Private)
                    msg += " (private)";
                else
                    msg += " (public)";
                Log.Info(msg);

                if (us.EmailOnComplete != "" && us.Ispublic)
                {
                    SendYouTubeMails(us.EmailOnComplete, us.Message, vCreated.VideoId);
                }
                //check against most recent uploaded videos
                MainForm.Conf.UploadedVideos += "," + us.AbsoluteFilePath + "|" + vCreated.VideoId;
                if (MainForm.Conf.UploadedVideos.Length > 10000)
                    MainForm.Conf.UploadedVideos = "";
            }
            if (UploadFiles.Count>0)
                Upload();
        }
开发者ID:vmail,项目名称:main,代码行数:86,代码来源:YouTubeUploader.cs

示例13: Upload

        private static void Upload(object state)
        {
            if (UploadList.Count == 0)
            {
                _uploading = false;
                return;
            }

            UserState us;

            try
            {
                var l = UploadList.ToList();
                us = l[0];//could have been cleared by Authorise
                l.RemoveAt(0);
                UploadList = l.ToList();
            }
            catch
            {
                _uploading = false;
                return;
            }

            var settings = new YouTubeRequestSettings("iSpy", MainForm.Conf.YouTubeKey, MainForm.Conf.YouTubeUsername, MainForm.Conf.YouTubePassword);
            var request = new YouTubeRequest(settings);

            var v = new Google.YouTube.Video
                        {
                            Title = "iSpy: " + us.CameraData.name,
                            Description = MainForm.Website+": free open source surveillance software: " +
                                          us.CameraData.description
                        };
            if (us.CameraData == null)
            {
                if (UploadList.Count > 0)
                    Upload(null);
                return;
            }
            v.Keywords = us.CameraData.settings.youtube.tags;
            if (v.Keywords.Trim() == "")
                v.Keywords = "ispyconnect"; //must specify at least one keyword
            v.Tags.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.YouTubeEntry.Private = [email protected];
            v.Media.Categories.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.Private = [email protected];
            v.Author = "iSpyConnect.com - Camera Security Software (open source)";

            string contentType = MediaFileSource.GetContentTypeForFileName(us.Filename);
            v.YouTubeEntry.MediaSource = new MediaFileSource(us.Filename, contentType);

            // add the upload uri to it
            //var link =
            //    new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" +
            //                 MainForm.Conf.YouTubeAccount + "/uploads") {Rel = ResumableUploader.CreateMediaRelation};
            //v.YouTubeEntry.Links.Add(link);

            bool success = false;
            ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 60 * 60 * 1000;
            Google.YouTube.Video vCreated = null;
            try
            {
                vCreated = request.Upload(v);
                success = true;
            }
            catch (GDataRequestException ex1)
            {
                MainForm.LogErrorToFile("YouTube Uploader: " + ex1.ResponseString+" ("+ex1.Message+")");
                if (ex1.ResponseString=="NoLinkedYouTubeAccount")
                {
                    MainForm.LogMessageToFile(
                        "This is because the Google account you connected has not been linked to YouTube yet. The simplest way to fix it is to simply create a YouTube channel for that account: http://www.youtube.com/create_channel");
                }
            }
            catch (Exception ex)
            {
                MainForm.LogExceptionToFile(ex);
            }
            if (success)
            {

                string msg = "YouTube video uploaded: <a href=\"http://www.youtube.com/watch?v=" + vCreated.VideoId + "\">" +
                                vCreated.VideoId + "</a>";
                if (vCreated.Private)
                    msg += " (private)";
                else
                    msg += " (public)";
                MainForm.LogMessageToFile(msg);

                MainForm.Conf.UploadedVideos += "," + us.Filename + "|" + vCreated.VideoId;
                if (MainForm.Conf.UploadedVideos.Length > 1000)
                    MainForm.Conf.UploadedVideos = "";
            }
            Upload(null);
        }
开发者ID:WildGenie,项目名称:ispyconnect,代码行数:94,代码来源:YouTubeUploader.cs

示例14: CreateYoutubeVideo

        public static YouTubeVideo.Video CreateYoutubeVideo(string title, string keywords, string description, bool isPrivate, string FilePath, string fileName, string contentType)
        {
            //YouTubeRequestSettings settings = new YouTubeRequestSettings("Logicum", "YouTubeDeveloperKey", "YoutubeUserName", "YoutubePassword");
            //      YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "[email protected]", "[email protected]");
            YouTubeRequestSettings settings =
                //new YouTubeRequestSettings("Zerofootprint", "532982290458-ua1mk31m7ke3pee5vas9rcr6rgfcmavf.apps.googleusercontent.com","AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ");

            new YouTubeRequestSettings("mstest","AI39si7-2qSv3Kie2omUhQk4k_IvvOw6IjsBdXZCLCEv5ULvFPG3nVYG4hWNj_U-hLLksdJmWkBjvftq-sA50hgeBVlH_1k6KA","[email protected]", "[email protected]");

            YouTubeRequest request = new YouTubeRequest(settings);
            YouTubeVideo.Video newVideo = new YouTubeVideo.Video();
            newVideo.Title = title;
            newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
            newVideo.Keywords = keywords;
            newVideo.Description = description;
            newVideo.YouTubeEntry.Private = isPrivate;
            //newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag”, YouTubeNameTable.DeveloperTagSchema));
            // alternatively, you could just specify a descriptive string newVideo.YouTubeEntry.setYouTubeExtension(“location”, “Mountain View, CA”);
            //newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);

            newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath,contentType);
               // newVideo.YouTubeEntry.MediaSource = new MediaFileSource(stream, fileName, contentType);

            YouTubeVideo.Video createdVideo = request.Upload(newVideo);

            return createdVideo;
        }
开发者ID:gitAakash,项目名称:OMS,代码行数:27,代码来源:VideoController.cs

示例15: Save

        //,string JobId, string groupType, string groupname)
        public ActionResult Save(IEnumerable<HttpPostedFileBase> files, VideoModel video, string JobOptionValue)
        {
            //, string Title, string Reference, string HostPrimary, string HostPrimaryLink, string HostSecondary, string HostSecondaryLink, string Comments
            // string Title = ""; string Reference = ""; string HostPrimary = ""; string HostPrimaryLink = ""; string HostSecondary = ""; string HostSecondaryLink = ""; string Comments = "";

            // The Name of the Upload component is "files"

            try
            {

                int job_Id;
                bool res = int.TryParse(JobOptionValue, out job_Id);
                if (res)
                {
                    job_Id = (Convert.ToInt32(JobOptionValue));
                }

                if (files != null && (!string.IsNullOrEmpty(video.Title) && !string.IsNullOrEmpty(video.Status)))
                {
                    foreach (var file in files)
                    {
                        string strImgShowingRepositoryUrl = string.Empty;
                        string strFolder = string.Empty;

                        var fileName = Path.GetFileName(file.FileName);
                        strFolder = System.Configuration.ConfigurationManager.AppSettings["VideoUplaodLocation"];

                        if (video.Title.Contains("/"))
                        {
                            video.Title = video.Title.Replace("/", "-");
                        }

                        strFolder = strFolder + "/" + video.ClientId + "/" + video.Title + "/";
                        string FilePath = strFolder;
                        strImgShowingRepositoryUrl = System.Configuration.ConfigurationManager.AppSettings["VideoDisplayLocation"];

                        strFolder = strFolder + fileName.ToString();

                        if (System.IO.File.Exists(strFolder))
                        {
                            // rename file

                            string strRandomFileName = Path.GetRandomFileName(); //This method returns a random file name of 11 characters
                            string FileExtension = System.IO.Path.GetExtension(file.FileName);
                            string FileName = System.IO.Path.GetFileName(file.FileName);
                            int fileSize = file.ContentLength;

                            strRandomFileName = strRandomFileName.Replace(".", "") + FileExtension;
                            strImgShowingRepositoryUrl = strImgShowingRepositoryUrl + video.ClientId + "/" + video.Title + "/" + strRandomFileName.ToString();

                            strFolder = string.Empty;
                            strFolder = FilePath + strRandomFileName;
                            file.SaveAs(strFolder);

                            ////////////////////////////////////////////

                            //                         Google.YouTube.YouTubeRequestSettings settings =
                            //new Google.YouTube.YouTubeRequestSettings("Bobina Channel", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ");
                            //                         Google.YouTube.YouTubeRequest request = new Google.YouTube.YouTubeRequest(settings);

                            //                         Google.YouTube.Video newVideo = new Google.YouTube.Video();
                            //                         newVideo.Title = "test 1";
                            //                         //  newVideo.Tags.Add(new MediaCategory("Gaming", YouTubeNameTable.CategorySchema));
                            //                         newVideo.Keywords = "mstest1 , mstest2";

                            //                         newVideo.Description = "test 3 test 4";
                            //                         newVideo.YouTubeEntry.Private = false;
                            //                         Google.YouTube.Video createdVideo = request.Upload(newVideo);

                            ///////////////////////////////////////////

                            //---------------------------------------------------------------

                            YouTubeRequestSettings settings =
              new YouTubeRequestSettings("Zerofootprint", "532982290458-ua1mk31m7ke3pee5vas9rcr6rgfcmavf.apps.googleusercontent.com", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ");
                            YouTubeRequest request = new YouTubeRequest(settings);

                            //YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "[email protected]", "[email protected]");
                            //YouTubeRequest request = new YouTubeRequest(settings);

                            Google.YouTube.Video newVideo = new Google.YouTube.Video();

                            newVideo.Title = "ms test";
                            newVideo.Tags.Add(new MediaCategory("Autos", Google.GData.YouTube.YouTubeNameTable.CategorySchema));
                            newVideo.Keywords = "mstest";
                            newVideo.Description = "mstest";
                            newVideo.YouTubeEntry.Private = false;
                            //newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag",
                            //  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 Google.GData.Client.MediaFileSource(strFolder,
                              "video/quicktime");

                            Google.YouTube.Video createdVideo = request.Upload(newVideo);

//.........这里部分代码省略.........
开发者ID:gitAakash,项目名称:OMS,代码行数:101,代码来源:VideoController.cs


注:本文中的YouTubeRequest.Upload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。