Example #1
0
        private void LoadSeries(int _seriesId)
        {
            TvdbSeries series = null;

            try
            {
                series = m_tvdbHandler.GetSeries(_seriesId, m_currentLanguage, cbLoadFull.Checked,
                                                 cbLoadActors.Checked, cbLoadBanner.Checked, cbUseZipped.Checked);
            }
            catch (TvdbInvalidApiKeyException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (TvdbNotAvailableException ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (series != null)
            {
                CleanUpForm();
                tabControlTvdb.SelectedTab = tabSeries;
                UpdateSeries(series);
            }
        }
Example #2
0
        private void cmdLoadSeries_Click(object sender, EventArgs e)
        {
            TvdbSeries s = m_tvdbHandler.GetSeries(Int32.Parse(txtSeriesIdForBanners.Text), TvdbLanguage.DefaultLanguage, true, true, true, true);

            foreach (TvdbBanner b in s.SeriesBanners)
            {
                ListViewItem item = new ListViewItem(b.BannerPath);
                item.Tag = b;
                lvSeriesBanners.Items.Add(item);
            }
        }
Example #3
0
        public string getTitle(int seriesID, int season, int episode)
        {
            string newTitle = "";

            try
            {
                if (season > 100)
                {
                    TvdbEpisode e = m_tvdbHandler.GetEpisode(seriesID, new DateTime(episode, season / 100, season % 100), TvdbLanguage.DefaultLanguage);
                    newTitle = e.EpisodeName;
                }
                else
                {
                    int seasonScale  = season;
                    int episodeScale = episode;
                    using (var client = new WebClient())
                    {
                        var json = client.DownloadString(String.Format("http://thexem.de/map/all?id={0}&origin=tvdb", seriesID));

                        RootObject m = JsonConvert.DeserializeObject <RootObject>(json);

                        foreach (Datum showData in m.data)
                        {
                            if (showData.scene.episode == episode && showData.scene.season == season)
                            {
                                seasonScale  = showData.tvdb.season;
                                episodeScale = showData.tvdb.episode;
                                break;
                            }
                        }
                    }
                    //if (seasonScale == 0 && episodeScale == 0)
                    //	return "";

                    TvdbSeries s = m_tvdbHandler.GetSeries(seriesID, TvdbLanguage.DefaultLanguage, true, false, false);
                    foreach (TvdbEpisode esp in s.Episodes)
                    {
                        if (seasonScale == esp.SeasonNumber && episodeScale == esp.EpisodeNumber)
                        {
                            newTitle = esp.EpisodeName;
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }

            newTitle = newTitle.Replace(":", "").Replace("?", "").Replace("/", "").Replace("<", "").Replace(">", "").Replace("\\", "").Replace("*", "").Replace("|", "").Replace("\"", "");
            return(newTitle);
        }
Example #4
0
        private void cmdTest1_Click(object sender, EventArgs e)
        {
            TvdbSeries s = m_tvdbHandler.GetSeries(73255, TvdbLanguage.DefaultLanguage, true, true, true);

            if (s.TvdbActorsLoaded)
            {
                List <TvdbBanner> bannerList = new List <TvdbBanner>();
                foreach (TvdbActor a in s.TvdbActors)
                {
                    bannerList.Add(a.ActorImage);
                }
                bcActors.BannerImages = bannerList;
            }
        }
Example #5
0
        public Serie(TvdbHandler TvdbHandler, int SerieID)
        {
            _Serie        = TvdbHandler.GetSeries(SerieID, TvdbHandler.UserInfo.UserPreferredLanguage, true, true, true);
            _ListeSaisons = new List <Saison>();

            _ListeSaisons.Add(new Saison("Spécial"));

            for (int i = 1; i <= _Serie.NumSeasons; i++)
            {
                _ListeSaisons.Add(new Saison("Saison " + i.ToString()));
            }

            foreach (TvdbEpisode item in _Serie.Episodes)
            {
                Console.WriteLine(item.SeasonNumber.ToString());

                if (item.SeasonNumber < _ListeSaisons.Count)
                {
                    _ListeSaisons[item.SeasonNumber].ListeEpisodes.Add(item);
                }
                else
                {
                    Console.WriteLine(item.ToString());
                }
            }
            Console.WriteLine(_Serie.SeriesName + "Terminéé");
        }
        public string getTitle(int seriesID, int season, int episode)
        {
            string newTitle = null;

            //TvdbEpisode e;
            try
            {
                //if (season > 100) return"";
                if (season > 100)
                {
                    TvdbEpisode e = m_tvdbHandler.GetEpisode(seriesID, new DateTime(episode, season / 100, season % 100), TvdbLanguage.DefaultLanguage);
                    newTitle = e.EpisodeName;
                }
                else
                {
                    TvdbSeries s = m_tvdbHandler.GetSeries(seriesID, TvdbLanguage.DefaultLanguage, true, false, false);
                    foreach (TvdbEpisode esp in s.Episodes)
                    {
                        if (season == esp.SeasonNumber && episode == esp.EpisodeNumber)
                        {
                            newTitle = esp.EpisodeName;
                            break;
                        }
                    }
                }
                //TvdbSeries s = m_tvdbHandler.GetSeries(seriesID, TvdbLanguage.DefaultLanguage, true, false, false);
                ////List<string> epList = new List<string>();

                //foreach (TvdbEpisode esp in s.Episodes)
                //{
                //	if (season == esp.SeasonNumber && episode == esp.EpisodeNumber)
                //	{
                //		newTitle = esp.EpisodeName;
                //		break;
                //	}
                //}
                //newTitle = e.EpisodeName;
            }
            catch (Exception) { }

            if (newTitle == null)
            {
                return("");
            }
            newTitle = newTitle.Replace(":", "").Replace("?", "").Replace("/", "").Replace("<", "").Replace(">", "").Replace("\\", "").Replace("*", "").Replace("|", "").Replace("\"", "");
            return(newTitle);
        }
        private void cmdExample1_Click(object sender, EventArgs args)
        {
            int seriesId = Int32.Parse(txtSeriesId.Text);

            //retrieve series "e.g. 73255 (House M.D.)" with all available information (without using zipped downloading)
            TvdbSeries s = m_tvdbHandler.GetSeries(seriesId, TvdbLanguage.DefaultLanguage, true, true, true, false);

            if (s != null)
            {
                WriteToConsole("Series Description:");
                WriteToConsole("================");
                WriteToConsole("Series id: " + s.Id);
                WriteToConsole("Name: " + s.SeriesName);
                WriteToConsole("Overview: " + s.Overview);
                WriteToConsole("Day of Week: " + s.AirsDayOfWeek);
                WriteToConsole("Airs Time: " + s.AirsTime.ToShortTimeString());
                WriteToConsole("Banner Path: " + s.BannerPath);
                WriteToConsole("Content Rating: " + s.ContentRating);
                WriteToConsole("Fanart Path: " + s.FanartPath);
                WriteToConsole("First Aired: " + s.FirstAired.ToShortDateString());
                WriteToConsole("Genres: " + s.GenreString);
                WriteToConsole("Imdb: " + s.ImdbId);
                WriteToConsole("Rating: " + s.Rating);
                WriteToConsole("Runtime: " + s.Runtime);
                WriteToConsole("Status: " + s.Status);
                WriteToConsole("tv.com id: " + s.TvDotComId);
                WriteToConsole("Zap2itId id: " + s.Zap2itId);
                WriteToConsole("");

                WriteToConsole("Episodes for " + s.SeriesName + ":");
                WriteToConsole("=================");
                foreach (TvdbEpisode e in s.Episodes)
                {
                    WriteToConsole("Season " + e.SeasonNumber + " Episode " + e.EpisodeNumber + ": " + e.EpisodeName);
                }
                WriteToConsole("");

                WriteToConsole("Actors:");
                WriteToConsole("======");
                foreach (TvdbActor a in s.TvdbActors)
                {
                    WriteToConsole(a.Name + " as " + a.Role + " (" + a.ActorImage.BannerPath + ")");
                }

                WriteToConsole("Banner:");
                WriteToConsole("======");
                foreach (TvdbBanner b in s.Banners)
                {
                    WriteToConsole(b.Id + ": " + b.BannerPath);
                }
            }
            else
            {
                WriteToConsole("Couldn't find series");
            }
        }
Example #8
0
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem i in lvFavorites.SelectedItems)
     {
         int        seriesId = (int)i.Tag;
         TvdbSeries series   = m_tvdbHandler.GetSeries(seriesId, TvdbLanguage.DefaultLanguage, true, true, true);
         if (series != null)
         {
             m_loadedSeries.Add(seriesId, series);
             i.BackColor = Color.DarkSeaGreen;
         }
     }
 }
Example #9
0
 private void cmdLoadBannerTest_Click(object sender, EventArgs e)
 {
     m_selectedSeriesForBannerTesting = m_tvdbHandler.GetSeries(Int32.Parse(txtSeriesIdForBanners.Text), TvdbLanguage.DefaultLanguage, true, true, true, true);
     if (m_selectedSeriesForBannerTesting != null)
     {
         m_bannerTestingIndex    = 0;
         pbBannerTesting.Visible = true;
         pbBannerTesting.BringToFront();
         LoadBanner(m_bannerTestingIndex);
     }
     else
     {
         MessageBox.Show("Couldn't load series");
     }
 }
Example #10
0
        public virtual TvdbSeries GetSeries(int id, bool loadEpisodes, bool loadActors = false)
        {
            lock (_handler)
            {
                Logger.Debug("Fetching SeriesId'{0}' from tvdb", id);
                var result = _handler.GetSeries(id, TvdbLanguage.DefaultLanguage, loadEpisodes, loadActors, true, true);

                //Remove duplicated episodes
                var episodes = result.Episodes.OrderByDescending(e => e.FirstAired).ThenByDescending(e => e.EpisodeName)
                               .GroupBy(e => e.SeriesId.ToString("000000") + e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
                               .Select(e => e.First());

                result.Episodes = episodes.ToList();

                return(result);
            }
        }
Example #11
0
        private void GetTvDBInfo(string searchMedia, string selectedLang, string fallbackLang)
        {
            const string tvDBFanartPath = "http://thetvdb.com/banners/";

            InitLists();

            string regexSearch = AppSettings.TvDBParseString;

            regexSearch =
                regexSearch.Replace("%show%", @"(?<show>[\w\s]*)")
                .Replace("%season%", @"(?<season>[\d]*)")
                .Replace("%episode%", @"(?<episode>[\d]*)")
                .Replace("%episode_name%", @"(?<episodename>[\w\s]*)");

            Regex searchObj   = new Regex(regexSearch, RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
            Match matchResult = searchObj.Match(searchMedia);

            // check first if we can use the search string
            if (!matchResult.Success)
            {
                regexSearch = regexSearch.Replace(@"(?<episodename>[\w\s]*)", "").Trim().TrimEnd(new [] { '-' }).Trim();
                searchObj   = new Regex(regexSearch, RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
                matchResult = searchObj.Match(searchMedia);
                if (!matchResult.Success)
                {
                    return;
                }
            }

            TvdbLanguage dbLang = _tvDbclient.Languages.Single(language => language.Abbriviation == selectedLang) ??
                                  _tvDbclient.Languages.Single(language => language.Abbriviation == fallbackLang);

            List <TvdbSearchResult> searchResults = _tvDbclient.SearchSeries(matchResult.Groups["show"].Value, dbLang);

            if (searchResults == null)
            {
                return;
            }

            TvdbSearchResult resultShow = new TvdbSearchResult();

            if (searchResults.Count > 1)
            {
                DBMultipleSelection selectWindow = new DBMultipleSelection
                {
                    Owner             = this,
                    TvdbSearchResults = searchResults
                };
                if (selectWindow.ShowDialog() == true)
                {
                    resultShow = selectWindow.TvdbSelectionResult;
                }
            }
            else
            {
                resultShow = searchResults.Count > 0 ? searchResults.First() : null;
            }

            if (resultShow == null || resultShow.Id == 0)
            {
                return;
            }

            TvdbSeries series = _tvDbclient.GetSeries(resultShow.Id, dbLang, true, true, true, true);

            TvShowTitle.Text      = series.SeriesName;
            TvShowGenre.Text      = string.Join(" / ", series.Genre);
            TvShowRating.Text     = series.Rating.ToString("g", AppSettings.CInfo);
            TvShowRuntime.Text    = series.Runtime.ToString("g", AppSettings.CInfo);
            TvShowFirstAired.Text = series.FirstAired.ToString("yyyy-MM-dd");
            TvShowPlot.Text       = series.Overview;
            TvShowMpaaRating.Text = series.ContentRating;
            TvShowImdbId.Text     = series.ImdbId;
            TvShowNetwork.Text    = series.Network;

            foreach (TvdbEpisode episode in series.Episodes)
            {
                DBTvShowSeason season;
                try
                {
                    season = _seasonList.First(showSeason => showSeason.SeasonNumber == episode.SeasonNumber);
                }
                catch (InvalidOperationException)
                {
                    season = new DBTvShowSeason
                    {
                        SeasonNumber = episode.SeasonNumber,
                        Title        = episode.IsSpecial ? "Special" : "Season " + episode.SeasonNumber
                    };
                    _seasonList.Add(season);
                }

                season.Episodes.Add(new DBTvShowEpisode
                {
                    Directors             = episode.Directors,
                    Writers               = episode.Writer,
                    SeasonNumber          = episode.SeasonNumber,
                    Runtime               = (int)series.Runtime,
                    Rating                = episode.Rating,
                    Plot                  = episode.Overview,
                    IsSpecial             = episode.IsSpecial,
                    ImdbId                = episode.ImdbId,
                    GuestStars            = episode.GuestStars,
                    FirstAired            = episode.FirstAired,
                    EpisodeTitle          = episode.EpisodeName,
                    EpisodeNumber         = episode.EpisodeNumber,
                    DvdEpisodeNumber      = episode.DvdEpisodeNumber,
                    CombinedEpisodeNumber = episode.CombinedEpisodeNumber,
                    AbsoluteEpisodeNumber = episode.AbsoluteNumber,
                    EpisodeImageUrl       = tvDBFanartPath + episode.BannerPath,
                });
            }

            TvShowSeason.ItemsSource = _seasonList;

            int tempInt;

            int.TryParse(matchResult.Groups["season"].Value, NumberStyles.Integer, AppSettings.CInfo, out tempInt);
            TvShowSeason.SelectedIndex = _seasonList.ToList().FindIndex(season => season.SeasonNumber == tempInt);

            int.TryParse(matchResult.Groups["episode"].Value, NumberStyles.Integer, AppSettings.CInfo, out tempInt);
            TvShowEpisodeNumber.SelectedIndex =
                ((List <DBTvShowEpisode>)TvShowEpisodeNumber.Items.SourceCollection).FindIndex(
                    episode => episode.EpisodeNumber == tempInt);

            int imageCounter = 1;

            foreach (TvdbSeriesBanner banner in series.SeriesBanners)
            {
                _bannerList.Add(new MovieDBBannerImage
                {
                    UrlOriginal = tvDBFanartPath + banner.BannerPath,
                    UrlPreview  =
                        tvDBFanartPath + (!string.IsNullOrEmpty(banner.ThumbPath)
                                                  ? banner.ThumbPath
                                                  : "_cache/" + banner.BannerPath),
                    Title = "Online image " + imageCounter
                });
                imageCounter++;
            }
            foreach (TvdbSeasonBanner banner in series.SeasonBanners)
            {
                _seasonBannerList.Add(new MovieDBSeasonBannerImage
                {
                    UrlOriginal = tvDBFanartPath + banner.BannerPath,
                    UrlPreview  =
                        tvDBFanartPath + (!string.IsNullOrEmpty(banner.ThumbPath)
                                                  ? banner.ThumbPath
                                                  : "_cache/" + banner.BannerPath),
                    Title  = "Online image " + imageCounter,
                    Season = banner.Season
                });
                imageCounter++;
            }
            _bannerList.ToList().ForEach(image => _previewBannerList.Add(image));
            _seasonBannerList.ToList().ForEach(image => _previewBannerList.Add(image));

            imageCounter = 1;
            foreach (TvdbFanartBanner banner in series.FanartBanners)
            {
                _backdropsList.Add(new MovieDBImageInfo
                {
                    Title       = "Online image " + imageCounter,
                    UrlOriginal = tvDBFanartPath + banner.BannerPath,
                    UrlPreview  =
                        tvDBFanartPath + (!string.IsNullOrEmpty(banner.ThumbPath)
                                                  ? banner.ThumbPath
                                                  : "_cache/" + banner.BannerPath)
                });
                imageCounter++;
            }

            imageCounter = 1;
            foreach (TvdbPosterBanner banner in series.PosterBanners)
            {
                _postersList.Add(new MovieDBPosterImage
                {
                    Title       = "Online image " + imageCounter,
                    UrlOriginal = tvDBFanartPath + banner.BannerPath,
                    UrlPreview  =
                        tvDBFanartPath + (!string.IsNullOrEmpty(banner.ThumbPath)
                                                  ? banner.ThumbPath
                                                  : "_cache/" + banner.BannerPath)
                });
                imageCounter++;
            }
            TvShowBannerList.ItemsSource   = _previewBannerList;
            TvShowBannerList.SelectedValue = tvDBFanartPath + "_cache/" + series.BannerPath;

            TvShowFanartList.ItemsSource   = _backdropsList;
            TvShowFanartList.SelectedValue = tvDBFanartPath + "_cache/" + series.FanartPath;

            TvShowPosterList.ItemsSource   = _postersList;
            TvShowPosterList.SelectedValue = tvDBFanartPath + "_cache/" + series.PosterPath;

            foreach (TvdbActor actor in series.TvdbActors)
            {
                _castList.Casts.Add(new MovieDBCast
                {
                    Name      = actor.Name,
                    Role      = actor.Role,
                    Thumbnail =
                        actor.ActorImage != null && !string.IsNullOrEmpty(actor.ActorImage.BannerPath)
                                ? tvDBFanartPath + actor.ActorImage.BannerPath
                                : string.Empty
                });
            }
            TvShowCastList.ItemsSource = _castList.Casts;

            ResultTabControl.SelectedIndex = 2;
        }
Example #12
0
 /// <summary>
 /// Gets Series information from TvDB. Results will be added automatically to cache.
 /// </summary>
 /// <param name="seriesId">TvDB ID of series</param>
 /// <param name="loadEpisodes"><c>true</c> to load episodes</param>
 /// <param name="series">Returns the Series information</param>
 /// <returns><c>true</c> if successful</returns>
 public bool GetSeries(int seriesId, bool loadEpisodes, out TvdbSeries series)
 {
     series = _tvdbHandler.GetSeries(seriesId, PreferredLanguage, loadEpisodes, false, false);
     return(series != null);
 }
        public override bool SearchSeriesEpisode(EpisodeInfo episodeSearch, TvdbLanguage language, out List <EpisodeInfo> episodes)
        {
            language = language ?? PreferredLanguage;

            episodes = null;
            SeriesInfo seriesSearch = episodeSearch.CloneBasicInstance <SeriesInfo>();

            if (episodeSearch.SeriesTvdbId <= 0)
            {
                if (!SearchSeriesUniqueAndUpdate(seriesSearch, language))
                {
                    return(false);
                }
                episodeSearch.CopyIdsFrom(seriesSearch);
            }

            if (episodeSearch.SeriesTvdbId > 0 && episodeSearch.SeasonNumber.HasValue)
            {
                TvdbSeries seriesDetail = _tvdbHandler.GetSeries(episodeSearch.SeriesTvdbId, language, true, false, false);

                foreach (TvdbEpisode episode in seriesDetail.Episodes.OrderByDescending(e => e.Id))
                {
                    if ((episodeSearch.EpisodeNumbers.Contains(episode.EpisodeNumber) || episodeSearch.EpisodeNumbers.Count == 0) &&
                        (episodeSearch.SeasonNumber == episode.SeasonNumber || episodeSearch.SeasonNumber.HasValue == false))
                    {
                        if (episodes == null)
                        {
                            episodes = new List <EpisodeInfo>();
                        }

                        EpisodeInfo info = new EpisodeInfo
                        {
                            TvdbId       = episode.Id,
                            SeriesName   = new SimpleTitle(seriesDetail.SeriesName, false),
                            SeasonNumber = episode.SeasonNumber,
                            EpisodeName  = new SimpleTitle(episode.EpisodeName, false),
                        };
                        info.EpisodeNumbers.Add(episode.EpisodeNumber);
                        info.CopyIdsFrom(seriesSearch);
                        info.Languages.Add(episode.Language.Abbriviation);
                        if (!episodes.Contains(info))
                        {
                            episodes.Add(info);
                        }
                    }
                }
                if (episodes != null)
                {
                    episodes.Sort();
                }
            }

            if (episodes == null)
            {
                episodes = new List <EpisodeInfo>();
                EpisodeInfo info = new EpisodeInfo
                {
                    SeriesName   = seriesSearch.SeriesName,
                    SeasonNumber = episodeSearch.SeasonNumber,
                    EpisodeName  = episodeSearch.EpisodeName,
                };
                info.CopyIdsFrom(seriesSearch);
                CollectionUtils.AddAll(info.EpisodeNumbers, episodeSearch.EpisodeNumbers);
                info.Languages = seriesSearch.Languages;
                episodes.Add(info);
                return(true);
            }

            return(episodes != null);
        }