private async Task <IEnumerable <RemoteChapterResult> > FetchAsyncInternal(ChapterSearchRequest request, CancellationToken cancellationToken) { string imdbIdText = request.GetProviderId(MetadataProviders.Imdb); long imdbId = 0; long.TryParse(imdbIdText.TrimStart('t'), NumberStyles.Any, _usCulture, out imdbId); var p = new SearchParameters { Type = SearchType.Search, Title = request.Name, Language = request.Language, Show = request.SeriesName, Season = request.ParentIndexNumber, Episode = request.IndexNumber, VideoKind = request.ContentType == VideoContentType.Movie ? "Movie" : "TVShow", ImdbId = imdbId > 0 ? imdbId.ToString() : null, Token = ApiKey, Locked = true, }; var url = BaseUrl + p.BuildQueryString(); using (var stream = await _httpClient.Get(new HttpRequestOptions { Url = url, ResourcePool = _resourcePool, CancellationToken = cancellationToken }).ConfigureAwait(false)) { var result = _xmlSerializer.DeserializeFromStream(typeof(SearchResults), stream) as SearchResults; if (result == null) { return(new List <RemoteChapterResult>()); } var first = result.Movies.FirstOrDefault(); if (first != null) { return(first.Chapters.Items.Select(x => new RemoteChapterResult { Id = x.Index.ToString(), Name = x.Title, RunTimeTicks = x.StartTime.Ticks })); } else { return(new List <RemoteChapterResult>()); } } }