Exemple #1
0
        public CommentsResource.ListRequest GetCommentListRequest(string part, string parentId,
                                                                  CommentsResource.ListRequest.TextFormatEnum textFormat, string pageToken)
        {
            var commentListReq = _youTubeService.Comments.List("snippet");

            commentListReq.ParentId   = parentId;
            commentListReq.TextFormat = textFormat;
            commentListReq.PageToken  = pageToken;

            return(commentListReq);
        }
Exemple #2
0
        public IEnumerable <Comment> GetComments(string part, string parentId, CommentsResource.ListRequest.TextFormatEnum textFormat)
        {
            do
            {
                var commentListReq = _youTubeDataApi.GetCommentListRequest(part, parentId, textFormat, nextCommentsBatchToken);
                commentListReq.MaxResults = 100;
                var comments = commentListReq.ExecuteAsync().GetAwaiter().GetResult();
                nextCommentsBatchToken = comments.NextPageToken != nextCommentsBatchToken ? comments.NextPageToken : null;

                foreach (var comment in comments.Items)
                {
                    yield return(comment);
                }
            } while (nextCommentsBatchToken != null);
        }
Exemple #3
0
        public IEnumerable <Comment> GetComments(string part, string parentId, CommentsResource.ListRequest.TextFormatEnum textFormat)
        {
            do
            {
                var comments = _restApi.GetCommentsFromThread(parentId, part, textFormat.ToString(), nextCommentsBatchToken).GetAwaiter().GetResult();
                if (comments == null)
                {
                    nextCommentsBatchToken = null;
                    yield break;
                }

                nextCommentsBatchToken = comments.NextPageToken != nextCommentsBatchToken ? comments.NextPageToken : null;

                foreach (var comment in comments.Items)
                {
                    yield return(comment);
                }
            } while (nextCommentsBatchToken != null);
        }