private static IObservable<IReadOnlyList<ISong>> RealSearch(string searchTerm) { var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri) { OrderBy = "relevance", Query = searchTerm, SafeSearch = YouTubeQuery.SafeSearchValues.None, NumberToRetrieve = RequestLimit }; var settings = new YouTubeRequestSettings("Espera", ApiKey); var request = new YouTubeRequest(settings); return Observable.FromAsync(async () => { Feed<Video> feed = await Task.Run(() => request.Get<Video>(query)); List<Video> entries = await Task.Run(() => feed.Entries.ToList()); return (from video in entries let url = video.WatchPage.OriginalString.Replace("&feature=youtube_gdata_player", String.Empty).Replace("https://", "http://") select new YoutubeSong() { Artist = video.Uploader, Title = video.Title, OriginalPath = url }).ToList(); }) .Catch<IReadOnlyList<YoutubeSong>, Exception>(ex => Observable.Throw<IReadOnlyList<YoutubeSong>>(new Exception("YoutubeSongFinder search failed", ex))); }
//---------------------------------------------------------------------------------------------------------- // song landing page dynamic content // public ActionResult GetSongDynamicDetails() { // 1.parse query string //----------------------------------------------------------------------------------------------------- string song_guid = ""; if (Request.QueryString["song_guid"] != null) { song_guid = Request.QueryString["song_guid"]; } //----------------------------------------------------------------------------------------------------- // 2.get video dynamic details //----------------------------------------------------------------------------------------------------- Video video = new Video(); try { YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA"); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + song_guid; video = request.Retrieve <Video>(new Uri(feedUrl)); }catch (Exception ex) {} //----------------------------------------------------------------------------------------------------- return(View(video)); }
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; }
private Video GetSongVideoByTitle(string song_title) { YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA"); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = String.Format("http://gdata.youtube.com/feeds/api/videos?q={0}&category=Music&format=5&start-index={1}&orderby=viewCount", HttpUtility.UrlEncode(song_title.Replace("+", " ")), 1); Feed <Video> videoFeed = null; Video ret_Video = new Video(); try { videoFeed = request.Get <Video>(new Uri(feedUrl)); if (videoFeed != null) { foreach (var item in videoFeed.Entries) { ret_Video = item; break; } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(ret_Video); }
public YoutubeVideo GetVideoById(string videoId) { YouTubeService service = new YouTubeService(_applicationName, _developerKey); string url = String.Format("{0}/{1}?v=2&", _videoUrl, videoId); YouTubeQuery searchQuery = new YouTubeQuery(url); var result = service.Query(searchQuery); YouTubeEntry entry = result.Entries.FirstOrDefault() as YouTubeEntry; var video = entry.ToYoutubeVideo(); string commentUrl = String.Format("http://gdata.youtube.com/feeds/api/videos/{0}/comments?max-results={1}&start-index={2}", videoId, 50, 1); var youTubeRequestSettings = new YouTubeRequestSettings(_applicationName, _developerKey); var request = new YouTubeRequest(youTubeRequestSettings); Feed <Comment> comments = request.Get <Comment>(new Uri(commentUrl)); foreach (var item in comments.Entries) { video.Comments.Add(new YoutubeComment { Author = item.Author, UpdatedOn = item.Updated, Title = item.Title, Content = item.Content, }); } return(video); }
/// <summary> /// Starts the <see cref="YoutubeSongFinder"/>. /// </summary> public override void Start() { var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri) { OrderBy = "relevance", Query = searchString, SafeSearch = YouTubeQuery.SafeSearchValues.None }; var settings = new YouTubeRequestSettings("Espera", ApiKey); var request = new YouTubeRequest(settings); Feed <Video> feed = request.Get <Video>(query); foreach (Video video in feed.Entries) { var duration = TimeSpan.FromSeconds(Int32.Parse(video.YouTubeEntry.Duration.Seconds)); string url = video.WatchPage.OriginalString .Replace("&feature=youtube_gdata_player", String.Empty) /* Unnecessary long url */ .Replace("https://", "http://"); /* VLC doesn't like https */ var song = new YoutubeSong(url, AudioType.Mp3, duration, CoreSettings.Default.StreamYoutube) { Title = video.Title, Description = video.Description, Rating = video.RatingAverage, ThumbnailSource = new Uri(video.Thumbnails[0].Url) }; this.InternSongsFound.Add(song); this.OnSongFound(new SongEventArgs(song)); } this.OnFinished(EventArgs.Empty); }
public IEnumerable<VideoModel> Search(string searchText) { var modelList = new List<VideoModel>(); var settings = new YouTubeRequestSettings("YouTunes", "AIzaSyCgNs6G_0w36g6dhAxxBL4nL7wD3C6jmOw"); var request = new YouTubeRequest(settings); var query = new YouTubeQuery("https://gdata.youtube.com/feeds/api/videos") { Query = searchText }; Feed<Video> feed = null; try { feed = request.Get<Video>(query); foreach (var video in feed.Entries) { modelList.Add(new VideoModel() { VideoTitle = video.Title, VideoId = video.VideoId }); } } catch (GDataRequestException gdre) { } return modelList; }
public GDataResultAggregator(string playlistURL) { YouTubeRequestSettings settings = new YouTubeRequestSettings(APPNAME, CLIENTID, DEVELKEY); YouTubeRequest request = new YouTubeRequest(settings); _videoFeed = request.Get<Video>(new Uri(playlistURL)); }
//---------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------- // perform youtube search public ActionResult MusicYTID() { string search_string = ""; if (Request.QueryString["ss"] != null) { //--------------------------------------------------------------------- search_string = Request.QueryString["ss"].ToString(); ViewBag.search_string = search_string.Replace(" ", "+"); //--------------------------------------------------------------------- } // 2.get video dynamic details //----------------------------------------------------------------------------------------------------- Video video = null; try { YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA"); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + HttpUtility.UrlEncode(search_string.Replace("+", " ")); video = request.Retrieve <Video>(new Uri(feedUrl)); } catch (Exception ex) { } //----------------------------------------------------------------------------------------------------- return(View(video)); }
public void resetAllConnectionAndAccount() { try { Console.WriteLine("Resetting accounts."); System.Threading.Thread.Sleep(60 * 1000 * minDelayMinute / 2); settings = new List <YouTubeRequestSettings>(); requests = new List <YouTubeRequest>(); lastUsed = new List <DateTime>(); foreach (var user in users) { YouTubeRequestSettings s = new YouTubeRequestSettings(user.AppName, user.ApiKey, user.UserName, user.Password); s.Timeout = 10000000; settings.Add(s); YouTubeRequest r = new YouTubeRequest(s); r.Proxy = GetProxyForUser(user); requests.Add(r); lastUsed.Add(DateTime.Now.Subtract(new TimeSpan(0, 0, (int)(2 * (random.NextDouble() + 0.01) * minDelayMinute), 0))); } } catch (Exception) { } }
public static YouTubeRequest GetRequest(string userName, string password) { // let's see if we get a valid authtoken back for the passed in credentials.... YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTubeAspSample", "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q", userName, password); YouTubeRequest request = new YouTubeRequest(settings); string authToken = null; try { authToken = request.Service.QueryClientLoginToken(); } catch { } request.Service.SetAuthenticationToken(authToken); //YouTubeRequest request = HttpContext.Current.Session["YTRequest"] as YouTubeRequest; //if (request == null) //{ // YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTubeAspSample", // "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q", // HttpContext.Current.Session["token"] as string // ); // settings.AutoPaging = true; // request = new YouTubeRequest(settings); // HttpContext.Current.Session["YTRequest"] = request; //} return(request); }
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); }
public Youtube() { YouTubeRequestSettings settings = new YouTubeRequestSettings("DemoFacebookFeature", "AI39si4cTAJSx5HF1qHrhfD_ws7kUEnk0Tr02WcFPiMf96nTxczLMT8a_lJqGhlbKRsY0YZE5BYhO-gu2y7rXsQesC3Jf2-jGA"); Request = new YouTubeRequest(settings); VideoFeeds = new List<Video>(); NewVideos = new List<Video>(); }
public void YouTubeUnAuthenticatedRequestTest() { Tracing.TraceMsg("Entering YouTubeUnAuthenticatedRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey); settings.AutoPaging = true; settings.Maximum = 50; YouTubeRequest f = new YouTubeRequest(settings); Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); // this will get you the first 25 videos, let's retrieve comments for the first one only foreach (Video v in feed.Entries) { Feed <Comment> list = f.GetComments(v); foreach (Comment c in list.Entries) { Assert.IsTrue(c.AtomEntry != null); Assert.IsTrue(c.Title != null); } break; } }
public void YouTubePageSizeTest() { Tracing.TraceMsg("Entering YouTubePageSizeTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular); int iCount = 0; // this will get you just the first 15 videos. foreach (Video v in feed.Entries) { iCount++; f.Settings.PageSize = 5; Feed <Comment> list = f.GetComments(v); int i = 0; foreach (Comment c in list.Entries) { i++; } Assert.IsTrue(i <= 5, "the count should be smaller/equal 5"); Assert.IsTrue(list.PageSize == -1 || list.PageSize == 5, "the returned pagesize should be 5 or -1 as well"); } Assert.AreEqual(iCount, 15, "the outer feed should count 15"); Assert.AreEqual(feed.PageSize, 15, "outer feed pagesize should be 15"); }
// youtube stuff private static bool ytLogin() { //http://trailsinthesand.com/programmatically-uploading-videos-to-youtube/ Console.WriteLine("[yt] Logging in to: " + User.ytUser + " ..."); settings = new YouTubeRequestSettings("Da Stank Bank", Program.ytDevKey, User.ytUser, User.ytPass); request = new YouTubeRequest(settings); string url = "http://gdata.youtube.com/feeds/api/users/" + User.ytUser + "/uploads"; try { Feed <Video> videoFeed = request.Get <Video>(new Uri(url)); foreach (Video entry in videoFeed.Entries) { Console.WriteLine("Entry: " + entry.Id + " -> " + entry.Title); if (entry.ReadOnly == false) { Console.WriteLine("\tVideo is editable by the current user."); } } } catch (ClientFeedException e) { Console.WriteLine("E: " + e); } catch (GDataRequestException) { // if this happens we're likely NOT logged in! return(false); } Console.WriteLine("done."); return(true); }
public void YouTubePlaylistBatchTest() { Tracing.TraceMsg("Entering YouTubePlaylistBatchTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); // GetVideoFeed get's you a users video feed Feed <Playlist> feed = f.GetPlaylistsFeed(null); // this will get you just the first 25 playlists. List <Playlist> list = new List <Playlist>(); int i = 0; foreach (Playlist p in feed.Entries) { list.Add(p); // add everything you want to do here... } Feed <PlayListMember> videos = f.GetPlaylist(list[0]); List <PlayListMember> lvideo = new List <PlayListMember>(); foreach (PlayListMember v in videos.Entries) { lvideo.Add(v); // add everything you want to do here... } List <PlayListMember> batch = new List <PlayListMember>(); PlayListMember toBatch = new PlayListMember(); toBatch.Id = lvideo[1].Id; toBatch.VideoId = lvideo[1].VideoId; toBatch.BatchData = new GDataBatchEntryData(); toBatch.BatchData.Id = "NEWGUY"; toBatch.BatchData.Type = GDataBatchOperationType.insert; batch.Add(toBatch); toBatch = lvideo[1]; toBatch.BatchData = new GDataBatchEntryData(); toBatch.BatchData.Id = "DELETEGUY"; toBatch.BatchData.Type = GDataBatchOperationType.delete; batch.Add(toBatch); toBatch = lvideo[0]; toBatch.Position = 1; toBatch.BatchData = new GDataBatchEntryData(); toBatch.BatchData.Id = "UPDATEGUY"; toBatch.BatchData.Type = GDataBatchOperationType.update; batch.Add(toBatch); Feed <PlayListMember> updatedVideos = f.Batch(batch, videos); foreach (Video v in updatedVideos.Entries) { Assert.IsTrue(v.BatchData.Status.Code < 300, "one batch operation failed: " + v.BatchData.Status.Reason); } }
//string wth; FIXED -- Issue with object scope? Will fix later. This is a workaround. public MainForm() { InitializeComponent(); buttonUpload.Enabled = false; //Disable buttons by default. textComplete.Visible = false; btnDelete.Enabled = false; btnAdd.Enabled = false; comboCategory.SelectedIndex = 7; //No selection is invalid. vidFlag = false; //User must provide credentials and a video before uploading. loginFlag = false; //Saved settings folderBrowserDialog.SelectedPath = stored_IncludeFolder; includeTextBox.Text = stored_IncludeFolder; VideoWatcher.Path = stored_IncludeFolder; VideoFilename = Youtube_Uploader.Properties.Settings.Default.FilesLib; VideoId = Youtube_Uploader.Properties.Settings.Default.IdLib; VideoStatus = Youtube_Uploader.Properties.Settings.Default.StatusLib; YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, Youtube_Uploader.Properties.Settings.Default.UsernameYT, Youtube_Uploader.Properties.Settings.Default.PasswordYT); request = new YouTubeRequest(settings); drawVideoList(); }
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 void YouTubePlaylistRequestTest() { Tracing.TraceMsg("Entering YouTubePlaylistRequestTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); // GetVideoFeed gets you a users video feed Feed <Playlist> feed = f.GetPlaylistsFeed(null); // this will get you just the first 25 videos. foreach (Playlist p in feed.Entries) { Assert.IsTrue(p.AtomEntry != null); Assert.IsTrue(p.Title != null); Feed <PlayListMember> list = f.GetPlaylist(p); foreach (PlayListMember v in list.Entries) { Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry"); Assert.IsTrue(v.Title != null, "There should be a title"); Assert.IsTrue(v.VideoId != null, "There should be a videoID"); // there might be no watchpage (not published yet) // Assert.IsTrue(v.WatchPage != null, "There should be a watchpage"); } } }
public void login(string user, string pass) { devkey = Properties.Resources.devkey.Length == 0 ? File.ReadAllText("devkey") : System.Text.Encoding.Default.GetString(Properties.Resources.devkey); YouTubeRequestSettings settings = new YouTubeRequestSettings("SubBuddy", devkey, user, pass); request = new YouTubeRequest(settings); }
public static string getSearchVal(string searchvar) { searchtext = searchvar; YouTubeRequestSettings yy = new YouTubeRequestSettings("unitysg", "AIzaSyAS1TLHGyfD6yP596kpmckOhUepSPmo8hM"); YouTubeRequest request = new YouTubeRequest(yy); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri + "?region=SG&v=2"); //order results by the number of views (most viewed first) // query.OrderBy = "viewCount"; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = searchvar; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed <Video> videoFeed = request.Get <Video>(query); if (printVideoFeed(videoFeed) == true) { return("Success"); } else { return("Fail"); } }
public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string playlistID = "4A3A73D5172EB90A"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd); // settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed <Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.playlist; sub.PlaylistId = playlistID; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List <Subscription> list = new List <Subscription>(); foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); if (s.PlaylistId == playlistID) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } foreach (Subscription s in feed.Entries) { Assert.IsTrue(s.PlaylistId != null, "There should be a PlaylistId"); Assert.IsTrue(s.PlaylistTitle != null, "There should be a PlaylistTitle"); Assert.IsFalse(s.PlaylistId == playlistID, "They should be gone"); } }
private void ButtonSaveSettings_Click(object sender, EventArgs e) { bool fHide = true; if (this.isAuthenticated.Checked == false && this.userName.Text.Length > 0) { // let's see if we get a valid authtoken back for the passed in credentials.... YouTubeRequestSettings settings = new YouTubeRequestSettings(AppKey, YTDEVKEY, this.userName.Text, this.passWord.Text); // settings.PageSize = 15; this.ytRequest = new YouTubeRequest(settings); try { this.authToken = this.ytRequest.Service.QueryClientLoginToken(); this.passWord.Text = ""; } catch { MessageBox.Show("There was a problem with your credentials"); this.authToken = null; fHide = false; } OnAuthenticationModified(this.authToken); } // let's save the username to the registry, but not the password RegistryKey ytNotifier = Registry.CurrentUser.OpenSubKey(YTNOTIFIERKEY, true); if (ytNotifier == null) { ytNotifier = Registry.CurrentUser.CreateSubKey(YTNOTIFIERKEY); } ytNotifier.SetValue("initialDataPullTime", this.InitialDataPullTime.Value, RegistryValueKind.DWord); ytNotifier.SetValue("updateFrequency", this.UpdateFrequency.Value, RegistryValueKind.DWord); ytNotifier.SetValue("notificationDuration", this.notifcationBalloons.Value, RegistryValueKind.DWord); ytNotifier.SetValue("userList", GetUserNamesToSave()); this.initialPullinHours = (int)this.InitialDataPullTime.Value; this.updateFrequency = (int)this.UpdateFrequency.Value; this.notificationDuration = (int)this.notifcationBalloons.Value; if (this.authToken != null) { ytNotifier.SetValue("userName", this.userName.Text); ytNotifier.SetValue("token", this.authToken); this.user = this.userName.Text; } if (fHide == true) { HideMe(); UpdateActivities(); } }
public static YouTubeRequest GetRequest() { YouTubeRequestSettings settings = new YouTubeRequestSettings("Chalkable Youtube app", "AI39si6y_3ZKWG2A4_-v5ogSal_5Y41jmsiQ3aYD0AUVHBTT7mNjOAhh1r24xJWUkki67hLg0l4EXZHS-d4h-kysPd9yGAV0Wg"); settings.AutoPaging = true; YouTubeRequest request = new YouTubeRequest(settings); return request; }
private YouTubeRequest GetRequest() { YouTubeRequestSettings settings = new YouTubeRequestSettings(_appName, _devKey); settings.AutoPaging = true; YouTubeRequest request = new YouTubeRequest(settings); return(request); }
public YouTubeRepository(string appName, string developerKey) { _appName = appName; _developerKey = developerKey; _settings = new YouTubeRequestSettings(_appName, _developerKey); _videoEntryFactory = new VideoEntryFactory(); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs a test on the YouTube factory object</summary> ////////////////////////////////////////////////////////////////////// [Test] public void YouTubeRequestActivitiesTest() { Tracing.TraceMsg("Entering YouTubeRequestActivitiesTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd); // settings.PageSize = 15; YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed <Activity> feed = f.GetActivities(); foreach (Activity a in feed.Entries) { Assert.IsTrue(a.VideoId != null, "There should be a VideoId"); } // now let's find all that happened in the last 24 hours DateTime t = DateTime.Now.AddDays(-1); // this returns the all activities for the last 24 hours default answer try { Feed <Activity> yesterday = f.GetActivities(t); foreach (Activity a in yesterday.Entries) { Assert.IsTrue(a.VideoId != null, "There should be a VideoId"); } } catch (GDataNotModifiedException e) { Assert.IsTrue(e != null); } t = DateTime.Now.AddMinutes(-1); // this returns the all activities for the last 1 minute, should be empty or throw a not modified try { Feed <Activity> lastmin = f.GetActivities(t); int iCount = 0; foreach (Activity a in lastmin.Entries) { iCount++; } Assert.IsTrue(iCount == 0, "There should be no activity for the last minute"); } catch (GDataNotModifiedException e) { Assert.IsTrue(e != null); } }
public static YouTubeRequest GetRequest() { YouTubeRequestSettings settings = new YouTubeRequestSettings("Chalkable Youtube app", "AI39si6y_3ZKWG2A4_-v5ogSal_5Y41jmsiQ3aYD0AUVHBTT7mNjOAhh1r24xJWUkki67hLg0l4EXZHS-d4h-kysPd9yGAV0Wg"); settings.AutoPaging = true; YouTubeRequest request = new YouTubeRequest(settings); return(request); }
private static YouTubeRequest GetRequest() { var youtubeApiKey = ConfigurationManager.AppSettings["youtubeApiKey"]; var applicationName = ConfigurationManager.AppSettings["applicationName"]; var youtubeUserName = ConfigurationManager.AppSettings["youtubeUserName"]; var youtubePassword = ConfigurationManager.AppSettings["youtubePassword"]; var settings = new YouTubeRequestSettings(applicationName, youtubeApiKey, youtubeUserName, youtubePassword); var request = new YouTubeRequest(settings); return request; }
public static Video getVideoDetails(string videoID) { YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTube VideoDownloader", devKey); YouTubeRequest request = new YouTubeRequest(settings); Uri videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoID)); Video video = request.Retrieve <Video>(videoEntryUrl); //video.Contents[0].Url; return(video); }
public YouTubeRequest GetRequest() { YouTubeRequestSettings settings = new YouTubeRequestSettings("SitecoreYouTubeUploader", devKey, username, password); settings.AutoPaging = true; YouTubeRequest request = new YouTubeRequest(settings); request = new YouTubeRequest(settings); return(request); }
public void YouTubeSubscriptionsTest() { Tracing.TraceMsg("Entering YouTubeSubscriptionsTest"); string channelUsername = "******"; YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytDevKey, this.ytUser, this.ytPwd); YouTubeRequest f = new YouTubeRequest(settings); // this returns the server default answer Feed <Subscription> feed = f.GetSubscriptionsFeed(null); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { f.Delete(s); } } Subscription sub = new Subscription(); sub.Type = SubscriptionEntry.SubscriptionType.channel; sub.UserName = "******"; f.Insert(feed, sub); // this returns the server default answer feed = f.GetSubscriptionsFeed(null); List <Subscription> list = new List <Subscription>(); foreach (Subscription s in feed.Entries) { if (!string.IsNullOrEmpty(s.UserName) && s.UserName == channelUsername) { list.Add(s); } } Assert.IsTrue(list.Count > 0, "There should be one subscription matching"); foreach (Subscription s in list) { f.Delete(s); } feed = f.GetSubscriptionsFeed(null); int iCount = 0; foreach (Subscription s in feed.Entries) { iCount++; } Assert.IsTrue(iCount == 0, "There should be no subscriptions in the feed"); }
public bool InitYouTubeRequest () { YouTubeRequestSettings yt_request_settings = new YouTubeRequestSettings (app_name, client_id, developer_key); this.yt_request = new YouTubeRequest (yt_request_settings); if (this.yt_request != null && yt_request_settings != null) { return true; } return false; }
public IDialogContext context; //Este es el contexto de la aplicación //Constructor principal public Buscador(string textoABuscar, int resultados, ref IDialogContext context) { //Establecemos la API de YouTube this.settings = new YouTubeRequestSettings("Tutankabot", "AIzaSyDO3IdHkAc7WMI8NCke7xM_MJfpFHrEg2Y"); this.request = new YouTubeRequest(settings); //Declaramos las variables this.textoABuscar = textoABuscar; this.resultados = resultados; this.context = context; }
private static YouTubeRequest GetRequest() { var youtubeApiKey = ConfigurationManager.AppSettings["youtubeApiKey"]; var applicationName = ConfigurationManager.AppSettings["applicationName"]; var youtubeUserName = ConfigurationManager.AppSettings["youtubeUserName"]; var youtubePassword = ConfigurationManager.AppSettings["youtubePassword"]; var settings = new YouTubeRequestSettings(applicationName, youtubeApiKey, youtubeUserName, youtubePassword); var request = new YouTubeRequest(settings); return(request); }
public void YouTubeUserActivitiesTest() { Tracing.TraceMsg("Entering YouTubeUserActivitiesTest"); YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey); YouTubeRequest f = new YouTubeRequest(settings); List <string> users = new List <string>(); users.Add("whiskeytonsils"); users.Add("joelandberry"); // this returns the server default answer Feed <Activity> feed = f.GetActivities(users); foreach (Activity a in feed.Entries) { VerifyActivity(a); } // now let's find all that happened in the last 24 hours DateTime t = DateTime.Now.AddDays(-1); // this returns the all activities for the last 24 hours try { Feed <Activity> yesterday = f.GetActivities(users, t); foreach (Activity a in yesterday.Entries) { VerifyActivity(a); } } catch (GDataNotModifiedException e) { Assert.IsTrue(e != null); } t = DateTime.Now.AddMinutes(-1); // this returns all activities for the last 1 minute, should be empty or throw a not modified try { Feed <Activity> lastmin = f.GetActivities(users, t); int iCount = 0; foreach (Activity a in lastmin.Entries) { iCount++; } Assert.IsTrue(iCount == 0, "There should be no activity for the last minute"); } catch (GDataNotModifiedException e) { Assert.IsTrue(e != null); } }
/// <summary> /// Handles the skip login command. /// </summary> /// <exception cref="System.NotImplementedException"></exception> private void HandleSkipLoginCommand() { if (this.StartupPageCompleted != null) { this.settings = new YouTubeRequestSettings("DeskTube", ConfigurationManager.AppSettings["DeveloperKey"]) { AutoPaging = true }; var request = new YouTubeRequest(this.settings); this.StartupPageCompleted(null, new Tuple <bool, YouTubeRequest>(false, request)); } }
private void Guncelle() { using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hesap.mdb")) { conn.Open(); OleDbCommand komut = new OleDbCommand(); komut.Connection = conn; komut.CommandText = "Select * from hesap"; // sorgu / komut cumlemi yazıyorum. komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz. OleDbDataReader dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz while (dr.Read()) // datareader ile okuyoruz. { string hadi = dr["hadi"].ToString(); string kadi = dr["kadi"].ToString(); string q; using (WebClient asd = new WebClient()) { asd.Encoding = Encoding.UTF8; q = asd.DownloadString("http://gdata.youtube.com/feeds/api/users/" + kadi + "/uploads?v=2&alt=jsonc&max-results=0"); } string[] adet1 = q.Split(new string[] { "totalItems\":" }, StringSplitOptions.None); string[] adet2 = adet1[1].Split(','); listView1.Items.Add(new ListViewItem(new string[] { hadi, "Adet: "+adet2[0] })); } dr.Close(); komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz. dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz while (dr.Read()) // datareader ile okuyoruz. { string kadi = dr["hadi"].ToString(); // veritabanimdaki "kadi" alanımdaki veriyi alip kadi değişkenine atıyorum(yukarıda string olusturmustum) string sifre = dr["hsifresi"].ToString(); // aynı durum söz konusu string devkey = dr["devkey"].ToString(); Random a = new Random(); string id = a.Next(100000, 999999).ToString(); YouTubeRequestSettings settings = new YouTubeRequestSettings(id, devkey, kadi,sifre); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads"; Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl)); foreach (Video entry in videoFeed.Entries) { string vid_thumb ="http://img.youtube.com/vi/"+entry.VideoId+"/0.jpg"; int izlenme = entry.ViewCount; if(izlenme == -1) izlenme = 0; listView1.Items.Add(new ListViewItem(new string[] { kadi,entry.YouTubeEntry.Title.Text,izlenme.ToString() })); } } } }
/// <summary> /// Autorize Users /// </summary> /// <returns></returns> private static YouTubeRequest GetRequest() { YouTubeRequest request = null;//HttpContext.Current.Session["YouTubeRequest"] as YouTubeRequest; if (request == null) { var settings = new YouTubeRequestSettings("LearningCubes", DeveloperKey, UsersName, UsersPass); request = new YouTubeRequest(settings); //var session = HttpContext.Current.Session; // HttpContext.Current.Session["YouTubeRequest"] = request; } return(request); }
public VideoTitleParseResult GetTitle(string id) { var settings = new YouTubeRequestSettings("VocaDB", null); var request = new YouTubeRequest(settings); var videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", id)); try { var video = request.Retrieve <Video>(videoEntryUrl); var thumbUrl = video.Thumbnails.Count > 0 ? video.Thumbnails[0].Url : string.Empty; return(VideoTitleParseResult.CreateSuccess(video.Title, video.Author, thumbUrl)); } catch (Exception x) { return(VideoTitleParseResult.CreateError(x.Message)); } }
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); }
public VideoTitleParseResult GetTitle(string id) { var settings = new YouTubeRequestSettings("VocaDB", null); var request = new YouTubeRequest(settings); var videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", id)); try { var video = request.Retrieve<Video>(videoEntryUrl); var thumbUrl = video.Thumbnails.Count > 0 ? video.Thumbnails[0].Url : string.Empty; return VideoTitleParseResult.CreateSuccess(video.Title, video.Author, thumbUrl); } catch (Exception x) { return VideoTitleParseResult.CreateError(x.Message); } }
// once you copied your access and refresh tokens // then you can run this method directly from now on... public void MainX(string args) { GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); YouTubeRequestSettings settings = new YouTubeRequestSettings(_app_name, _clientID, _devKey); YouTubeRequest request = new YouTubeRequest(settings); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //order results by the number of views (most viewed first) query.OrderBy = "viewCount"; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = args; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; //Feed<Video> videoFeed = requestFactory.Get<Video>(query); }
public static YouTubeRequest GetRequest() { YouTubeRequest request = HttpContext.Current.Session["YTRequest"] as YouTubeRequest; if (request == null) { YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTubeAspSample", "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q", HttpContext.Current.Session["token"] as string ); settings.AutoPaging = true; request = new YouTubeRequest(settings); HttpContext.Current.Session["YTRequest"] = request; } return request; }
internal List<KeyValuePair<string, List<Video>>> GetListOfSubscriptions(Settings i_settings) { List<KeyValuePair<string, List<Video>>> resObj = new List<KeyValuePair<string, List<Video>>> (); YouTubeRequestSettings settings = new YouTubeRequestSettings( i_settings.appName , i_settings.devKey , i_settings.username , i_settings.password); YouTubeRequest request = new YouTubeRequest(settings); Feed<Subscription> feedOfSubcr = request.GetSubscriptionsFeed(i_settings.userShort); string[] stringSeparators = new string[] { "Activity of:" }; foreach (Subscription subItem in feedOfSubcr.Entries) { string keyStr = subItem.ToString().Split(stringSeparators, StringSplitOptions.None)[1].Trim(); List<Video> listOfVideos = new List<Video>(); string userName = subItem.UserName; string url = string.Format(i_settings.urlFormatter, userName); Feed<Video> videoFeed = request.Get<Video>(new Uri(url)); int depth = 0; foreach (Video entry in videoFeed.Entries) { //strBuilder.AppendLine(" " + entry.Title); listOfVideos.Add(entry); depth++; if (depth >= i_settings.feedDepth) { break; } } if (listOfVideos.Count > 0) { KeyValuePair<string, List<Video>> subscriptionO = new KeyValuePair<string, List<Video>>(keyStr, listOfVideos); resObj.Add(subscriptionO); } } return resObj; }
private static IObservable<IReadOnlyList<YoutubeSong>> RealSearch(string searchTerm) { var query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri) { OrderBy = "relevance", Query = searchTerm, SafeSearch = YouTubeQuery.SafeSearchValues.None, NumberToRetrieve = RequestLimit }; // NB: I have no idea where this API blocks exactly var settings = new YouTubeRequestSettings("Espera", ApiKey); var request = new YouTubeRequest(settings); return Observable.FromAsync(async () => { Feed<Video> feed = await Task.Run(() => request.Get<Video>(query)); List<Video> entries = await Task.Run(() => feed.Entries.ToList()); var songs = new List<YoutubeSong>(); foreach (Video video in entries) { var duration = TimeSpan.FromSeconds(Int32.Parse(video.YouTubeEntry.Duration.Seconds)); string url = video.WatchPage.OriginalString .Replace("&feature=youtube_gdata_player", String.Empty) // Unnecessary long url .Replace("https://", "http://"); // Secure connections are not always easy to handle when streaming var song = new YoutubeSong(url, duration) { Artist = video.Uploader, Title = video.Title, Description = video.Description, Rating = video.RatingAverage >= 1 ? video.RatingAverage : (double?)null, ThumbnailSource = new Uri(video.Thumbnails[0].Url), Views = video.ViewCount }; songs.Add(song); } return songs; }) // The API gives no clue what can throw, wrap it all up .Catch<IReadOnlyList<YoutubeSong>, Exception>(ex => Observable.Throw<IReadOnlyList<YoutubeSong>>(new NetworkSongFinderException("YoutubeSongFinder search failed", ex))); }
static void Main(string[] args) { Uri youTubeLink = new Uri("http://www.youtube.com/watch?v=ItqQ2EZziB8"); var parameters = System.Web.HttpUtility.ParseQueryString(youTubeLink.Query); var videoId = parameters["v"]; Uri youTubeApi = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId)); YouTubeRequestSettings settings = new YouTubeRequestSettings(null, null); YouTubeRequest request = new YouTubeRequest(settings); var result = request.Retrieve<Video>(youTubeApi); Console.WriteLine(result.Title); Console.WriteLine(result.Description); Console.WriteLine(result.ViewCount); Console.ReadLine(); }
public VideoList Search(string query) { VideoList videoList = new VideoList(); try { string api = ConfigService.GetConfig(ConfigKeys.YOUTUBE_API_KEY, ""); YouTubeRequestSettings settings = new YouTubeRequestSettings("TheInternetBuzz.org", "TheInternetBuzz.org", api); YouTubeRequest request = new YouTubeRequest(settings); AddVideo(request, ConfigKeys.YOUTUBE_SEARCH_MAXRESULTS, query, videoList); } catch (Exception exception) { ErrorService.Log("YouTubeSearchService", "Search", query, exception); } return videoList; }
public FormUploadToken addMetadata(String title, String description, String keyword) { String developerKey = "AI39si5IOTNaonIFeiHdJxhJQy3oNC-fB1I_9w4TMeGQ3SOTyf59bNvHh2IRKvqDIHQRGMC_PIfRpJuq_bwkFPauyXQWY9T1nQ"; String username = "******"; String pwd = "cmsgecg28"; YouTubeRequestSettings settings = new YouTubeRequestSettings("cms_app", developerKey, username, pwd); YouTubeRequest request = new YouTubeRequest(settings); Video newVideo = new Video(); newVideo.Title = title; newVideo.Tags.Add(new MediaCategory("Education", YouTubeNameTable.CategorySchema)); newVideo.Keywords = keyword; newVideo.Description = description; newVideo.YouTubeEntry.Private = false; newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122); newVideo.Tags.Add(new MediaCategory("CMS, GECG28", YouTubeNameTable.DeveloperTagSchema)); FormUploadToken token = request.CreateFormUploadToken(newVideo); return token; }
public static Feed<Google.YouTube.Video> GetCurtVideos() { try { YouTubeRequestSettings settings = new YouTubeRequestSettings("eLocal", "AI39si6iCFZ_NutrvZe04i9_m7gFhgmPK1e7LF6-yHMAwB-GDO3vC3eD0R-5lberMQLdglNjH3IWUMe3tJXe9qrFe44n2jAUyg"); YouTubeRequest req = new YouTubeRequest(settings); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); query.Author = "curtmfg"; query.Formats.Add(YouTubeQuery.VideoFormat.Embeddable); query.OrderBy = "viewCount"; // We need to load the feed data for the CURTMfg Youtube Channel Feed<Google.YouTube.Video> video_feed = req.Get<Google.YouTube.Video>(query); return video_feed; } catch (Exception) { return null; } }
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; }
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 void loginDone_Click(object sender, EventArgs e) { String key = @"AI39si5BLf_EKytNzPVPtepg-yNDLPSxKOP9ZCBaDTErR5nWmFMy36d8jnKOfwU3PN0c61au0l6b68k9lk7GRluBKh7lvlNRzA"; //My personal API key. YouTubeService service = new YouTubeService("YouTube Synchronizer"); service.setUserCredentials(textLogin.Text, textPassword.Text); //textbox1 contains username and maskedTextBox1 contains password try { service.QueryClientLoginToken(); this.Hide(); } catch (InvalidCredentialsException j) { loginTxt_lbl.Visible = true; } YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, textLogin.Text, textPassword.Text); Youtube_Uploader.Properties.Settings.Default.UsernameYT = textLogin.Text; Youtube_Uploader.Properties.Settings.Default.PasswordYT = textPassword.Text; Youtube_Uploader.Properties.Settings.Default.Save(); MainForm.request = new YouTubeRequest(settings); }
private static string YoutubeOutput(string input, string flag) { YouTubeRequestSettings settings = new YouTubeRequestSettings("Botler", "AI39si4qO-ubkSyRTofnQsaho8bd2vsIXUd8UI874MI6_ulO6gIyR32tUSQJlok__4H0SoaQ5es7Fl1k6P4fuddYn5zdDjzSvw"); YouTubeRequest request = new YouTubeRequest(settings); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); if (flag == "+v") query.OrderBy = "viewCount"; else if (flag == "+r") query.OrderBy = "rating"; else if (flag == "+p") query.OrderBy = "published"; else query.OrderBy = "relevance"; query.Query = input; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed<Video> videoFeed = request.Get<Video>(query); string output = printVideoFeed(videoFeed); return output; }
private void CreateVideoFeed(string s) { YouTubeRequestSettings settings = new YouTubeRequestSettings("most_viewed", YouTubeDeveloperKey); YouTubeRequest request = new YouTubeRequest(settings); //Link to the feed we wish to read from string feedUrl = String.Format("http://gdata.youtube.com/feeds/api/videos?q=" + s); dtVideoData.Columns.Add("Title"); dtVideoData.Columns.Add("DateUploaded"); dtVideoData.Columns.Add("VideoID"); dtVideoData.Columns.Add("Duration"); DataRow drVideoData; Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl)); //Iterate through each video entry and store details in DataTable foreach (Video videoEntry in videoFeed.Entries) { drVideoData = dtVideoData.NewRow(); drVideoData["Title"] = videoEntry.Title; drVideoData["DateUploaded"] = videoEntry.Updated.ToShortDateString(); drVideoData["VideoID"] = videoEntry.YouTubeEntry.VideoId; drVideoData["Duration"] = videoEntry.YouTubeEntry.Duration.Seconds.ToString(); dtVideoData.Rows.Add(drVideoData); } RadGrid1.DataSource = dtVideoData; RadGrid1.DataBind(); }
public override List<Result> Search(string pKeyWords) { string youtubeApplicationName = ConfigurationManager.AppSettings["youtube-application-name"]; string youtubeDeveloperKey = ConfigurationManager.AppSettings["youtube-developer-key"]; if (string.IsNullOrWhiteSpace(youtubeApplicationName) || string.IsNullOrWhiteSpace(youtubeDeveloperKey)) throw new Exception("App was unable to find Youtube credentials on the current settings file. Please add youtube-application-name and youtube-developer-key to the appSettings section."); YouTubeRequestSettings requestSettings = new YouTubeRequestSettings(youtubeApplicationName, youtubeDeveloperKey); requestSettings.AutoPaging = false; YouTubeRequest youtubeRequest = new YouTubeRequest(requestSettings); YouTubeQuery youtubeQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri) { OrderBy = "viewCount", Query = pKeyWords, NumberToRetrieve = this.MaxResultSearch }; Feed<Video> youtubeVideos = youtubeRequest.Get<Video>(youtubeQuery); List<Result> domainResults = new List<Result>(); foreach (Video video in youtubeVideos.Entries) { domainResults.Add( new Result() { CreatedDate = video.Updated, Type = SourceType.YouTube, Text = string.Format("{0} {1}", video.Description, video.Keywords), Title = video.Title, URL = video.WatchPage.OriginalString } ); } return domainResults; }
private void youTubeSearch(string searchTerm) { YouTubeRequestSettings settings = new YouTubeRequestSettings("SmartHome", developerKeyV2); YouTubeRequest request = new YouTubeRequest(settings); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //For Categories //AtomCategory category1 = new AtomCategory("News", YouTubeNameTable.KeywordSchema); //query.Categories.Add(new QueryCategory(category1); //For Playlist // YouTubeQuery query = new YouTubeQuery(YouTubeQuery.BaseUserUri); // Feed<Google.YouTube.Playlist> userPlayList = request.GetPlaylistsFeed("*****@*****.**"); // foreach (Google.YouTube.Playlist p in userPlayList.Entries) // { // Feed<PlayListMember> list = request.GetPlaylist(p); // foreach (Google.YouTube.Video entry in list.Entries) // { // System.Windows.MessageBox.Show(entry.Title); // } // } //order results by the number of views (most viewed first) query.OrderBy = "viewCount"; query.NumberToRetrieve = 50; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = searchTerm; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed<Google.YouTube.Video> videoFeed = request.Get<Google.YouTube.Video>(query); foreach (Google.YouTube.Video entry in videoFeed.Entries) { //System.Windows.MessageBox.Show(entry.Title); } }
private void button1_Click(object sender, EventArgs e) { login = "******"; password = "******"; if (!logged) { YouTubeService service = new YouTubeService("Manager"); service.setUserCredentials(login, password); try { service.QueryClientLoginToken(); } catch (System.Net.WebException ex) { MessageBox.Show(ex.Message); } yousettings = new YouTubeRequestSettings("YTPlayer","AI39si40b25zgBg_U7eheiSnNeb2UMF-3x35HLBYxQDXJEzYOrA8GSQ1vKikFIRSMGOTjBdFvUx4QPz3q72gUkUqOmg9JBx3bQ", login, password); yourequest = new YouTubeRequest(yousettings); logged = true; } YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); query.OrderBy = "viewCount"; query.Query = textBox1.Text; videofeed = yourequest.Get<Video>(query); videofeedcount = videofeed.TotalResults; totalpages = videofeedcount / 25; if (videofeedcount % 25 != 0) totalpages = totalpages + 1; listView1.Items.Clear(); videoIDs.Clear(); foreach (Video entry in videofeed.Entries) { listView1.Items.Add(entry.Title); videoIDs.Add(entry.VideoId); } }