public YoutubeDataItem(string Uid, string title, string subtitle, string imagePath, string description, string videoID, YoutubeDataGroup group, string localID = "") : base(Uid, title, subtitle, imagePath, description) { this._localId = localID; this._videoID = videoID; this._group = group; this._link = new Uri("http://www.youtube.com/embed/" + videoID + "?rel=0&autoplay=1"); }
private async Task<YoutubeDataGroup> GetUserFavoriteFeedAsync(string Uid, string user) { string text = "http://gdata.youtube.com/feeds/api/users/" + user + "/favorites?v=2&max-results=25"; new Uri(text); YoutubeDataGroup result; try { YoutubeDataItem item = null; YoutubeDataGroup youtubeDataGroup = new YoutubeDataGroup(Uid, user.ToUpper(), "", "ms-appx:///Assets/Darkgray.png", ""); WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num = 0; string title = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text2 = string.Empty; string expr_193 = xmlReader.Name; if (expr_193 != null) { if (!(expr_193 == "yt:videoid")) { if (!(expr_193 == "title")) { if (!(expr_193 == "media:credit")) { if (!(expr_193 == "media:description")) { if (!(expr_193 == "yt:duration")) { if (expr_193 == "gd:rating") { float.Parse(xmlReader["average"].ToString()); } } else { int num2 = Convert.ToInt32(xmlReader["seconds"]); if (num2 > 60) { int num3 = num2 / 60; int num4 = num2 % 60; if (num4 < 10) { str2 = num3.ToString() + ":0" + num4.ToString(); } else { str2 = num3.ToString() + ":" + num4.ToString(); } } else { str2 = "0:" + num2.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { title = xmlReader.ReadElementContentAsString(); } } else { text2 = xmlReader.ReadElementContentAsString(); string imagePath = "http://i.ytimg.com/vi/" + text2 + "/hqdefault.jpg"; item = new YoutubeDataItem(Uid + num.ToString(), title, "by " + str + " | " + str2, imagePath, description, text2, youtubeDataGroup); youtubeDataGroup.Items.Add(item); } } } num++; } webRequest.Abort(); webResponse.Dispose(); webRequest = null; webResponse = null; xmlReader = null; xDocument = null; item = null; result = youtubeDataGroup; } catch (Exception) { result = null; } return result; }
private async Task<YoutubeDataGroup> GetStandardfeedAsync(string Uid, string standardfeed) { string text = "http://gdata.youtube.com/feeds/api/standardfeeds/" + standardfeed + "?v=2&max-results=25"; new Uri(text); string title = string.Empty; string empty = string.Empty; switch (standardfeed) { case "top_rated": title = "Top Rated"; break; case "top_favorites": title = "Favorites"; break; case "most_viewed": title = "Most Viewed"; break; case "most_shared": title = "Most Shared"; break; case "most_popular": title = "Most Popular"; break; case "most_recent": title = "Most Recent"; break; case "most_discussed": title = "Most Discussed"; break; case "most_responded": title = "Most Responded"; break; case "recently_featured": title = "Recently Featured"; break; case "on_the_web": title = "Trends"; break; } YoutubeDataGroup result; try { YoutubeDataItem item = null; YoutubeDataGroup youtubeDataGroup = new YoutubeDataGroup(Uid, title, empty, "ms-appx:///Assets/Darkgray.png", ""); string empty2 = string.Empty; WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num2 = 0; string text2 = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text3 = string.Empty; string expr_31D = xmlReader.Name; if (expr_31D != null) { if (!(expr_31D == "yt:videoid")) { if (!(expr_31D == "title")) { if (!(expr_31D == "media:credit")) { if (!(expr_31D == "media:description")) { if (expr_31D == "yt:duration") { int num3 = Convert.ToInt32(xmlReader["seconds"]); if (num3 > 60) { int num4 = num3 / 60; int num5 = num3 % 60; if (num5 < 10) { str2 = num4.ToString() + ":0" + num5.ToString(); } else { str2 = num4.ToString() + ":" + num5.ToString(); } } else { str2 = "0:" + num3.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { text2 = xmlReader.ReadElementContentAsString(); } } else { text3 = xmlReader.ReadElementContentAsString(); string text4 = "http://i.ytimg.com/vi/" + text3 + "/hqdefault.jpg"; if (empty2 == string.Empty) { youtubeDataGroup.SetImage(text4); } item = new YoutubeDataItem(Uid + num2.ToString() + text2, text2, "by " + str + " | " + str2, text4, description, text3, youtubeDataGroup); item._Grouping = standardfeed; youtubeDataGroup.Items.Add(item); } } } num2++; } webRequest.Abort(); webResponse.Dispose(); webRequest = null; webResponse = null; xmlReader = null; xDocument = null; item = null; result = youtubeDataGroup; } catch (Exception) { result = null; } return result; }
private async Task<YoutubeDataItem> GetYoutubeDataItemAsync(string Uid, string videoID, YoutubeDataGroup group) { string text = "http://gdata.youtube.com/feeds/api/videos/" + videoID + "?v=2"; new Uri(text); YoutubeDataItem result; try { YoutubeDataItem youtubeDataItem = null; WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num = 0; string title = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text2 = string.Empty; string expr_165 = xmlReader.Name; if (expr_165 != null) { if (!(expr_165 == "yt:videoid")) { if (!(expr_165 == "title")) { if (!(expr_165 == "media:credit")) { if (!(expr_165 == "media:description")) { if (expr_165 == "yt:duration") { int num2 = Convert.ToInt32(xmlReader["seconds"]); if (num2 > 60) { int num3 = num2 / 60; int num4 = num2 % 60; if (num4 < 10) { str2 = num3.ToString() + ":0" + num4.ToString(); } else { str2 = num3.ToString() + ":" + num4.ToString(); } } else { str2 = "0:" + num2.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { title = xmlReader.ReadElementContentAsString(); } } else { text2 = xmlReader.ReadElementContentAsString(); string imagePath = "http://i.ytimg.com/vi/" + text2 + "/hqdefault.jpg"; youtubeDataItem = new YoutubeDataItem(text2, title, "by " + str + " | " + str2, imagePath, description, text2, group); } } } num++; } result = youtubeDataItem; } catch (Exception ex) { result = null; } return result; }
private async Task GetYoutubeDataGroupAsync(string Uid, string Keyword, int MaxResults, int Page = 0) { string text = string.Concat(new object[] { "http://gdata.youtube.com/feeds/api/videos?max-results=", MaxResults, "&v=2&q=", Keyword, "&start-index=", ((Page * MaxResults) + 1) }); new Uri(text); YoutubeDataGroup result; try { YoutubeDataItem item = null; YoutubeDataGroup youtubeDataGroup = new YoutubeDataGroup(Uid, "Search: " + Keyword, Keyword, "ms-appx:///Assets/Darkgray.png", ""); WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num = 0; string title = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; //SearchFeedResults.Clear(); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text2 = string.Empty; string expr_1BE = xmlReader.Name; if (expr_1BE != null) { if (!(expr_1BE == "yt:videoid")) { if (!(expr_1BE == "title")) { if (!(expr_1BE == "media:credit")) { if (!(expr_1BE == "media:description")) { if (expr_1BE == "yt:duration") { int num2 = Convert.ToInt32(xmlReader["seconds"]); if (num2 > 60) { int num3 = num2 / 60; int num4 = num2 % 60; if (num4 < 10) { str2 = num3.ToString() + ":0" + num4.ToString(); } else { str2 = num3.ToString() + ":" + num4.ToString(); } } else { str2 = "0:" + num2.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { title = xmlReader.ReadElementContentAsString(); } } else { text2 = xmlReader.ReadElementContentAsString(); string imagePath = "http://i.ytimg.com/vi/" + text2 + "/hqdefault.jpg"; item = new YoutubeDataItem(num.ToString(), title, "by " + str + " | " + str2, imagePath, description, text2, youtubeDataGroup); youtubeDataGroup.Items.Add(item); StandardFeedResults.Add(item); } } } num++; } result = youtubeDataGroup; } catch (Exception) { result = null; } return; }
private async Task <YoutubeDataGroup> GetUserFavoriteFeedAsync(string Uid, string user) { string text = "http://gdata.youtube.com/feeds/api/users/" + user + "/favorites?v=2&max-results=25"; new Uri(text); YoutubeDataGroup result; try { YoutubeDataItem item = null; YoutubeDataGroup youtubeDataGroup = new YoutubeDataGroup(Uid, user.ToUpper(), "", "ms-appx:///Assets/Darkgray.png", ""); WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num = 0; string title = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text2 = string.Empty; string expr_193 = xmlReader.Name; if (expr_193 != null) { if (!(expr_193 == "yt:videoid")) { if (!(expr_193 == "title")) { if (!(expr_193 == "media:credit")) { if (!(expr_193 == "media:description")) { if (!(expr_193 == "yt:duration")) { if (expr_193 == "gd:rating") { float.Parse(xmlReader["average"].ToString()); } } else { int num2 = Convert.ToInt32(xmlReader["seconds"]); if (num2 > 60) { int num3 = num2 / 60; int num4 = num2 % 60; if (num4 < 10) { str2 = num3.ToString() + ":0" + num4.ToString(); } else { str2 = num3.ToString() + ":" + num4.ToString(); } } else { str2 = "0:" + num2.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { title = xmlReader.ReadElementContentAsString(); } } else { text2 = xmlReader.ReadElementContentAsString(); string imagePath = "http://i.ytimg.com/vi/" + text2 + "/hqdefault.jpg"; item = new YoutubeDataItem(Uid + num.ToString(), title, "by " + str + " | " + str2, imagePath, description, text2, youtubeDataGroup); youtubeDataGroup.Items.Add(item); } } } num++; } webRequest.Abort(); webResponse.Dispose(); webRequest = null; webResponse = null; xmlReader = null; xDocument = null; item = null; result = youtubeDataGroup; } catch (Exception) { result = null; } return(result); }
private async Task <YoutubeDataGroup> GetStandardfeedAsync(string Uid, string standardfeed) { string text = "http://gdata.youtube.com/feeds/api/standardfeeds/" + standardfeed + "?v=2&max-results=25"; new Uri(text); string title = string.Empty; string empty = string.Empty; switch (standardfeed) { case "top_rated": title = "Top Rated"; break; case "top_favorites": title = "Favorites"; break; case "most_viewed": title = "Most Viewed"; break; case "most_shared": title = "Most Shared"; break; case "most_popular": title = "Most Popular"; break; case "most_recent": title = "Most Recent"; break; case "most_discussed": title = "Most Discussed"; break; case "most_responded": title = "Most Responded"; break; case "recently_featured": title = "Recently Featured"; break; case "on_the_web": title = "Trends"; break; } YoutubeDataGroup result; try { YoutubeDataItem item = null; YoutubeDataGroup youtubeDataGroup = new YoutubeDataGroup(Uid, title, empty, "ms-appx:///Assets/Darkgray.png", ""); string empty2 = string.Empty; WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num2 = 0; string text2 = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text3 = string.Empty; string expr_31D = xmlReader.Name; if (expr_31D != null) { if (!(expr_31D == "yt:videoid")) { if (!(expr_31D == "title")) { if (!(expr_31D == "media:credit")) { if (!(expr_31D == "media:description")) { if (expr_31D == "yt:duration") { int num3 = Convert.ToInt32(xmlReader["seconds"]); if (num3 > 60) { int num4 = num3 / 60; int num5 = num3 % 60; if (num5 < 10) { str2 = num4.ToString() + ":0" + num5.ToString(); } else { str2 = num4.ToString() + ":" + num5.ToString(); } } else { str2 = "0:" + num3.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { text2 = xmlReader.ReadElementContentAsString(); } } else { text3 = xmlReader.ReadElementContentAsString(); string text4 = "http://i.ytimg.com/vi/" + text3 + "/hqdefault.jpg"; if (empty2 == string.Empty) { youtubeDataGroup.SetImage(text4); } item = new YoutubeDataItem(Uid + num2.ToString() + text2, text2, "by " + str + " | " + str2, text4, description, text3, youtubeDataGroup); item._Grouping = standardfeed; youtubeDataGroup.Items.Add(item); } } } num2++; } webRequest.Abort(); webResponse.Dispose(); webRequest = null; webResponse = null; xmlReader = null; xDocument = null; item = null; result = youtubeDataGroup; } catch (Exception) { result = null; } return(result); }
private async Task <YoutubeDataItem> GetYoutubeDataItemAsync(string Uid, string videoID, YoutubeDataGroup group) { string text = "http://gdata.youtube.com/feeds/api/videos/" + videoID + "?v=2"; new Uri(text); YoutubeDataItem result; try { YoutubeDataItem youtubeDataItem = null; WebRequest webRequest = WebRequest.Create(text); webRequest.Method = "GET"; WebResponse webResponse = await webRequest.GetResponseAsync(); XDocument xDocument = XDocument.Load(webResponse.GetResponseStream()); XmlReader xmlReader = xDocument.CreateReader(); int num = 0; string title = string.Empty; string str = string.Empty; string str2 = string.Empty; string description = string.Empty; while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { string text2 = string.Empty; string expr_165 = xmlReader.Name; if (expr_165 != null) { if (!(expr_165 == "yt:videoid")) { if (!(expr_165 == "title")) { if (!(expr_165 == "media:credit")) { if (!(expr_165 == "media:description")) { if (expr_165 == "yt:duration") { int num2 = Convert.ToInt32(xmlReader["seconds"]); if (num2 > 60) { int num3 = num2 / 60; int num4 = num2 % 60; if (num4 < 10) { str2 = num3.ToString() + ":0" + num4.ToString(); } else { str2 = num3.ToString() + ":" + num4.ToString(); } } else { str2 = "0:" + num2.ToString(); } } } else { description = xmlReader.ReadElementContentAsString(); } } else { str = xmlReader["yt:display"]; } } else { title = xmlReader.ReadElementContentAsString(); } } else { text2 = xmlReader.ReadElementContentAsString(); string imagePath = "http://i.ytimg.com/vi/" + text2 + "/hqdefault.jpg"; youtubeDataItem = new YoutubeDataItem(text2, title, "by " + str + " | " + str2, imagePath, description, text2, group); } } } num++; } result = youtubeDataItem; } catch (Exception ex) { result = null; } return(result); }