Esempio n. 1
0
 private void cmdLoadByImdbId_Click(object sender, EventArgs e)
 {
     if (!txtImdbSearchId.Text.Equals(""))
     {
         TvdbSearchResult result = m_tvdbHandler.GetSeriesByRemoteId(ExternalId.ImdbId, txtImdbSearchId.Text);
         if (result != null)
         {
             List <TvdbSearchResult> list = new List <TvdbSearchResult>();
             list.Add(result);
             SearchResultForm form = new SearchResultForm(list);
             form.StartPosition = FormStartPosition.Manual;
             form.Left          = this.Left + this.Width / 2 - form.Width / 2;
             form.Top           = this.Top + this.Height / 2 - form.Height / 2;
             DialogResult res = form.ShowDialog();
             if (res == DialogResult.OK)
             {
                 LoadSeries(form.Selection.Id);
             }
         }
         else
         {
             MessageBox.Show("No results for this series");
         }
     }
 }
Esempio n. 2
0
        private TvdbSearchResult SearchSeries(string idOrName, bool stringIsIMDB = false)
        {
            TvdbSearchResult result;

            if (stringIsIMDB)
            {
                try
                {
                    result = TVDB.GetSeriesByRemoteId(ExternalId.ImdbId, idOrName);
                    if (result == null)
                    {
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured: " + ex.Message);
                    return(null);
                }
            }
            else
            {
                try
                {
                    var list = TVDB.SearchSeries(idOrName);
                    if (list.Count == 0)
                    {
                        MessageBox.Show("nothing found");
                        return(null);
                    }

                    int iResult;
                    if (list.Count > 1)
                    {
                        SearchResult w = new SearchResult();
                        w.SetItemSource(list);
                        w.ShowDialog();
                        iResult = w.SelectedIndex;
                    }
                    else
                    {
                        iResult = 0;
                    }

                    if (iResult < 0)
                    {
                        return(null);
                    }

                    result = list[iResult];
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured: " + ex.Message);
                    return(null);
                }
            }

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Gets Series information from TvDB.
 /// </summary>
 /// <param name="imdbId">The IMDB id for the Series.</param>
 /// <param name="series">Returns the Series information</param>
 /// <returns><c>true</c> if successful</returns>
 public bool GetSeries(string imdbId, out TvdbSearchResult series)
 {
     series = _tvdbHandler.GetSeriesByRemoteId(ExternalId.ImdbId, imdbId);
     return(series != null);
 }
Esempio n. 4
0
        public override bool UpdateFromOnlineSeries(SeriesInfo series, TvdbLanguage language, bool cacheOnly)
        {
            try
            {
                language = language ?? PreferredLanguage;

                TvdbSeries seriesDetail = null;
                if (series.TvdbId > 0)
                {
                    seriesDetail = _tvdbHandler.GetSeries(series.TvdbId, language, true, true, false);
                }
                if (seriesDetail == null && !cacheOnly && !string.IsNullOrEmpty(series.ImdbId))
                {
                    TvdbSearchResult foundSeries = _tvdbHandler.GetSeriesByRemoteId(ExternalId.ImdbId, series.ImdbId);
                    if (foundSeries != null)
                    {
                        seriesDetail = _tvdbHandler.GetSeries(foundSeries.Id, language, true, true, false);
                    }
                }
                if (seriesDetail == null)
                {
                    return(false);
                }

                series.TvdbId = seriesDetail.Id;
                series.ImdbId = seriesDetail.ImdbId;

                series.SeriesName    = new SimpleTitle(seriesDetail.SeriesName, false);
                series.FirstAired    = seriesDetail.FirstAired;
                series.Description   = new SimpleTitle(seriesDetail.Overview, false);
                series.Certification = seriesDetail.ContentRating;
                series.Rating        = new SimpleRating(seriesDetail.Rating, seriesDetail.RatingCount);
                series.Genres        = seriesDetail.Genre.Select(s => new GenreInfo {
                    Name = s
                }).ToList();
                series.Networks = ConvertToCompanies(seriesDetail.NetworkID, seriesDetail.Network, CompanyAspect.COMPANY_TV_NETWORK);
                if (seriesDetail.Status.IndexOf("Ended", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    series.IsEnded = true;
                }

                series.Actors     = ConvertToPersons(seriesDetail.TvdbActors, PersonAspect.OCCUPATION_ACTOR, null, seriesDetail.SeriesName);
                series.Characters = ConvertToCharacters(seriesDetail.TvdbActors, null, seriesDetail.SeriesName);

                foreach (TvdbActor actor in seriesDetail.TvdbActors)
                {
                    _seriesToActorMap.StoreMappedId(actor.Id.ToString(), seriesDetail.Id.ToString());
                }

                foreach (TvdbEpisode episodeDetail in seriesDetail.Episodes.OrderByDescending(e => e.Id))
                {
                    SeasonInfo seasonInfo = new SeasonInfo()
                    {
                        TvdbId = episodeDetail.SeasonId,

                        SeriesTvdbId = seriesDetail.Id,
                        SeriesImdbId = seriesDetail.ImdbId,
                        SeriesName   = new SimpleTitle(seriesDetail.SeriesName, false),
                        SeasonNumber = episodeDetail.SeasonNumber,
                    };
                    if (!series.Seasons.Contains(seasonInfo))
                    {
                        series.Seasons.Add(seasonInfo);
                    }

                    EpisodeInfo episodeInfo = new EpisodeInfo()
                    {
                        TvdbId = episodeDetail.Id,

                        SeriesTvdbId     = seriesDetail.Id,
                        SeriesImdbId     = seriesDetail.ImdbId,
                        SeriesName       = new SimpleTitle(seriesDetail.SeriesName, false),
                        SeriesFirstAired = seriesDetail.FirstAired,

                        ImdbId         = episodeDetail.ImdbId,
                        SeasonNumber   = episodeDetail.SeasonNumber,
                        EpisodeNumbers = new List <int>(new int[] { episodeDetail.EpisodeNumber }),
                        FirstAired     = episodeDetail.FirstAired,
                        EpisodeName    = new SimpleTitle(episodeDetail.EpisodeName, false),
                        Summary        = new SimpleTitle(episodeDetail.Overview, false),
                        Genres         = seriesDetail.Genre.Select(s => new GenreInfo {
                            Name = s
                        }).ToList(),
                        Rating = new SimpleRating(episodeDetail.Rating, episodeDetail.RatingCount),
                    };

                    if (episodeDetail.DvdEpisodeNumber > 0)
                    {
                        episodeInfo.DvdEpisodeNumbers = new List <double>(new double[] { episodeDetail.DvdEpisodeNumber });
                    }

                    episodeInfo.Actors = ConvertToPersons(seriesDetail.TvdbActors, PersonAspect.OCCUPATION_ACTOR, episodeDetail.EpisodeName, seriesDetail.SeriesName);
                    //info.Actors.AddRange(ConvertToPersons(episodeDetail.GuestStars, PersonAspect.OCCUPATION_ACTOR, info.Actors.Count));
                    episodeInfo.Characters = ConvertToCharacters(seriesDetail.TvdbActors, episodeDetail.EpisodeName, seriesDetail.SeriesName);
                    episodeInfo.Directors  = ConvertToPersons(episodeDetail.Directors, PersonAspect.OCCUPATION_DIRECTOR, 0, episodeDetail.EpisodeName, seriesDetail.SeriesName);
                    episodeInfo.Writers    = ConvertToPersons(episodeDetail.Writer, PersonAspect.OCCUPATION_WRITER, 0, episodeDetail.EpisodeName, seriesDetail.SeriesName);
                    episodeInfo.Languages.Add(episodeDetail.Language.Abbriviation);

                    if (!series.Episodes.Contains(episodeInfo))
                    {
                        series.Episodes.Add(episodeInfo);
                    }
                }
                series.Episodes.Sort();
                series.TotalEpisodes = series.Episodes.Count;

                for (int index = 0; index < series.Seasons.Count; index++)
                {
                    series.Seasons[index].FirstAired    = series.Episodes.Find(e => e.SeasonNumber == series.Seasons[index].SeasonNumber).FirstAired;
                    series.Seasons[index].TotalEpisodes = series.Episodes.FindAll(e => e.SeasonNumber == series.Seasons[index].SeasonNumber).Count;
                }
                series.Seasons.Sort();
                series.TotalSeasons = series.Seasons.Count;

                TvdbEpisode nextEpisode = seriesDetail.Episodes.Where(e => e.FirstAired > DateTime.Now).OrderBy(e => e.FirstAired)
                                          .ThenByDescending(p => p.Id).FirstOrDefault();
                if (nextEpisode != null)
                {
                    series.NextEpisodeName         = new SimpleTitle(nextEpisode.EpisodeName, false);
                    series.NextEpisodeAirDate      = nextEpisode.FirstAired;
                    series.NextEpisodeSeasonNumber = nextEpisode.SeasonNumber;
                    series.NextEpisodeNumber       = nextEpisode.EpisodeNumber;
                }

                return(true);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug("TvDbWrapper: Exception while processing series {0}", ex, series.ToString());
                return(false);
            }
        }