Guest User

Untitled

a guest
Aug 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public Task<List<SearchResult>> GetVideosFromChannelAsync(string ytChannelId)
  2. {
  3.  
  4. return Task.Run(() =>
  5. {
  6. List<SearchResult> res = new List<SearchResult>();
  7.  
  8. string nextpagetoken = " ";
  9.  
  10. while (nextpagetoken != null)
  11. {
  12. var searchListRequest = _youtubeService.Search.List("snippet");
  13. searchListRequest.MaxResults = 50;
  14. searchListRequest.ChannelId = ytChannelId;
  15. searchListRequest.PageToken = nextpagetoken;
  16. searchListRequest.Type = "video";
  17.  
  18. // Call the search.list method to retrieve results matching the specified query term.
  19. var searchListResponse = searchListRequest.Execute();
  20.  
  21. // Process the video responses
  22. res.AddRange(searchListResponse.Items);
  23.  
  24. nextpagetoken = searchListResponse.NextPageToken;
  25.  
  26. }
  27.  
  28. return res;
  29.  
  30. });
  31. }
Add Comment
Please, Sign In to add comment