Exemple #1
0
        public async Task <List <Series> > GetSeriesListAsync(int startId, int endId, HashSet <Genre> gl, HashSet <Network> nl)
        {
            List <Series> l  = new List <Series>();
            int           id = startId;

            try {
                for (; id <= endId; id++)
                {
                    using (HttpResponseMessage resp = TvDbClient.GetAsync("/series/" + id).Result) {
                        if (!resp.IsSuccessStatusCode)
                        {
                            Debug.WriteLine("No pude recuperar serie nº" + id + ". Boomer :(");
                            continue;
                        }

                        string jsonString = await resp.Content.ReadAsStringAsync();

                        TheTvDbSeries TvDbS = JsonConvert.DeserializeObject <TheTvDbSeries>(jsonString);
                        Series        s     = TvDbS.ToSeries(gl, nl);

                        if (String.IsNullOrWhiteSpace(s.seriesName))
                        {
                            continue;
                        }

                        s.actorList = await GetActorRolesBySeriesIdAsync(id);

                        foreach (ActorRole ar in s.actorList)
                        {
                            ar.series = s;
                        }

                        IMDbSeries IMDbS = await GetIMDbSeriesAsync(s.imbdId);

                        if (IMDbS != null)
                        {
                            s.posterUrl = IMDbS.Poster;
                        }

                        s.seasonList = await GetSeasonListSeriesIdAsync(id);

                        foreach (Season se in s.seasonList)
                        {
                            se.series = s;
                        }

                        l.Add(s);
                    }
                }
            } catch (Exception e) {
                MessageBox.Show(e.Message, "Excepción procesando la serie nº" + id + ".");
            }

            return(l);
        }