Skip to content

Instantly share code, notes, and snippets.

@HristoKolev
Created March 15, 2017 17:44
Show Gist options
  • Save HristoKolev/7b4bdeaca44bbc8cddee67d0c2530e65 to your computer and use it in GitHub Desktop.
Save HristoKolev/7b4bdeaca44bbc8cddee67d0c2530e65 to your computer and use it in GitHub Desktop.
namespace ConsoleApp5
{
using System;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TvDbSharper;
using TvDbSharper.BaseSchemas;
using TvDbSharper.Clients.Authentication.Json;
using TvDbSharper.Clients.Series.Json;
public class EntryPint
{
public static void Main(string[] args) => new EntryPint().MainAsync(args).GetAwaiter().GetResult();
public async Task MainAsync(string[] args)
{
const int SeriesId = 267777;
var client = new TvDbClient();
await client.Authentication.AuthenticateAsync(new AuthenticationData("xxxxxxxxxxxxxx"));
var tasks = new List<Task<TvDbResponse<BasicEpisode[]>>>();
var firstResponse = await client.Series.GetEpisodesAsync(SeriesId, 1);
for (int i = 2; i <= firstResponse.Links.Last; i++)
{
tasks.Add(client.Series.GetEpisodesAsync(SeriesId, i));
}
var results = await Task.WhenAll(tasks);
var episodes = firstResponse.Data.Concat(results.SelectMany(x => x.Data));
Console.WriteLine(episodes.Count()); // 263
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment