示例#1
0
        public void YouTubeRequestInsertTest()
        {
            Tracing.TraceMsg("Entering YouTubeRequestInsertTest");

            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 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(Path.Combine(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(Path.Combine(this.resourcePath, "test.mp4"), "video/mp4");
            Video last = f.Update(updatedVideo);

            f.Delete(last);
        }
示例#2
0
        public bool UploadVideoToYouTube(YoutubeVideo video, out string videoId, string userName = "", string password = "")
        {
            //to upload video onto youtube, the video must have atleast 1 category
            videoId = string.Empty;
            if (video.Categories == null || video.Categories.Count == 0)
            {
                return(false);
            }

            var settings = new YouTubeRequestSettings(_applicationName, _developerKey,
                                                      string.IsNullOrEmpty(userName) ? _userName : userName,
                                                      string.IsNullOrEmpty(password) ? _password : password)
            {
                Timeout = 100000000
            };

            var request = new YouTubeRequest(settings);

            var newVideo = new Video {
                Title = video.Title, Description = video.Description
            };

            foreach (var category in video.Categories)
            {
                newVideo.Tags.Add(new MediaCategory(category, YouTubeNameTable.CategorySchema));
            }

            foreach (var tag in video.Tags)
            {
                newVideo.Tags.Add(new MediaCategory(tag, YouTubeNameTable.DeveloperTagSchema));
            }

            newVideo.Keywords                 = video.Tags.Any() ? String.Join(",", video.Tags.ToArray()) : string.Empty;
            newVideo.Private                  = true;
            newVideo.YouTubeEntry.Private     = false;
            newVideo.YouTubeEntry.Location    = new GeoRssWhere(video.Latitude, video.Longitude);
            newVideo.YouTubeEntry.MediaSource = new MediaFileSource(video.LocalFilePath, "video/wmv");

            try
            {
                Video createdVideo = request.Upload(newVideo);
                videoId = createdVideo.Id;
                return(true);
            }
            catch (Exception ex)
            {
            }

            return(false);
        }
示例#3
0
文件: up.cs 项目: voyl/myprojects
        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);
        }
 protected void btnUploadYTVideo_Click(object sender, EventArgs e)
 {
     YouTubeRequestSettings ytsettings = new YouTubeRequestSettings("SonetReach", "AI39si4bVFP9AaDQuM12V5xTGF-pj87bxWApjm3KReLJFl67kkFfq3Jn32DikSJzRrqGo8mYY7Ww7XXD9JZDCezjMd9jUMtFCA", "*****@*****.**", "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;
 }
        static void UploaderDoWork(object sender, DoWorkEventArgs e)
        {
            var request  = new YouTubeRequest(settings);
            var newVideo = new Video {
                Title = "Test"
            };

            newVideo.Tags.Add(new MediaCategory("Animals", YouTubeNameTable.CategorySchema));
            newVideo.Description              = "Testing Testing Testing";
            newVideo.YouTubeEntry.Private     = true;
            newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\Wildlife.wmv", "video/x-ms-wmv");
            try
            {
                request.Upload(newVideo);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Upload failed: " + exception.Message);
            }
        }
示例#6
0
        /**
         * Upload the finished movie to YouTube
         * @param user The username to use
         * @param pass The password to use
         * @param videotitle The video title to use
         * @param description The description to use
         * @return void
         * @note Pro and Developer Version only
         */
        public void Upload(string user, string pass, string videotitle, string description)
        {
            YouTubeRequestSettings settings = new YouTubeRequestSettings("VidLapse", _youtubekey, user, pass);
            YouTubeRequest         request  = new YouTubeRequest(settings);

            Video vid = new Video();

            vid.Title                = videotitle;
            vid.Description          = description;
            vid.YouTubeEntry.Private = false;
            if (SaveToDesktop)
            {
                vid.YouTubeEntry.MediaSource = new MediaFileSource(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "/" + _Filename + ".avi", "video/avi");
            }
            else
            {
                vid.YouTubeEntry.MediaSource = new MediaFileSource(_fullpath + "/" + _Filename + ".avi", "video/avi");
            }
            Video complete = request.Upload(vid);
        }
        public static void UploadVideo()
        {
            try
            {
            //                string developerKey = "AI39si72llWnlwlqjLA1XPfT1uz-ryd6n8Yb9KgjoHsjHda3tn5fANjJ1Ys73SFRUp0aV7oxdJESkICc1jveiBb4tD-zvKZnfw";
                String developerKey = "AIzaSyAWcrKx4meD6r3-SixVEMaMf_PCvUwA-rE";
                string username = "******";
                string password = "******";
                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);
            }
        }
示例#8
0
        public override void Perform()
        {
            try
            {
                UseSavedAuthorization();

                Video newVideo = new Video();
                newVideo.Title = videoTitle;
                newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
                newVideo.Description              = description;
                newVideo.YouTubeEntry.Private     = false;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoPath, "video/mp4");

                Video createdVideo = request.Upload(newVideo);

                ErrorLog.AddError(ErrorType.Message, string.Format(Strings.YouTube_UploadSuccesful, videoTitle));
            }
            catch (Exception ex)
            {
                ErrorLog.AddError(ErrorType.Failure, string.Format(Strings.YouTube_UploadFailed, videoTitle));
                Logger.Write(ex);
            }
        }
示例#9
0
        public static string UploadVideo(string FilePath, string Title, string Description)
        {
            YouTubeRequestSettings settings;
            YouTubeRequest         request;
            string devkey   = "AIzaSyAijRdjujLWtxE2cz5OcvH7pxEVlLMYQuI"; //Api Key
            string username = "******";                              //Kullanıcı adı
            string password = "******";                             //Kullanıcı şifre

            settings = new YouTubeRequestSettings("Haadi Canim Browser", devkey, username, password)
            {
                Timeout = -1
            };
            request = new YouTubeRequest(settings);

            //settings.Timeout = 1;

            Video newVideo = new Video();

            newVideo.Title                = Title;
            newVideo.Description          = Description;
            newVideo.Private              = true;
            newVideo.YouTubeEntry.Private = false;

            //newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));

            //newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));

            //newVideo.YouTubeEntry.setYouTubeExtension("location", "Paris, FR");
            // You can also specify just a descriptive string ==>
            // newVideo.YouTubeEntry.Location = new GeoRssWhere(71, -111);
            // newVideo.YouTubeEntry.setYouTubeExtension("location", "Paris, France.");

            newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/mp4");
            Video createdVideo = request.Upload(newVideo);

            return(createdVideo.VideoId);
        }
示例#10
0
文件: Form1.cs 项目: voyl/myprojects
        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();
        }
示例#11
0
        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);
        }
示例#12
0
        //,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]");
                            //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);

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

                            //var clients = _videoService.GetVideos(string.Empty, int.Parse(id)).ToList();

                            //int client_Id, string title, string fileName, string fileExtension, int fileSize, string files3location,
                            //    string reference, string host_Primary, string hostPrimaryLink, string hostSecondary, string hostSecondaryLink, string comments,
                            //    string status, bool isDeleted = false

                            if (video.Row_Id > 0)
                            {
                                _videoService.UpdateVideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl,
                                    video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, video.Row_Id, job_Id);
                            }
                            else
                            {
                                _videoService.Insertvideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, false, job_Id);
                            }
                            //_repository.InsertJobAttachment(JobId, groupType, groupname, strRandomFileName, FileExtension, fileSize, selectedTags, strImgShowingRepositoryUrl, FileName);

                            // this will rutund the exist file
                        }
                        else
                        {
                            DirectoryInfo diPath = new DirectoryInfo(FilePath);
                            diPath.Create();
                            strImgShowingRepositoryUrl = strImgShowingRepositoryUrl + video.ClientId + "/" + video.Title + "/" + fileName.ToString();

                            string FileExtension = System.IO.Path.GetExtension(file.FileName);
                            string FileName = System.IO.Path.GetFileName(file.FileName);
                            int fileSize = file.ContentLength;

                            file.SaveAs(strFolder);

                            /////////////////////////// working except upload////////////////

                            //YouTubeRequestSettings settings = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "*****@*****.**", "[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);

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

                            //Google.YouTube.YouTubeRequestSettings settings =
                            //new Google.YouTube.YouTubeRequestSettings("Bobina Channel", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ");
                            //YouTubeRequest request = new 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);

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

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

                            //                            var settings1 = new YouTubeRequestSettings("Zerofootprint", "AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ", "*****@*****.**"
                            //, "[email protected]");
                            //                            var youTubeRequest = new YouTubeRequest(settings1);
                            //                           Google.YouTube.Video  video1 = new Google.YouTube.Video();

                            //                            video1.Title = "First Test 1";
                            //                            video1.Keywords = "O2 Test";
                            //                           // MediaCategory category = new MediaCategory("Technology");
                            //                          //  category.Attributes["scheme"] = YouTubeService.DefaultCategory;
                            //                          //  video1.Tags.Add(category);
                            //                             video1.MediaSource = new Google.GData.Client.MediaFileSource(strFolder, "video/avi");
                            //                             youTubeRequest.Upload(video1);
                            //                            //--------------------------------------------------------------------------------------------

                            //                        YouTubeRequestSettings settings = new YouTubeRequestSettings(
                            //"whatwill come here ?",
                            //"AIzaSyBM80iRA-wuMScreXvI2TfIkTncdt9Mx2s",
                            //"*****@*****.**",
                            //"[email protected]");
                            //                        YouTubeRequest request = new 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;
                            //                        //newVideo.Tags.Add(new MediaCategory("tag 1, tag 2",
                            //                        //  Google.GData.YouTube.YouTubeNameTable.DeveloperTagSchema));

                            //                        //   newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);

                            //                        newVideo.YouTubeEntry.MediaSource = new MediaFileSource(strFolder, "video/quicktime");

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

                         //   byte[] bytes = System.IO.File.ReadAllBytes(strFolder);

                            CreateYoutubeVideo(video.Title, video.Title, video.Comments, false, strFolder, file.FileName, "video/quicktime");

                            if (video.Row_Id > 0)
                            {
                                _videoService.UpdateVideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl,
                                    video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, video.Row_Id, job_Id);
                            }
                            else
                            {
                                _videoService.Insertvideo(Convert.ToInt32(video.ClientId), video.Title, FileName, FileExtension, fileSize, strImgShowingRepositoryUrl, video.Reference, video.HostPrimary, video.HostPrimaryLink, video.HostSecondary, video.HostSecondaryLink, video.Comments, video.Status, false, job_Id);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                #region For Error

                string ErrorMsg = ex.Message;
                string Error = ErrorMsg;

                if (!string.IsNullOrEmpty(ErrorMsg))
                {
                    switch (Error)
                    {
                        case "FileExist":
                            return Json(new DataSourceResult
                            {
                                // Errors = "You cannot change the organizer of an instance."
                                Errors = "CustomError400"
                            });

                        case "CustomError401":
                            return Json(new DataSourceResult
                            {
                                //Errors = "You cannot turn an instance of a recurring event into a recurring event itself."
                                Errors = "CustomError401"
                            });

                        case "Null_Event":
                            return Json(new DataSourceResult
                            {
                                Errors = "Null_Event"
                            });

                        //default:
                        //         Logger(ex.InnerException.Message);
                        //         return Json(new DataSourceResult
                        //    {

                        //        Errors = string.Empty
                        //    });
                    }
                }
                else
                {
                    return Json(new DataSourceResult
                    {
                        Errors = ""
                    });
                }
                #endregion
            }

            //var currentUser = UserManager.Current();
            //if (currentUser != null)
            //{
            //    var videomodel = _videoService.GetVideos(string.Empty, (video.ClientId)).ToList();
            //    return PartialView("Controls/Video/_VideoList", videomodel);

            //}
            //return null;

            return Content("");
        }
示例#13
0
        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);
        }
示例#14
0
文件: Form1.cs 项目: voyl/myprojects
        }//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);
            }
        }
示例#15
0
文件: Form1.cs 项目: voyl/myprojects
        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();
            }
        }
示例#16
0
        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 = !us.CameraData.settings.youtube.@public;
            v.Media.Categories.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.Private = !us.CameraData.settings.youtube.@public;
            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);
        }
示例#17
0
        private bool UploadToYoutube(string filename)
        {
            try
            {
                YouTubeRequestSettings ytsettings = new YouTubeRequestSettings("SonetReach", "AI39si4bVFP9AaDQuM12V5xTGF-pj87bxWApjm3KReLJFl67kkFfq3Jn32DikSJzRrqGo8mYY7Ww7XXD9JZDCezjMd9jUMtFCA", "*****@*****.**", "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;
        }
示例#18
0
        public static void UploadVideo(string usernam, string apikey, string FilePath, string Title, string Description, string Category, bool privatevid, string Keywords)
        {
            //Console.WriteLine("Начало загрузки видео - " + Title);
            Console.WriteLine("Загрузка " + Title);
            YouTubeRequestSettings settings;
            YouTubeRequest         request;
            string devkey   = apikey;
            string username = usernam;
            string password = passwa;

            settings = new YouTubeRequestSettings(usernam, devkey, username, password)
            {
                Timeout = -1
            };
            request = new YouTubeRequest(settings);
            ((GDataRequestFactory)request.Service.RequestFactory).Timeout   = 9999999;
            ((GDataRequestFactory)request.Service.RequestFactory).KeepAlive = false;
            Video newVideo = new Video();


            newVideo.Title = Title;
            if (Title.Length > 100)
            {
                newVideo.Title = Title.Substring(0, 99);
            }
            newVideo.Tags.Add(new MediaCategory(Category, YouTubeNameTable.CategorySchema));
            newVideo.Keywords             = Keywords.Replace("\"", "");
            newVideo.Description          = Description;
            newVideo.YouTubeEntry.Private = privatevid;
            //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");

labs1:
            try
            {
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/wmv"); //video/wmv video/mp4

                Video createdVideo = request.Upload(newVideo);
            }
            catch (Exception ex)
            {
                Console.WriteLine("");
                Console.WriteLine("*************************************");
                Console.WriteLine("***" + ex.Message + " - " + Title);
                Console.WriteLine("*************************************");
                Console.WriteLine("");
                if (ex.Message == "The operation has timed out")
                {
                    Console.WriteLine("Повторная загрузка " + Title);
                    goto labs1;
                }
                //
            }

            //Console.WriteLine("Конец загрузки видео - " + Title);
            //newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));

            //newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));

            //newVideo.YouTubeEntry.setYouTubeExtension("location", "Paris, FR");
            // You can also specify just a descriptive string ==>
            // newVideo.YouTubeEntry.Location = new GeoRssWhere(71, -111);
            // newVideo.YouTubeEntry.setYouTubeExtension("location", "Paris, France.");
        }
示例#19
0
        public ActionResult Create([Bind(Include = "VideoID,Name,Description,VideoPath,FileExt,UserID,Dou")] learnersmate.Models.Video video, HttpPostedFileBase uploadvideo, string newlogo, bool IsYoutube)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            if (newlogo == "")
            {
                Session["err"] = "Video required";
                data.message   = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (newlogo != "")
                {
                    video.VideoPath = newlogo;
                    var extention = Path.GetExtension(newlogo);
                    video.FileExt = extention;
                }
                db.Videos.Add(video);
                db.SaveChanges();

                if (IsYoutube)
                {
                    try
                    {
                        //////ref https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=webbased-document-management
                        ///https://console.developers.google.com/apis/credentials?project=webbased-document-management
                        ///https://www.slickremix.com/docs/get-api-key-for-youtube/
                        YouTubeRequestSettings settings;
                        YouTubeRequest         request;
                        string devkey   = ConfigurationManager.AppSettings.Get("youtubedevkey");
                        string username = ConfigurationManager.AppSettings.Get("youtubeusername");
                        string password = ConfigurationManager.AppSettings.Get("youtubepassword");

                        string filepath = Server.MapPath("/" + newlogo.PadLeft(1).Replace("/", "\\"));
                        settings = new YouTubeRequestSettings("education", devkey, username, password)
                        {
                            Timeout = 999999999
                        };
                        request = new YouTubeRequest(settings);
                        Google.YouTube.Video videoyoutube = new Google.YouTube.Video();
                        videoyoutube.Title       = video.Name;
                        videoyoutube.Description = video.Description;
                        videoyoutube.Tags.Add(new MediaCategory("Education", YouTubeNameTable.CategorySchema));
                        videoyoutube.Keywords    = "Education";
                        videoyoutube.Private     = false;
                        videoyoutube.MediaSource = new MediaFileSource(filepath, "video/flv");
                        Google.YouTube.Video createdVideo = request.Upload(videoyoutube); //In that createdVideo you will get uploaded video ID.

                        video.YoutubePath     = createdVideo.VideoId;
                        db.Entry(video).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception exception)

                    {
                        Session["msg"] = "Cant upload youtube, Please check youtube api settings" + exception.Message;
                    }
                }

                Session["err"]  = "";
                Session["msg"] += "Created Successfully";
            }



            data.message = "/Video/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
示例#20
0
 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;
 }
示例#21
0
        public void DealWithRequest()
        {
            while (ol.IsListening)
            {
                //receive files via bluetooth
                try
                {
                    ObexListenerContext olc = ol.GetContext();
                    ObexListenerRequest olr = olc.Request;

                    string filename = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) +
                                      "\\" +
                                      DateTime.Now.ToString("dd-MM-yy HHmm") +
                                      " " +
                                      Uri.UnescapeDataString(olr.RawUrl.TrimStart(new char[] { '/' }));
                    //remove newline
                    filename = filename.Substring(0, filename.Length - 1);
                    Console.Write("filetype: " + filename.Substring(filename.Length - 3, 3));
                    olr.WriteFile(filename);

                    //add filename to fileList
                    DoFileListUpdate(filename);

                    if (filename.Substring(filename.Length - 3, 3).Equals("jpg") ||
                        filename.Substring(filename.Length - 3, 3).Equals("JPG") ||
                        filename.Substring(filename.Length - 3, 3).Equals("png") ||
                        filename.Substring(filename.Length - 3, 3).Equals("PNG") ||
                        filename.Substring(filename.Length - 3, 3).Equals("GIF") ||
                        filename.Substring(filename.Length - 3, 3).Equals("gif"))
                    {
                        //image upload to picasa

                        Uri postUri = new Uri(PicasaQuery.CreatePicasaUri(username, albumid));

                        System.IO.FileInfo   fileInfo   = new System.IO.FileInfo(filename);
                        System.IO.FileStream fileStream = fileInfo.OpenRead();
                        PicasaEntry          entry      = (PicasaEntry)picasaService.Insert(postUri, fileStream, "image/jpeg", filename);
                        fileStream.Close();
                        //image properties
                        entry.Title.Text   = "Gogbot09: " + olr.RawUrl.TrimStart(new char[] { '/' });
                        entry.Summary.Text = "User content for GOGBOT 2009 festival, provided by bluetooth device: " +
                                             olr.UserHostAddress +
                                             " on: " +
                                             DateTime.Now.ToString("dd-MM-yy HHmm");
                        entry.Media.Keywords.Value = "gogbot, GOGBOT09, gogbot2009, bluetube";
                        //entry.Location = new GeoRssWhere();
                        //entry.Location.Latitude = 37;
                        //entry.Location.Longitude = -122;

                        PicasaEntry updatedEntry = (PicasaEntry)entry.Update();
                        Console.WriteLine("Photo: " + olr.RawUrl.TrimStart(new char[] { '/' }) + " uploaded.");
                    }
                    else
                    {
                        //upload video to youtube
                        Video newVideo = new Video();

                        newVideo.Title = "Gogbot09: " + olr.RawUrl.TrimStart(new char[] { '/' });
                        newVideo.Tags.Add(new MediaCategory("People", YouTubeNameTable.CategorySchema));
                        newVideo.Keywords    = "gogbot, GOGBOT09, gogbot2009, bluetube";
                        newVideo.Description = "User content for GOGBOT 2009 festival, provided by bluetooth device: " +
                                               olr.UserHostAddress +
                                               " on: " +
                                               DateTime.Now.ToString("dd-MM-yy HHmm");
                        newVideo.YouTubeEntry.Private = false;
                        newVideo.Tags.Add(new MediaCategory("uploaded_through_bluetube",
                                                            YouTubeNameTable.DeveloperTagSchema));

                        //newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
                        // alternatively, you could just specify a descriptive string
                        newVideo.YouTubeEntry.setYouTubeExtension("location", "Vrije Universiteit, Amsterdam");

                        newVideo.YouTubeEntry.MediaSource = new MediaFileSource(filename, "video/3gpp");
                        Video video = request.Upload(newVideo);

                        //Check status
                        if (video.IsDraft)
                        {
                            Console.WriteLine("Video is not live.");
                            string stateName = video.Status.Name;
                            if (stateName == "processing")
                            {
                                Console.WriteLine("Video is still being processed.");
                            }
                            else if (stateName == "rejected")
                            {
                                Console.Write("Video has been rejected because: ");
                                Console.WriteLine(video.Status.Value);
                                Console.Write("For help visit: ");
                                Console.WriteLine(video.Status.Help);
                            }
                            else if (stateName == "failed")
                            {
                                Console.Write("Video failed uploading because:");
                                Console.WriteLine(video.Status.Value);
                                Console.Write("For help visit: ");
                                Console.WriteLine(video.Status.Help);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
示例#22
0
        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();
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <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);
        }
示例#24
0
        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]");
            YouTubeRequestSettings settings =
                //new YouTubeRequestSettings("Zerofootprint", "532982290458-ua1mk31m7ke3pee5vas9rcr6rgfcmavf.apps.googleusercontent.com","AI39si5uAJcnGQWqT7bOooT00fTbkCsMjImXlYoyZpkArc49nQvQF-UhxIQDUpwoLxdvf85t97K3wUP2SDrdm1Q8IchJT5mYgQ");

            new YouTubeRequestSettings("mstest","AI39si7-2qSv3Kie2omUhQk4k_IvvOw6IjsBdXZCLCEv5ULvFPG3nVYG4hWNj_U-hLLksdJmWkBjvftq-sA50hgeBVlH_1k6KA","*****@*****.**", "[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;
        }
示例#25
0
文件: Form2.cs 项目: voyl/myprojects
        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);
            }
        }
示例#26
0
        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 = !us.CameraData.settings.youtube.@public;
            v.Media.Categories.Add(new MediaCategory(us.CameraData.settings.youtube.category));
            v.Private = !us.CameraData.settings.youtube.@public;
            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);
        }
示例#27
0
        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)
            {
                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)
            {
                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)";
                MainForm.LogMessageToFile(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();
        }
示例#28
0
文件: Form1.cs 项目: voyl/myprojects
        private void YoutubeUpload()
        {
            youtubesonuc = true;
            tsdurum2.Text = "Video Yükleniyor..";
            try
            {
                VideoAdı = txvideoadi.Text;
                Açıklama = txaciklama.Text;
                etiketler = txetiket.Text;
                Random a = new Random();
                string id = textBox1.Text + 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 = VideoAdı;
                newVideo.Tags.Add(new MediaCategory(VideoTur(comboBox1.Text), YouTubeNameTable.CategorySchema));
                newVideo.Keywords = etiketler;
                newVideo.Description = Açıklama;
                if (Gizlilik() == 1)
                    newVideo.YouTubeEntry.Private = false;
                else
                    newVideo.YouTubeEntry.Private = true;
                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(videoismi, "video/x-flv");

                request.Upload(newVideo);
            }
            catch (Exception ex)
            {
                hata += ex.ToString();
                tsdurum2.Text = "Hata.";
                youtubesonuc = false;
            }
            if (radioButton4.Checked)
                VideoDelete();
        }