JryVideo.Core.TheTVDB.TheTVDBClient.GetSeriesByImdbIdAsync C# (CSharp) Method

GetSeriesByImdbIdAsync() public method

public GetSeriesByImdbIdAsync ( string imdbId ) : Task>
imdbId string
return Task>
        public async Task<IEnumerable<Series>> GetSeriesByImdbIdAsync(string imdbId)
        {
            if (imdbId == null) throw new ArgumentNullException(nameof(imdbId));
            if (!imdbId.StartsWith("tt")) throw new ArgumentException(nameof(imdbId));
            if (this.allMirror.Count == 0) throw new NotSupportedException();

            var url = $"{this.allMirror.RandomTake().MirrorPath}/api/GetSeriesByRemoteID.php?imdbid={imdbId}";
            var request = WebRequest.CreateHttp(url);
            var result = (await request.GetResultAsBytesAsync()).AsXml<SeriesArray>();
            if (result.IsSuccess && result.Result?.Series != null) return result.Result.Series;
            return Enumerable.Empty<Series>();
        }

Usage Example

Ejemplo n.º 1
0
        public async void BeginLoadPosterByImdbId(TheTVDBClient client, string imdbId)
        {
            if (client == null) throw new ArgumentNullException(nameof(client));
            if (imdbId == null) throw new ArgumentNullException(nameof(imdbId));

            var videos = (await client.GetSeriesByImdbIdAsync(imdbId)).ToArray();
            if (videos.Length == 0)
            {
                this.Load(Enumerable.Empty<string>());
            }
            else
            {
                var urls = (await videos[0].GetBannersAsync(JryVideoCore.Current.GetTheTVDBClient()))
                    .Where(z => z.BannerType == BannerType.Poster)
                    .Select(z => z.BuildUrl(client))
                    .ToArray();
                this.Load(urls);
            }
        }
All Usage Examples Of JryVideo.Core.TheTVDB.TheTVDBClient::GetSeriesByImdbIdAsync