Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        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);
        }