当前位置: 首页>>代码示例>>C#>>正文


C# YouTubeRequest.GetSubscriptionsFeed方法代码示例

本文整理汇总了C#中YouTubeRequest.GetSubscriptionsFeed方法的典型用法代码示例。如果您正苦于以下问题:C# YouTubeRequest.GetSubscriptionsFeed方法的具体用法?C# YouTubeRequest.GetSubscriptionsFeed怎么用?C# YouTubeRequest.GetSubscriptionsFeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YouTubeRequest的用法示例。


在下文中一共展示了YouTubeRequest.GetSubscriptionsFeed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetListOfSubscriptions

        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;
        }
开发者ID:maxshlain,项目名称:ytpodcaster_00,代码行数:47,代码来源:SubscriptionsFetcher.cs

示例2: YouTubeSubscriptionsTest

        public void YouTubeSubscriptionsTest()
        {
            Tracing.TraceMsg("Entering YouTubeSubscriptionsTest");
            string playlistID = "4A3A73D5172EB90A";

            YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, this.ytClient, 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");
            }
        }
开发者ID:yodiz,项目名称:Avega.ContactSynchronizer,代码行数:58,代码来源:youtubetest.cs

示例3: YouTubeSubscriptionsTest

        public void YouTubeSubscriptionsTest() {
            Tracing.TraceMsg("Entering YouTubeSubscriptionsTest");
            string channelUsername = "GoogleDevelopers";

            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 = "GoogleDevelopers";

            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");
        }
开发者ID:saeedesmaeili,项目名称:google-gdata,代码行数:47,代码来源:youtubetest.cs


注:本文中的YouTubeRequest.GetSubscriptionsFeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。