youtube v3 api request timeout

Viewed 659

I'm working on project that uses the YouTube api v3 with the Google .net client libary.

It's done, however sometimes it takes long time to respond when getting a video-list from playlist id. When this happens, it gives error "bad request" after 1 minute and tells me request timed out.

Is there any way to increase the request timeout or another solution for this problem?

List<YTVideo> videos = new List<YTVideo>();
var searchRequest = youtubeService.PlaylistItems.List("snippet");
                searchRequest.PlaylistId = playlistId;
                searchRequest.MaxResults = 1;
                var searchResponse = await searchRequest.ExecuteAsync();
                var playlistItemsInfo = searchResponse.Items.FirstOrDefault();
// to get videos from playlistItemsInfo
foreach (var searchResult in searchResponse.Items)
                    {
                        var videoSearchRequest = youtubeService.Videos.List("snippet, statistics, contentDetails");
                        videoSearchRequest.Id = searchResult.Snippet.ResourceId.VideoId;
                        videoSearchRequest.MaxResults = 1;
                        var videoSearchResponse = videoSearchRequest.Execute();
                        var video = videoSearchResponse.Items.FirstOrDefault();
                        if (video != null)
                        {
                            YTVideo yTVideo = new YTVideo
                            {
                                Title = video.Snippet.Title,
                                VideoId = video.Id,
                                Image = video.Snippet.Thumbnails.Maxres != null ? video.Snippet.Thumbnails.Maxres.Url : video.Snippet.Thumbnails.High.Url,
                                IsSelected = true
                            };
                            videos.Add(yTVideo);
                        }
                    }

My problem happens in searchResponse when I execute search the request.

0 Answers
Related