public static YouTubeRequest GetRequest1() { YouTubeRequestSettings settings = new YouTubeRequestSettings("LifeTube", ConfigurationManager.AppSettings["YouTubeAPIKey"], ConfigurationManager.AppSettings["YouTubeUsername"], ConfigurationManager.AppSettings["YouTubePassword"]); YouTubeRequest request = new YouTubeRequest(settings); Google.YouTube.Video newVideo = new Google.YouTube.Video(); newVideo.Title = "My first Movie"; newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema)); newVideo.Keywords = "cars, funny"; newVideo.Description = "My description"; newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema)); newVideo.YouTubeEntry.Private = false; newVideo.YouTubeEntry.setYouTubeExtension("location", "Somerville, MA"); var token = request.CreateFormUploadToken(newVideo); var strToken = token.Token; var strFormAction = token.Url + "?nexturl=http://[ LifeTube ]/form/post-video-step2.aspx?Complete=1"; //Session["YTRequest"] = request; return request; //return View(request); }
public static YouTubeVideo.Video CreateYoutubeVideo(string title, string keywords, string description, bool isPrivate, byte[] content, 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"); 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); Stream stream = new MemoryStream(content); newVideo.YouTubeEntry.MediaSource = new MediaFileSource(stream, fileName, contentType); YouTubeVideo.Video createdVideo = request.Upload(newVideo); return createdVideo; }
public static Google.YouTube.Video GetYouTubeVideo(string id = "") { try { // Initiate video object Google.YouTube.Video video = new Google.YouTube.Video(); // Initiate YouTube request object YouTubeRequestSettings settings = new YouTubeRequestSettings("eLocal", "AI39si6iCFZ_NutrvZe04i9_m7gFhgmPK1e7LF6-yHMAwB-GDO3vC3eD0R-5lberMQLdglNjH3IWUMe3tJXe9qrFe44n2jAUyg"); YouTubeRequest req = new YouTubeRequest(settings); // Create the URI and make request to YouTube Uri video_url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + id); video = req.Retrieve<Google.YouTube.Video>(video_url); return video; } catch (Exception) { return new Google.YouTube.Video(); } }
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(); }
public ActionResult VideoSubmit(string video, string videoType, string personType, string footageType, string band, string song, string contestID) { if (string.IsNullOrWhiteSpace(video)) { Response.Redirect("~/videosubmission.aspx?statustype=I"); return new EmptyResult(); } VideoRequest vir = new VideoRequest(); vir.RequestURL = video; string vidKey = string.Empty; vir.RequestURL = vir.RequestURL.Replace("https", "http"); if (vir.RequestURL.Contains("http://youtu.be/")) { vir.VideoKey = vir.RequestURL.Replace("http://youtu.be/", string.Empty); } else if (vir.RequestURL.Contains("http://www.youtube.com/watch?")) { NameValueCollection nvcKey = System.Web.HttpUtility.ParseQueryString(vir.RequestURL.Replace("http://www.youtube.com/watch?", string.Empty)); vir.VideoKey = nvcKey["v"]; vidKey = nvcKey["v"]; } else { // invalid vir.StatusType = 'I'; Response.Redirect("~/videosubmission.aspx?statustype=I"); return new EmptyResult(); } if (string.IsNullOrWhiteSpace(videoType) || string.IsNullOrWhiteSpace(personType) || string.IsNullOrWhiteSpace(footageType) || string.IsNullOrWhiteSpace(band) || string.IsNullOrWhiteSpace(song)) { // invalid vir.StatusType = 'P'; Response.Redirect("~/videosubmission.aspx?statustype=P"); return new EmptyResult(); } try { //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator(); //while (enumerator.MoveNext()) //{ // HttpContext.Current.Cache.Remove(enumerator.Key.ToString()); //} //Artists allartsis = new Artists(); //allartsis.RemoveCache(); //if (gvwRequestedVideos.SelectedDataKey != null) //{ // vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value)); // vidreq.StatusType = 'A'; // vidreq.Update(); //} BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", vidKey); vid.ProviderCode = "YT"; Google.YouTube.Video video2; video2 = new Google.YouTube.Video(); try { YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password); YouTubeRequest yourequest; Uri Url; yourequest = new YouTubeRequest(yousettings); Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vidKey); video2 = yourequest.Retrieve<Google.YouTube.Video>(Url); vid.Duration = (float)Convert.ToDouble(video2.YouTubeEntry.Duration.Seconds); vid.ProviderUserKey = video2.Uploader; vid.PublishDate = video2.YouTubeEntry.Published; } catch (GDataRequestException) { vid.IsEnabled = false; vid.Update(); //litVideo.Text = string.Empty; // return; // invalid vir.StatusType = 'I'; Response.Redirect("~/videosubmission.aspx?statustype=I"); return new EmptyResult(); } vid.VolumeLevel = 5; // vid.HumanType = personType; // t(string video, string videoType, string personType, //string footageType, string band, string song, string contestID) // vid.VideoType = videoType; //vid.Duration = (float)Convert.ToDouble(txtDuration.Text); //vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text); //vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text); //vid.ProviderCode = ddlVideoProvider.SelectedValue; //vid.ProviderUserKey = txtUserName.Text; //vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue); //vid.IsEnabled = chkEnabled.Checked; //// vid.IsHidden = chkHidden.Checked; //vid.EnableTrim = chkEnabled.Checked; ///// publish date //YouTubeRequestSettings yousettings = // new YouTubeRequestSettings("You Manager", devkey, username, password); //YouTubeRequest yourequest; //Uri Url; //yourequest = new YouTubeRequest(yousettings); //Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey); //video = new Google.YouTube.Video(); //video = yourequest.Retrieve<Google.YouTube.Video>(Url); //vid.PublishDate = video.YouTubeEntry.Published; if (string.IsNullOrWhiteSpace(vid.ProviderKey)) { // invalid vir.StatusType = 'I'; Response.Redirect("~/videosubmission.aspx?statustype=I"); return new EmptyResult(); } if (vid.VideoID == 0) { vid.IsHidden = false; vid.IsEnabled = true; vid.Create(); } else { vid.Update(); } // if there is a contest, add it now since there is an id int subContestID = 0; if (!string.IsNullOrWhiteSpace(contestID) && int.TryParse(contestID, out subContestID) && subContestID > 0) { //TODO: check if it already is in the contest ContestVideo.DeleteVideoFromAllContests(vid.VideoID); ContestVideo cv = new ContestVideo(); cv.ContestID = subContestID; cv.VideoID = vid.VideoID; cv.Create(); } else { // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL ContestVideo.DeleteVideoFromAllContests(vid.VideoID); } PropertyType propTyp = null; MultiProperty mp = null; // vid type propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID); // human propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID); // footage propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID); //// guitar //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue) // && this.ddlGuitarType.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID); //} //// Language //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue) // && this.ddlLanguage.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID); //} //// genre //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue) // && this.ddlGenre.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID); //} //// difficulty //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue) // && this.ddlDifficultyLevel.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID); //} //VideoSong.DeleteSongsForVideo(vid.VideoID); // song 1 Artist artst = new Artist(band.Trim()); if (artst.ArtistID == 0) { artst.GetArtistByAltname(band.Trim()); } if (artst.ArtistID == 0) { artst.Name = band.Trim(); artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } Song sng = new Song(artst.ArtistID, song.Trim()); if (sng.SongID == 0) { sng.Name = sng.Name.Trim(); sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1); // RefreshLists(); // lblStatus.Text = "OK"; if (vid.VideoID > 0) { Response.Redirect(vid.VideoURL);// just send them to it } } catch { // lblStatus.Text = ex.Message; //{ Response.Redirect("~/videosubmission.aspx?statustype=I"); return new EmptyResult(); //} } //Video v1 = new Video(); //if (!string.IsNullOrEmpty(vir.VideoKey)) //{ // v1 = new Video("YT", vir.VideoKey); //} //if (v1.VideoID > 0 && v1.IsEnabled) //{ // Response.Redirect(v1.VideoURL);// just send them to it // return new EmptyResult(); //} //vir.GetVideoRequest(); //if (vir.StatusType == 'W') //{ // Response.Redirect("~/videosubmission.aspx?statustype=W"); // return new EmptyResult(); //} //else if (vir.StatusType == 'R') //{ // Response.Redirect("~/videosubmission.aspx?statustype=R"); // return new EmptyResult(); //} //vir.StatusType = 'W'; //vir.Create(); // Response.Redirect("~/videosubmission.aspx?statustype=W"); // return new EmptyResult(); //if (vir.StatusType == 'W') //{ // Response.Redirect("~/videosubmission.aspx?statustype=W"); // return new EmptyResult(); //} //else if (vir.StatusType == 'R') //{ // Response.Redirect("~/videosubmission.aspx?statustype=R"); // return new EmptyResult(); //} //else //{ // v1 = new Video("YT", vir.VideoKey); // if (v1.VideoID > 0 && v1.IsEnabled) // { // Response.Redirect(v1.VideoURL);// just send them to it // } // else // { // vir.StatusType = 'W'; // vir.Create(); // Response.Redirect("~/videosubmission.aspx?statustype=W"); // return new EmptyResult(); // } //} return new EmptyResult(); }
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(); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator(); //while (enumerator.MoveNext()) //{ // HttpContext.Current.Cache.Remove(enumerator.Key.ToString()); //} Artists allartsis = new Artists(); allartsis.RemoveCache(); if (gvwRequestedVideos.SelectedDataKey != null) { vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value)); vidreq.StatusType = 'A'; vidreq.Update(); } vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", txtVideoKey.Text); vid.Duration = (float)Convert.ToDouble(txtDuration.Text); vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text); vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text); vid.ProviderCode = ddlVideoProvider.SelectedValue; vid.ProviderUserKey = txtUserName.Text; vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue); vid.IsEnabled = chkEnabled.Checked; // vid.IsHidden = chkHidden.Checked; vid.EnableTrim = chkEnabled.Checked; /// publish date YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password); YouTubeRequest yourequest; Uri Url; Google.YouTube.Video video; yourequest = new YouTubeRequest(yousettings); Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey); video = new Google.YouTube.Video(); video = yourequest.Retrieve<Google.YouTube.Video>(Url); vid.PublishDate = video.YouTubeEntry.Published; if (vid.VideoID == 0) { vid.Create(); } else vid.Update(); // if there is a contest, add it now since there is an id if (ddlContest.SelectedValue != unknownValue) { //TODO: check if it already is in the contest ContestVideo.DeleteVideoFromAllContests(vid.VideoID); ContestVideo cv = new ContestVideo(); cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue); cv.VideoID = vid.VideoID; cv.Create(); } else { // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL ContestVideo.DeleteVideoFromAllContests(vid.VideoID); } // vid type if (!string.IsNullOrWhiteSpace(this.ddlVideoType.SelectedValue) && this.ddlVideoType.SelectedValue != selectText) { propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo( Convert.ToInt32( ddlVideoType.SelectedValue), vid.VideoID); } // human if (!string.IsNullOrWhiteSpace(this.ddlHumanType.SelectedValue) && this.ddlHumanType.SelectedValue != selectText) { propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo( Convert.ToInt32( ddlHumanType.SelectedValue), vid.VideoID); } // footage if (!string.IsNullOrWhiteSpace(this.ddlFootageType.SelectedValue) && this.ddlFootageType.SelectedValue != selectText) { propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); mp.RemoveCache(); MultiPropertyVideo.AddMultiPropertyVideo( Convert.ToInt32( ddlFootageType.SelectedValue), vid.VideoID); } //// guitar //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue) // && this.ddlGuitarType.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID); //} //// Language //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue) // && this.ddlLanguage.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID); //} //// genre //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue) // && this.ddlGenre.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID); //} //// difficulty //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue) // && this.ddlDifficultyLevel.SelectedValue != selectText) //{ // propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC); // mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); // MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID); // mp.RemoveCache(); // MultiPropertyVideo.AddMultiPropertyVideo( // Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID); //} VideoSong.DeleteSongsForVideo(vid.VideoID); // song 1 if (string.IsNullOrEmpty(txtArtist1.Text.Trim())) { artst = new Artist(ddlArtist1.SelectedValue); } else { artst = new Artist(txtArtist1.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong1.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs1.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong1.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1); // song 2 if ((ddlArtist2.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist2.SelectedValue)) || !string.IsNullOrEmpty(txtArtist2.Text)) { artst = null; sng = null; if (string.IsNullOrEmpty(txtArtist2.Text.Trim())) { artst = new Artist(ddlArtist2.SelectedValue); } else { artst = new Artist(txtArtist2.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong2.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs2.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong2.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 2); if ((ddlArtist3.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist3.SelectedValue)) || !string.IsNullOrEmpty(txtArtist3.Text)) { // song 3 artst = null; sng = null; if (string.IsNullOrEmpty(txtArtist3.Text)) { artst = new Artist(ddlArtist3.SelectedValue); } else { artst = new Artist(txtArtist3.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong3.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs3.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong3.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 3); if ((ddlArtist4.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist4.SelectedValue)) || !string.IsNullOrEmpty(txtArtist4.Text)) { // song 4 artst = null; sng = null; if (string.IsNullOrEmpty(txtArtist4.Text)) { artst = new Artist(ddlArtist4.SelectedValue); } else { artst = new Artist(txtArtist4.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong4.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs4.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong4.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 4); if ((ddlArtist5.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist5.SelectedValue)) || !string.IsNullOrEmpty(txtArtist5.Text)) { // song 5 artst = null; sng = null; if (string.IsNullOrEmpty(txtArtist5.Text)) { artst = new Artist(ddlArtist5.SelectedValue); } else { artst = new Artist(txtArtist5.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong5.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs5.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong5.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 5); if ((ddlArtist6.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist6.SelectedValue)) || !string.IsNullOrEmpty(txtArtist6.Text)) { // song 6 artst = null; sng = null; if (string.IsNullOrEmpty(txtArtist6.Text)) { artst = new Artist(ddlArtist6.SelectedValue); } else { artst = new Artist(txtArtist6.Text); } if (artst.ArtistID == 0) { artst.AltName = FromString.URLKey(artst.Name); artst.Create(); } if (string.IsNullOrEmpty(txtArtistSong6.Text)) { sng = new Song(artst.ArtistID, ddlArtistSongs6.SelectedValue); } else { sng = new Song(artst.ArtistID, txtArtistSong6.Text); } if (sng.SongID == 0) { sng.SongKey = FromString.URLKey(sng.Name); sng.Create(); } VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 6); } } } } } // RefreshLists(); lblStatus.Text = "OK"; } catch (Exception ex) { lblStatus.Text = ex.Message; } LoadGrid(); }
private void LoadVideo(string videoKey) { ClearInput(); try { vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", videoKey); litVideo.Text = string.Format( @"<iframe width=""425"" height=""349"" src=""http://www.youtube.com/embed/{0}"" frameborder=""0"" allowfullscreen></iframe>", vid.ProviderKey); txtSecondsIn.Text = vid.Intro.ToString(); txtElasedEnd.Text = vid.LengthFromStart.ToString(); ddlVideoProvider.SelectedValue = vid.ProviderCode; chkEnabled.Checked = vid.IsEnabled; ddlVolumeLevel.SelectedValue = vid.VolumeLevel.ToString(); lblVideoID.Text = vid.VideoID.ToString(); if (vid.VolumeLevel == 0) { ddlVolumeLevel.SelectedValue = "5"; chkEnabled.Checked = true; } Google.YouTube.Video video; video = new Google.YouTube.Video(); try { YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password); YouTubeRequest yourequest; Uri Url; yourequest = new YouTubeRequest(yousettings); Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoKey); video = yourequest.Retrieve<Google.YouTube.Video>(Url); txtDuration.Text = video.YouTubeEntry.Duration.Seconds.ToString(); } catch (GDataRequestException) { vid.IsEnabled = false; vid.Update(); litVideo.Text = string.Empty; return; } if (vid.LengthFromStart == 0) { txtElasedEnd.Text = video.YouTubeEntry.Duration.Seconds.ToString(); } if (vid.LengthFromStart == 0) { txtDuration.Text = video.YouTubeEntry.Duration.Seconds.ToString(); } txtUserName.Text = video.Uploader; lblVideoID.Text = vid.VideoID.ToString(); txtVideoKey.Text = video.VideoId; // if (vid.VideoID == 0) return; //// status //Statuses stus = new Statuses(); //stus.GetAll(); //ddlVideoStatus.DataSource = stus; //ddlVideoStatus.DataTextField = "statusDescription"; //ddlVideoStatus.DataValueField = "statusID"; //ddlVideoStatus.DataBind(); //if (vid.StatusID != 0) // ddlVideoStatus.SelectedValue = vid.StatusID.ToString(); // vid type propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); mps = new MultiProperties(propTyp.PropertyTypeID); mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); }); ddlVideoType.DataSource = mps; ddlVideoType.DataTextField = "name"; ddlVideoType.DataValueField = "multiPropertyID"; ddlVideoType.DataBind(); ddlVideoType.Items.Insert(0, new ListItem(selectText)); if (mp.MultiPropertyID != 0) ddlVideoType.SelectedValue = mp.MultiPropertyID.ToString(); // human propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); mps = new MultiProperties(propTyp.PropertyTypeID); mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); }); ddlHumanType.DataSource = mps; ddlHumanType.DataTextField = "name"; ddlHumanType.DataValueField = "multiPropertyID"; ddlHumanType.DataBind(); ddlHumanType.Items.Insert(0, new ListItem(selectText)); if (mp.MultiPropertyID != 0) ddlHumanType.SelectedValue = mp.MultiPropertyID.ToString(); // footage propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG); mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); mps = new MultiProperties(propTyp.PropertyTypeID); mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); }); ddlFootageType.DataSource = mps; ddlFootageType.DataTextField = "name"; ddlFootageType.DataValueField = "multiPropertyID"; ddlFootageType.DataBind(); ddlFootageType.Items.Insert(0, new ListItem(selectText)); if (mp.MultiPropertyID != 0) ddlFootageType.SelectedValue = mp.MultiPropertyID.ToString(); //// gutiar type //propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR); //mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); //mps = new MultiProperties(propTyp.PropertyTypeID); //mps.Sort(delegate(MultiProperty p1, MultiProperty p2) //{ // return p1.Name.CompareTo(p2.Name); //}); //ddlGuitarType.DataSource = mps; //ddlGuitarType.DataTextField = "name"; //ddlGuitarType.DataValueField = "multiPropertyID"; //ddlGuitarType.DataBind(); //ddlGuitarType.Items.Insert(0, new ListItem(selectText)); //if (mp.MultiPropertyID != 0) // ddlGuitarType.SelectedValue = mp.MultiPropertyID.ToString(); //// language //propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE); //mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); //mps = new MultiProperties(propTyp.PropertyTypeID); //mps.Sort(delegate(MultiProperty p1, MultiProperty p2) //{ // return p1.Name.CompareTo(p2.Name); //}); //ddlLanguage.DataSource = mps; //ddlLanguage.DataTextField = "name"; //ddlLanguage.DataValueField = "multiPropertyID"; //ddlLanguage.DataBind(); //ddlLanguage.Items.Insert(0, new ListItem(selectText)); //if (mp.MultiPropertyID != 0) // ddlLanguage.SelectedValue = mp.MultiPropertyID.ToString(); //// genre //propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE); //mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); //mps = new MultiProperties(propTyp.PropertyTypeID); //mps.Sort(delegate(MultiProperty p1, MultiProperty p2) //{ // return p1.Name.CompareTo(p2.Name); //}); //ddlGenre.DataSource = mps; //ddlGenre.DataTextField = "name"; //ddlGenre.DataValueField = "multiPropertyID"; //ddlGenre.DataBind(); //ddlGenre.Items.Insert(0, new ListItem(selectText)); //if (mp.MultiPropertyID != 0) // ddlGenre.SelectedValue = mp.MultiPropertyID.ToString(); //// difficulty //propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC); //mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO); //mps = new MultiProperties(propTyp.PropertyTypeID); //mps.Sort(delegate(MultiProperty p1, MultiProperty p2) //{ // // sort by entry // return p1.MultiPropertyID.CompareTo(p2.MultiPropertyID); //}); //ddlDifficultyLevel.DataSource = mps; //ddlDifficultyLevel.DataTextField = "name"; //ddlDifficultyLevel.DataValueField = "multiPropertyID"; //ddlDifficultyLevel.DataBind(); //ddlDifficultyLevel.Items.Insert(0, new ListItem(selectText)); //if (mp.MultiPropertyID != 0) // ddlDifficultyLevel.SelectedValue = mp.MultiPropertyID.ToString(); // contest ContestVideo vidInContest = new ContestVideo(); vidInContest.GetContestVideo(vid.VideoID); if (vidInContest.ContestVideoID != 0) { ddlContest.SelectedValue = vidInContest.ContestID.ToString(); } else ddlContest.SelectedValue = unknownValue; Songs sngs = new Songs(); artsngs = new Songs(); sngs.GetSongsForVideo(vid.VideoID); Artist art = null; Artists arts = new Artists(); arts.GetAll(); // artists 1 ddlArtist1.DataSource = arts; ddlArtist1.DataTextField = "name"; ddlArtist1.DataValueField = "name"; ddlArtist1.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist1); ddlArtist1.Items.Insert(0, new ListItem(unknownValue)); // artists 2 ddlArtist2.DataSource = arts; ddlArtist2.DataTextField = "name"; ddlArtist2.DataValueField = "name"; ddlArtist2.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist2); ddlArtist2.Items.Insert(0, new ListItem(unknownValue)); // artists 3 ddlArtist3.DataSource = arts; ddlArtist3.DataTextField = "name"; ddlArtist3.DataValueField = "name"; ddlArtist3.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist3); ddlArtist3.Items.Insert(0, new ListItem(unknownValue)); // artists 4 ddlArtist4.DataSource = arts; ddlArtist4.DataTextField = "name"; ddlArtist4.DataValueField = "name"; ddlArtist4.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist4); ddlArtist4.Items.Insert(0, new ListItem(unknownValue)); // artists 5 ddlArtist5.DataSource = arts; ddlArtist5.DataTextField = "name"; ddlArtist5.DataValueField = "name"; ddlArtist5.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist5); ddlArtist5.Items.Insert(0, new ListItem(unknownValue)); // artists 6 ddlArtist6.DataSource = arts; ddlArtist6.DataTextField = "name"; ddlArtist6.DataValueField = "name"; ddlArtist6.DataBind(); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtist6); ddlArtist6.Items.Insert(0, new ListItem(unknownValue)); foreach (Song sng in sngs) { if (sng.Name == unknownValue || string.IsNullOrEmpty(sng.Name)) continue; // sngrcd.SongDisplay += art.Name + " - " + sng.Name + " " ; if (sng.RankOrder == 0 || sng.RankOrder == 1) { // song 1 art = new Artist(sng.ArtistID); ddlArtist1.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs1.DataSource = artsngs; ddlArtistSongs1.DataTextField = "name"; ddlArtistSongs1.DataValueField = "name"; ddlArtistSongs1.DataBind(); ddlArtistSongs1.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs1); ddlArtistSongs1.SelectedValue = sng.Name.ToString(); } else if (sng.RankOrder == 2) { // song 2 art = new Artist(sng.ArtistID); ddlArtist2.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs2.DataSource = artsngs; ddlArtistSongs2.DataTextField = "name"; ddlArtistSongs2.DataValueField = "name"; ddlArtistSongs2.DataBind(); ddlArtistSongs2.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs2); ddlArtistSongs2.SelectedValue = sng.Name.ToString(); } else if (sng.RankOrder == 3) { // song 3 art = new Artist(sng.ArtistID); ddlArtist3.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs3.DataSource = artsngs; ddlArtistSongs3.DataTextField = "name"; ddlArtistSongs3.DataValueField = "name"; ddlArtistSongs3.DataBind(); ddlArtistSongs3.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs3); ddlArtistSongs3.SelectedValue = sng.Name.ToString(); } else if (sng.RankOrder == 4) { // song 4 art = new Artist(sng.ArtistID); ddlArtist4.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs4.DataSource = artsngs; ddlArtistSongs4.DataTextField = "name"; ddlArtistSongs4.DataValueField = "name"; ddlArtistSongs4.DataBind(); ddlArtistSongs4.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs4); ddlArtistSongs4.SelectedValue = sng.Name.ToString(); } else if (sng.RankOrder == 5) { // song 5 art = new Artist(sng.ArtistID); ddlArtist5.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs5.DataSource = artsngs; ddlArtistSongs5.DataTextField = "name"; ddlArtistSongs5.DataValueField = "name"; ddlArtistSongs5.DataBind(); ddlArtistSongs5.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs5); ddlArtistSongs5.SelectedValue = sng.Name.ToString(); } else if (sng.RankOrder == 6) { // song 6 art = new Artist(sng.ArtistID); ddlArtist6.SelectedValue = art.Name; artsngs = new Songs(); artsngs.GetSongsForArtist(art.ArtistID); ddlArtistSongs6.DataSource = artsngs; ddlArtistSongs6.DataTextField = "name"; ddlArtistSongs6.DataValueField = "name"; ddlArtistSongs6.DataBind(); ddlArtistSongs6.Items.Insert(0, new ListItem(unknownValue)); BootBaronLib.Operational.Utilities.General.SortDropDownList(ddlArtistSongs6); ddlArtistSongs6.SelectedValue = sng.Name.ToString(); } } lblStatus.Text = "OK"; } catch (Exception ex) { lblStatus.Text = ex.Message; } }
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); }
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); }
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)); }
//,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(""); }