Exemplo n.º 1
0
        public static void updateSubscriptions()
        {
            subUpdate++;
            Log <Youtube> .Debug("Update subscriptions tries = {0} - subscriptions.Count - {1}", subUpdate, Youtube.subscriptions.Count);

            if (Youtube.subscriptions.Count == 0 || subUpdate % 20 == 0)
            {
                Youtube.subscriptions.Clear();

                string       feedUrl = "http://gdata.youtube.com/feeds/api/users/default/subscriptions";
                YouTubeQuery query   = new YouTubeQuery(feedUrl);
                Log <Youtube> .Debug("feedUrl for subscriptions: {0}", feedUrl);

                SubscriptionFeed subFeed = null;
                string           url     = "http://www.youtube.com/user/{0}";
                try
                {
                    subFeed = service.GetSubscriptions(query);
                    if (subFeed.Entries.Count > 0)
                    {
                        foreach (SubscriptionEntry entry in subFeed.Entries)
                        {
                            YouTubeSubscriptionItem subscription =
                                new YouTubeSubscriptionItem(entry.UserName, String.Format(url, entry.UserName), entry.Title.Text);
                            Youtube.subscriptions.Add(subscription);
                        }
                    }
                    Log <Youtube> .Debug("Finished updating subscriptions");
                }
                catch (Exception e)
                {
                    Log <Youtube> .Error("Error getting subscriptions - {0}", e.Message);

                    Log <Youtube> .Debug(e.StackTrace);
                }
            }
        }