Exemplo n.º 1
0
 public TvDbClientManager(IMemoryCache memoryCache)
 {
     _cache      = memoryCache;
     _tvDbClient = new TvDbClient();
     _tvDbClient.Authentication.AuthenticateAsync(TvdbUtils.TvdbApiKey);
     _tokenCreatedAt = DateTime.Now;
 }
            public TvDbClientInfo(IHttpClientFactory httpClientFactory, string language)
            {
                Client = new TvDbClient(httpClientFactory.CreateClient(NamedClient.Default))
                {
                    AcceptedLanguage = language
                };

                TokenUpdateLock = new SemaphoreSlim(1, 1);
                TokenUpdatedAt  = DateTime.MinValue;
            }
Exemplo n.º 3
0
        public async Task <int> tvdbIdByTitle(string title)
        {
            var client = new TvDbClient();
            await client.Authentication.AuthenticateAsync("F6EE96D0B5484A59");


            var showTvDbSearch = (await client.Search.SearchSeriesByNameAsync(title)).Data;

            return(showTvDbSearch.First().Id);
        }
Exemplo n.º 4
0
        public async Task GetSeriesAsync_FailedResponse_ReturnsNone()
        {
            _jsonConnection.GetAsync(Arg.Any <GetSeriesRequest>(), Arg.Any <Option <string> >())
            .Returns(new FailedRequest(HttpStatusCode.BadRequest, "Failed"));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            var seriesResult = await tvDbClient.GetSeriesAsync(4);

            seriesResult.IsSome.Should().BeFalse();
        }
        public async Task FindSeriesAsync_NoMatchingSeriesName_ReturnsNone()
        {
            var client = new TvDbClient(new JsonConnection(new TestHttpClient(), new JsonSerialiser(), _logManager),
                                        _fileCache, _applicationPaths, _logManager, new JsonSerialiser(), new PluginConfiguration
            {
                TvDbApiKey = Secrets.TvDbApiKey
            });

            var seriesResult = await client.FindSeriesAsync("NotASeries");

            seriesResult.IsSome.Should().BeFalse();
        }
Exemplo n.º 6
0
        internal async Task <tvShows> GetTvShowsByTvDbIdAsync(int id)
        {
            var client = new TvDbClient();

            client.AcceptedLanguage = "de";
            await client.Authentication.AuthenticateAsync(Data.ApiKey, Data.UserName, Data.UserKey);

            var response = await client.Series.GetAsync(id);

            tvShows shows = new tvShows(response);

            return(shows);
        }
Exemplo n.º 7
0
        internal async Task <tvShows> GetTvShowsByNameAsync(string tvShowName)
        {
            var client = new TvDbClient();

            client.AcceptedLanguage = "de";
            await client.Authentication.AuthenticateAsync(Data.ApiKey, Data.UserName, Data.UserKey);

            var response = await client.Search.SearchSeriesByNameAsync(tvShowName);

            tvShows shows = new tvShows(response, tvShowName);

            return(shows);
        }
        public MissingEpisodeProvider(
            IProviderManager providerManager,
            ILocalizationManager localization,
            ILibraryManager libraryManager,
            ILogger <MissingEpisodeProvider> logger)
        {
            _providerManager = providerManager;
            _localization    = localization;
            _libraryManager  = libraryManager;
            _logger          = logger;

            _tvDbClient = new TvDbClient();
        }
Exemplo n.º 9
0
        private async Task InitialiseAsync()
        {
            if (_client is null)
            {
                _client = new TvDbClient();

                var credentials = Environment.GetEnvironmentVariable("THETVDB_CREDENTIALS");
                var parts       = credentials.Split('!');
                if (parts.Length == 3)
                {
                    await _client.Authentication.AuthenticateAsync(parts[0], parts[1], parts[2]);
                }
            }
        }
Exemplo n.º 10
0
        public async Task GetEpisodesAsync_LocalEpisodeData_ReturnsLocalEpisodeData()
        {
            var episode = new TvDbEpisodeData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 3.77f, 12);

            _fileCache.GetFileContent(Arg.Any <TvDbSeriesEpisodesFileSpec>())
            .Returns(new TvDbEpisodeCollection(new[] { episode }));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            var episodes = await tvDbClient.GetEpisodesAsync(4);

            episodes.IsSome.Should().BeTrue();
            episodes.ValueUnsafe().Should().BeEquivalentTo(episode);
        }
Exemplo n.º 11
0
        public async Task GetEpisodesAsync_LocalEpisodeData_DoesNotRequestEpisodeData()
        {
            var episode = new TvDbEpisodeData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 3.77f, 12);

            _fileCache.GetFileContent(Arg.Any <TvDbSeriesEpisodesFileSpec>())
            .Returns(new TvDbEpisodeCollection(new[] { episode }));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            await tvDbClient.GetEpisodesAsync(4);

            _jsonConnection.DidNotReceiveWithAnyArgs()
            .GetAsync <GetEpisodesRequest.Response>(null, Option <string> .None);
        }
Exemplo n.º 12
0
        public async Task GetSeriesAsync_NoLocalSeriesData_ReturnsNewSeriesData()
        {
            var series = new TvDbSeriesData(4, "TestSeries", new DateTime(2017, 1, 1, 1, 1, 1), "", 2,
                                            AirDay.Monday, "", 4f, new[] { "Alias1", "Alias2" }, new[] { "Genre1", "Genre2" },
                                            "Overview");

            _jsonConnection.GetAsync(Arg.Any <GetSeriesRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetSeriesRequest.Response>(new GetSeriesRequest.Response(series)));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            var seriesResult = await tvDbClient.GetSeriesAsync(4);

            seriesResult.IsSome.Should().BeTrue();
            seriesResult.ValueUnsafe().Should().Be(series);
        }
Exemplo n.º 13
0
        public async Task GetSeriesAsync_NoLocalSeriesData_RequestsSeriesData()
        {
            var series = new TvDbSeriesData(4, "TestSeries", new DateTime(2017, 1, 1, 1, 1, 1), "", 2,
                                            AirDay.Monday, "", 4f, new[] { "Alias1", "Alias2" }, new[] { "Genre1", "Genre2" },
                                            "Overview");

            _jsonConnection.GetAsync(Arg.Any <GetSeriesRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetSeriesRequest.Response>(new GetSeriesRequest.Response(series)));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            await tvDbClient.GetSeriesAsync(4);

            _jsonConnection.ReceivedWithAnyArgs(1)
            .GetAsync <GetSeriesRequest.Response>(null, Option <string> .None);
        }
Exemplo n.º 14
0
        internal static void Save(Serie s)
        {
            using (MySqlConnection con = Database.GetConnection()) {
                ITvDbClient client = new TvDbClient();
                client.AcceptedLanguage = "es";
                var task = client.Authentication.AuthenticateAsync(Secrets.apiKey);
                task.Wait();

                var task2 = client.Series.GetAsync(s.IdSerie);
                task2.Wait();
                var result = task2.Result;

                s.SeriesName  = result.Data.SeriesName;
                s.SeriesPhoto = result.Data.Poster;

                con.Open();
                MySqlCommand command = con.CreateCommand();
                command.CommandText = "insert into series(idSerie, seriesName, seriesPhoto) values" +
                                      "(@idSerie, @seriesName, @seriesPhoto)";
                command.Parameters.AddWithValue("idSerie", s.IdSerie);
                command.Parameters.AddWithValue("seriesName", s.SeriesName);
                command.Parameters.AddWithValue("seriesPhoto", s.SeriesPhoto);
                Debug.WriteLine("comando" + command.CommandText);
                command.ExecuteNonQuery();

                int numPagina = 1;
                int numReturned;

                do
                {
                    var task3 = client.Series.GetEpisodesAsync(s.IdSerie, numPagina);
                    task3.Wait();
                    var episodes = task3.Result;
                    numReturned = episodes.Data.Length;
                    foreach (var e in episodes.Data)
                    {
                        if (e.AiredEpisodeNumber != 0 && e.AiredSeason != 0)
                        {
                            CapituloRepository.Save(new Capitulo(e.Id, e.SeriesId, e.AiredEpisodeNumber, e.AiredSeason, e.EpisodeName));
                        }
                    }
                    numPagina++;
                } while (numReturned == 100);
            }
        }
Exemplo n.º 15
0
        public async Task <Show> getShowByTvdbId(int tvdbId)
        {
            await _showAddLock.WaitAsync();

            try
            {
                var savedShow = await _dbContext.Shows.Include(b => b.Episodes).SingleOrDefaultAsync(s => s.TvdbId == tvdbId);

                if (savedShow != null)
                {
                    return(savedShow);
                }

                var client = new TvDbClient();
                await client.Authentication.AuthenticateAsync("F6EE96D0B5484A59");


                var showTvDb = (await client.Series.GetAsync(tvdbId)).Data;
                var show     = _mapper.Map <Show>(showTvDb);


                var tasks = new List <Task <TvDbResponse <EpisodeRecord[]> > >();


                var firstResponse = await client.Series.GetEpisodesAsync(tvdbId, 1);

                for (int i = 2; i <= firstResponse.Links.Last; i++)
                {
                    tasks.Add(client.Series.GetEpisodesAsync(tvdbId, i));
                }

                var results = await Task.WhenAll(tasks);

                var episodesTvDb = firstResponse.Data.Concat(results.SelectMany(x => x.Data));
                var episodes     = _mapper.Map <List <Episode> >(episodesTvDb);

                show.Episodes = episodes;

                _dbContext.Shows.Add(show);
                _dbContext.SaveChanges();
                return(show);
            } finally {
                _showAddLock.Release();
            }
        }
Exemplo n.º 16
0
        public static void Main(string[] args)
        {
            using (new LoggingScope(FindFile(LoggingScope.DefaultConfigFile)))
            {
                try
                {
                    Log.Debug($"New run with command line: {Environment.CommandLine}");
                    Log.Debug($"Current directory: {Environment.CurrentDirectory}");

                    var arguments = Arguments.Parse(args);
                    var options   = LoadOptions(arguments.Options);

                    var client = new TvDbClient(options.TvDb.ApiKey, options.TvDb.UserKey, options.TvDb.UserName);
                    client.Login().Wait();

                    var copier  = new Copier(arguments, client, options);
                    int matches = copier.CopyFiles().Result;

                    if (matches == 0)
                    {
                        Log.Warn($"No matches were found!");
                    }
                }
                catch (FatalException fe)
                {
                    Log.Error(fe.Message);
                }
                catch (AggregateException ae)
                {
                    if (ae.InnerException is FatalException)
                    {
                        Log.Error(ae.InnerException.Message);
                    }
                    else
                    {
                        Log.Error(ae);
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
        public async Task GetSeriesAsync_ValidSeriesId_ReturnsSeriesData()
        {
            var client = new TvDbClient(new JsonConnection(new TestHttpClient(), new JsonSerialiser(), _logManager),
                                        _fileCache, _applicationPaths, _logManager, new JsonSerialiser(), new PluginConfiguration
            {
                TvDbApiKey = Secrets.TvDbApiKey
            });

            var seriesResult = await client.GetSeriesAsync(80675);

            seriesResult.IsSome.Should().BeTrue();

            var series = seriesResult.ValueUnsafe();

            series.Should().BeEquivalentTo(new TvDbSeriesData(80675, "Mobile Suit Gundam 00",
                                                              new DateTime(2007, 10, 6), "Tokyo Broadcasting System", 30, AirDay.Saturday, "6:00 PM",
                                                              9.4f, new string[] { }, new[] { "Animation", "Drama", "Science-Fiction" },
                                                              "2307 AD.\r\nAs fossil fuels became exhausted, humanity found a new energy source to change their situation: A large-scale solar power system with three enormous orbiting elevators. However, only a few large countries and their allies reaped the benefits.\r\nThree superpowers had ownership of the three orbiting elevators: The Union, based in the United States Of America, The People`s Reform League, made up of China, Russia, and India, and Europe`s AEU. The superpowers continue playing a large zero-sum game for their own dignity and respective prosperity. Even though it is the 24th century, humanity has yet to become one.\r\nIn this world where war has no end, a private militia appears advocating the eradication of war through force. Each possessing a mobile suit Gundam, they are Celestial Being. The armed intervention by the Gundams against all acts of war begins."));
        }
Exemplo n.º 18
0
        public async Task GetEpisodesAsync_MultiPageResponse_RequestsAllPages()
        {
            var page1Episode       = new TvDbEpisodeSummaryData(1, "Test1", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview");
            var page1EpisodeDetail = new TvDbEpisodeData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 33.4f, 12);

            var page2Episode       = new TvDbEpisodeSummaryData(2, "Test2", 5L, 6, 7, 8, new DateTime(2017, 1, 2, 3, 4, 5), "Overview");
            var page2EpisodeDetail = new TvDbEpisodeData(2, "Test2", 5L, 6, 7, 8, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 33.4f, 12);

            _jsonConnection
            .GetAsync(Arg.Is <GetEpisodesRequest>(r => r.Url == "https://api.thetvdb.com/series/4/episodes?page=1"),
                      Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodesRequest.Response>(new GetEpisodesRequest.Response(
                                                                    new[] { page1Episode },
                                                                    new GetEpisodesRequest.PageLinks(1, 2, 2, Option <int> .None))));
            _jsonConnection.GetAsync(Arg.Is <GetEpisodeDetailsRequest>(r => r.Url.EndsWith("1")), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodeDetailsRequest.Response>(
                         new GetEpisodeDetailsRequest.Response(page1EpisodeDetail)));

            _jsonConnection
            .GetAsync(Arg.Is <GetEpisodesRequest>(r => r.Url == "https://api.thetvdb.com/series/4/episodes?page=2"),
                      Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodesRequest.Response>(new GetEpisodesRequest.Response(
                                                                    new[] { page2Episode },
                                                                    new GetEpisodesRequest.PageLinks(2, 2, Option <int> .None, 1))));
            _jsonConnection.GetAsync(Arg.Is <GetEpisodeDetailsRequest>(r => r.Url.EndsWith("2")), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodeDetailsRequest.Response>(
                         new GetEpisodeDetailsRequest.Response(page2EpisodeDetail)));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            await tvDbClient.GetEpisodesAsync(4);

            _jsonConnection.Received(1)
            .GetAsync(Arg.Is <GetEpisodesRequest>(r => r.Url == "https://api.thetvdb.com/series/4/episodes?page=1"),
                      Arg.Any <Option <string> >());
            _jsonConnection.Received(1)
            .GetAsync(Arg.Is <GetEpisodesRequest>(r => r.Url == "https://api.thetvdb.com/series/4/episodes?page=2"),
                      Arg.Any <Option <string> >());
            _jsonConnection.ReceivedWithAnyArgs(2)
            .GetAsync <GetEpisodeDetailsRequest.Response>(null, Option <string> .None);
        }
Exemplo n.º 19
0
        public async Task GetEpisodeAsync_NoLocalEpisodeData_ReturnsNewEpisodeData()
        {
            var episode       = new TvDbEpisodeSummaryData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview");
            var episodeDetail = new TvDbEpisodeData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 33.4f, 12);

            _jsonConnection.GetAsync(Arg.Any <GetEpisodesRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodesRequest.Response>(new GetEpisodesRequest.Response(new[] { episode },
                                                                                                new GetEpisodesRequest.PageLinks(1, 1, Option <int> .None, Option <int> .None))));
            _jsonConnection.GetAsync(Arg.Any <GetEpisodeDetailsRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodeDetailsRequest.Response>(
                         new GetEpisodeDetailsRequest.Response(episodeDetail)));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            var episodes = await tvDbClient.GetEpisodesAsync(4);

            episodes.IsSome.Should().BeTrue();
            episodes.ValueUnsafe().Should().BeEquivalentTo(episodeDetail);
        }
Exemplo n.º 20
0
        public async Task <ActionResult <IEnumerable <EpisodeRecord> > > GetEpisodes(int id)
        {
            var client = new TvDbClient();
            await client.Authentication.AuthenticateAsync("F6EE96D0B5484A59");

            var tasks = new List <Task <TvDbResponse <EpisodeRecord[]> > >();

            var firstResponse = await client.Series.GetEpisodesAsync(id, 1);

            for (int i = 2; i <= firstResponse.Links.Last; i++)
            {
                tasks.Add(client.Series.GetEpisodesAsync(id, i));
            }

            var results = await Task.WhenAll(tasks);

            var episodesTvDb = firstResponse.Data.Concat(results.SelectMany(x => x.Data));
            var episodes     = _mapper.Map <List <Episode> >(episodesTvDb);

            return(Ok(episodes));
        }
        public async Task GetEpisodesAsync_ValidSeriesId_ReturnsEpisodes()
        {
            var client = new TvDbClient(new JsonConnection(new TestHttpClient(), new JsonSerialiser(), _logManager),
                                        _fileCache, _applicationPaths, _logManager, new JsonSerialiser(), new PluginConfiguration
            {
                TvDbApiKey = Secrets.TvDbApiKey
            });

            var episodesResult = await client.GetEpisodesAsync(80675);

            episodesResult.IsSome.Should().BeTrue();
            var episodes = episodesResult.ValueUnsafe().ToList();

            episodes.Should().HaveCount(57);

            episodes[0]
            .Should().BeEquivalentTo(new TvDbEpisodeData(340368, "Celestial Being", 1L, 1, 1, 1496255818,
                                                         new DateTime(2007, 10, 6),
                                                         "Celestial Being, a private army dedicated to eradicating war, begins demonstrating the powers of their new \"MS-GUNDAM\" suits by interrupting the public demonstration of AEU's latest Mobile Suit, the AEU Enact and by protecting the Human Reform League's Space Elevator, \"Tenchu\" from being attacked by terrorists when their mobile suits had attempted to launch rockets on the \"Tenchu\", earning a news appearance from various TV news channels where Celestial Being's goals were publicly stated by Aeoria Schenberg.",
                                                         8.2f, 5));
        }
Exemplo n.º 22
0
        public async Task GetEpisodeAsync_NoLocalEpisodeData_SavesNewEpisodeData()
        {
            var episode       = new TvDbEpisodeSummaryData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview");
            var episodeDetail = new TvDbEpisodeData(1, "Test", 1L, 2, 3, 4, new DateTime(2017, 1, 2, 3, 4, 5), "Overview", 33.4f, 12);

            _jsonConnection.GetAsync(Arg.Any <GetEpisodesRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodesRequest.Response>(new GetEpisodesRequest.Response(new[] { episode },
                                                                                                new GetEpisodesRequest.PageLinks(1, 1, Option <int> .None, Option <int> .None))));
            _jsonConnection.GetAsync(Arg.Any <GetEpisodeDetailsRequest>(), Arg.Any <Option <string> >())
            .Returns(new Response <GetEpisodeDetailsRequest.Response>(
                         new GetEpisodeDetailsRequest.Response(episodeDetail)));

            var tvDbClient = new TvDbClient(_jsonConnection, _fileCache, _applicationPaths, _logManager,
                                            new JsonSerialiser(), new PluginConfiguration());

            await tvDbClient.GetEpisodesAsync(4);

            _fileCache.Received(1)
            .SaveFile(Arg.Any <TvDbSeriesEpisodesFileSpec>(),
                      Arg.Is <TvDbEpisodeCollection>(d => d.Episodes.Single() == episodeDetail));
        }
Exemplo n.º 23
0
 public TvdbClientManager(IMemoryCache memoryCache)
 {
     _cache      = memoryCache;
     _tvDbClient = new TvDbClient();
 }
Exemplo n.º 24
0
        private async void GetEpisodes()
        {
            if (TvShows != null)
            {
                //Load Episode Data from TvShows and write back to TvShows;
                var client = new TvDbClient();
                await client.Authentication.AuthenticateAsync(Data.ApiKey, Data.UserName, Data.UserKey);

                client.AcceptedLanguage = Data.prefLang;

                var    tasks    = new List <Task <TvDbResponse <TvDbSharper.Dto.EpisodeRecord[]> > >();
                var    response = new TvDbResponse <EpisodeRecord[]>();
                tvShow show     = TvShows.Find(i => i.tvdbID == actualTvDbID);
                if (show.Count > 1)
                {
                    foreach (showEpisode ep in TvShows.Where(i => i.tvdbID == actualTvDbID))
                    {
                        response = await client.Series.GetEpisodesAsync(ep.tvdbID, 1);

                        for (int i = 2; i <= response.Links.Last; i++)
                        {
                            tasks.Add(client.Series.GetEpisodesAsync(ep.tvdbID, i));
                        }
                    }
                }
                else
                {
                    EpisodeQuery q = new EpisodeQuery();
                    q.AiredSeason  = TvShows[0][0].seasonNr;
                    q.AiredEpisode = TvShows[0][0].episodeNr;
                    response       = await client.Series.GetEpisodesAsync(show.tvdbID, 1, q);
                }

                var results = await Task.WhenAll(tasks);


                //var eps = response.Data.Concat(results.SelectMany(x => x.Data));
                foreach (EpisodeRecord er in response.Data.Concat(results.SelectMany(x => x.Data)))
                {
                    foreach (showEpisode ep in TvShows.Where(i => i.tvdbID == actualTvDbID))
                    {
                        if (er.AiredSeason == ep.seasonNr && er.AiredEpisodeNumber == ep.episodeNr)
                        {
                            //DateTime dt = DateTime.Parse(ep.FirstAired);

                            if (er.EpisodeName == null) //Backup if no German
                            {
                                client.AcceptedLanguage = "en";
                                TvDbResponse <EpisodeRecord> er1 = await client.Episodes.GetAsync(er.Id);

                                ep.episodeName = er1.Data.EpisodeName;
                                ep.description = er1.Data.Overview;
                            }
                            else
                            {
                                ep.episodeName = er.EpisodeName;
                                ep.description = er.Overview;
                            }
                            ep.tvDbEpisodeId = er.Id;
                            if (helper.isDateTime(er.FirstAired))
                            {
                                ep.episodeAirDate = DateTime.Parse(er.FirstAired);
                            }
                            if (ep.episodeName != null && ep.episodeNumbering != null)
                            {
                                ep.newFilename = GetCorrectedFileName(ep.episodeName, ep.episodeNumbering);
                            }
                        }
                    }
                }
                //Episode not found in Episode List
            }
        }
Exemplo n.º 25
0
 public TvDbWrapper(string apiKey)
 {
     _client = new TvDbClient(apiKey);
     _client.AuthenticateAsync(apiKey);
     _apiKey = apiKey;
 }
Exemplo n.º 26
0
        static async Task Main(string[] args)
        {
            var httpClient = new HttpClient();

            var client = new TvDbClient(httpClient);

            var authenticationData = JsonConvert.DeserializeObject <AuthenticationData>(await File.ReadAllTextAsync("../../../auth.json"));

            await client.Authentication.AuthenticateAsync(authenticationData);

            client = new TvDbClient(httpClient);

            int seriesID = 83237;

            await client.Authentication.RefreshTokenAsync();

            var episode = (await client.Episodes.GetAsync(418910)).Data;

            var allLanguages = (await client.Languages.GetAllAsync()).Data;

            var language = (await client.Languages.GetAsync(allLanguages.First().Id.Value)).Data;

            var searchResult = (await client.Search.SearchSeriesAsync("stargate", SearchParameter.Name)).Data;

            var searchBySlug = (await client.Search.SearchSeriesBySlugAsync("stargate-universe")).Data;

            var searchByImdb = (await client.Search.SearchSeriesByImdbIdAsync("tt1286039")).Data;

            var searchByZap = (await client.Search.SearchSeriesByZap2ItIdAsync("EP01183982")).Data;

            var searchByZap2 = (await client.Search.SearchSeriesAsync("EP01183982", "zap2itId")).Data;

            var show = (await client.Series.GetAsync(seriesID)).Data;

            var actors = (await client.Series.GetActorsAsync(seriesID)).Data;

            var allEpisodes = (await client.Series.GetEpisodesAsync(seriesID, 0)).Data;

            var headers = (await client.Series.GetHeadersAsync(seriesID));

            var images = (await client.Series.GetImagesAsync(seriesID, new ImagesQuery()
            {
                KeyType = KeyType.Poster
            })).Data;

            var images2 = (await client.Series.GetImagesAsync(seriesID, new ImagesQueryAlternative()
            {
                KeyType = "poster"
            })).Data;

            var summaries = (await client.Series.GetEpisodesSummaryAsync(seriesID)).Data;

            var imageSummaries = (await client.Series.GetImagesSummaryAsync(seriesID)).Data;

            var updates = (await client.Updates.GetAsync(DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now)).Data;

            // user API

            var userData = (await client.Users.GetAsync()).Data;

            // var allRatings = (await client.Users.GetRatingsAsync(RatingType.Series)).Data;

            var ratings = (await client.Users.AddRatingAsync(RatingType.Series, seriesID, 10)).Data;

            await client.Users.RemoveRatingAsync(RatingType.Series, seriesID);

            var fav = (await client.Users.GetFavoritesAsync()).Data;

            var addFav = (await client.Users.AddToFavoritesAsync(seriesID)).Data;

            var remFav = (await client.Users.RemoveFromFavoritesAsync(seriesID)).Data;

            Console.WriteLine("Done.");
        }