示例#1
0
 /// <summary>
 /// Updates all information of this episode from the given
 /// episode...
 /// </summary>
 /// <param name="_episode">new episode</param>
 internal void UpdateEpisodeInfo(TvdbEpisode _episode)
 {
     this.LastUpdated           = _episode.LastUpdated;
     this.Banner                = _episode.Banner;
     this.AbsoluteNumber        = _episode.AbsoluteNumber;
     this.CombinedEpisodeNumber = _episode.CombinedEpisodeNumber;
     this.CombinedSeason        = _episode.CombinedSeason;
     this.Directors             = _episode.Directors;
     this.DvdChapter            = _episode.DvdChapter;
     this.DvdDiscId             = _episode.DvdDiscId;
     this.DvdEpisodeNumber      = _episode.DvdEpisodeNumber;
     this.DvdSeason             = _episode.DvdSeason;
     this.EpisodeName           = _episode.EpisodeName;
     this.EpisodeNumber         = _episode.EpisodeNumber;
     this.FirstAired            = _episode.FirstAired;
     this.GuestStars            = _episode.GuestStars;
     this.ImdbId                = _episode.ImdbId;
     this.Language              = _episode.Language;
     this.Overview              = _episode.Overview;
     this.ProductionCode        = _episode.ProductionCode;
     this.Rating                = _episode.Rating;
     this.SeasonId              = _episode.SeasonId;
     this.SeasonNumber          = _episode.SeasonNumber;
     this.Writer                = _episode.Writer;
 }
示例#2
0
 /// <summary>
 /// Add the episode to the series
 /// </summary>
 /// <param name="_episode"></param>
 /// <param name="_series"></param>
 internal static void AddEpisodeToSeries(TvdbEpisode _episode, TvdbSeries _series)
 {
     bool episodeFound = false; ;
       for (int i = 0; i < _series.Episodes.Count; i++)
       {
     if (_series.Episodes[i].Id == _episode.Id)
     {//we have already stored this episode -> overwrite it
       _series.Episodes[i].UpdateEpisodeInfo(_episode);
       episodeFound = true;
       break;
     }
       }
       if (!episodeFound)
       {//the episode doesn't exist yet
     _series.Episodes.Add(_episode);
     if (!_series.EpisodesLoaded) _series.EpisodesLoaded = true;
       }
 }
示例#3
0
 /// <summary>
 /// Updates all information of this episode from the given
 /// episode...
 /// </summary>
 /// <param name="_episode">new episode</param>
 internal void UpdateEpisodeInfo(TvdbEpisode _episode)
 {
     this.LastUpdated = _episode.LastUpdated;
       this.Banner = _episode.Banner;
       this.AbsoluteNumber = _episode.AbsoluteNumber;
       this.CombinedEpisodeNumber = _episode.CombinedEpisodeNumber;
       this.CombinedSeason = _episode.CombinedSeason;
       this.Directors = _episode.Directors;
       this.DvdChapter = _episode.DvdChapter;
       this.DvdDiscId = _episode.DvdDiscId;
       this.DvdEpisodeNumber = _episode.DvdEpisodeNumber;
       this.DvdSeason = _episode.DvdSeason;
       this.EpisodeName = _episode.EpisodeName;
       this.EpisodeNumber = _episode.EpisodeNumber;
       this.FirstAired = _episode.FirstAired;
       this.GuestStars = _episode.GuestStars;
       this.ImdbId = _episode.ImdbId;
       this.Language = _episode.Language;
       this.Overview = _episode.Overview;
       this.ProductionCode = _episode.ProductionCode;
       this.Rating = _episode.Rating;
       this.SeasonId = _episode.SeasonId;
       this.SeasonNumber = _episode.SeasonNumber;
       this.Writer = _episode.Writer;
 }
示例#4
0
        /// <summary>
        /// Add this episode to the proper cached series
        /// </summary>
        /// <param name="_episode">Episode to add to cache</param>
        private void AddEpisodeToCache(TvdbEpisode _episode)
        {
            bool seriesFound = false;
              foreach (TvdbSeries s in m_loadedData.SeriesList)
              {
            if (s.Id == _episode.SeriesId)
            {//series for ep found
              seriesFound = true;
              Util.AddEpisodeToSeries(_episode, s);
              break;
            }

              }

              //todo: maybe skip this since downloading an episode is no biggie
              if (!seriesFound)
              {//the series doesn't exist yet -> add episode to dummy series
            TvdbSeries newSeries = new TvdbSeries();
            newSeries.LastUpdated = new DateTime(1, 1, 1);
            newSeries.Episodes.Add(_episode);
            m_loadedData.SeriesList.Add(newSeries);
              }
        }
示例#5
0
        /// <summary>
        /// Retrieve the episode with the given parameters
        /// </summary>
        /// <param name="_seriesId">id of the series</param>
        /// <param name="_seasonNr">season number of the episode</param>
        /// <param name="_episodeNr">number of the episode</param>
        /// <param name="_language">language of the episode</param>
        /// <param name="_order">The sorting order that should be user when downloading the episode</param>
        /// <returns>The retrieved episode</returns>
        public TvdbEpisode GetEpisode(int _seriesId, int _seasonNr, int _episodeNr,
            TvdbEpisode.EpisodeOrdering _order, TvdbLanguage _language)
        {
            String order = null;
              switch (_order)
              {
            case TvdbEpisode.EpisodeOrdering.AbsoluteOrder:
              order = "absolut";
              break;
            case TvdbEpisode.EpisodeOrdering.DefaultOrder:
              order = "default";
              break;
            case TvdbEpisode.EpisodeOrdering.DvdOrder:
              order = "dvd";
              break;
              }

              TvdbEpisode episode = m_downloader.DownloadEpisode(_seriesId, _seasonNr, _episodeNr, order, _language);
              return episode;
        }
示例#6
0
        /// <summary>
        /// Update the series with the episode (Add it to the series if it doesn't already exist or update the episode if the current episode is older than the updated one)
        /// </summary>
        /// <param name="s"></param>
        /// <param name="ue"></param>
        private void UpdateEpisode(TvdbSeries s, TvdbEpisode ue)
        {
            List<TvdbEpisode> allEpList = new List<TvdbEpisode>();
              allEpList.AddRange(s.Episodes);
              foreach (TvdbLanguage l in s.GetAvailableLanguages())
              {
            if (s.SeriesTranslations[l].Episodes != null && s.SeriesTranslations[l].Language != s.Language)
            {
              allEpList.AddRange(s.SeriesTranslations[l].Episodes);
            }
              }

              //check all episodes if the updated episode is in it
              foreach (TvdbEpisode e in allEpList)
              {
            if (e.Id == ue.Id)
            {
              if (e.LastUpdated < ue.LastUpdated)
              {
            //download episode which has been updated
            TvdbEpisode newEpisode = m_downloader.DownloadEpisode(e.Id, e.Language);

            //update information of episode with new episodes informations
            if (newEpisode != null)
            {
              newEpisode.LastUpdated = ue.LastUpdated;

              e.UpdateEpisodeInfo(newEpisode);
              Log.Info("Updated Episode " + e.Id + " for series " + e.SeriesId);
            }
              }
              return;
            }
              }

              //episode hasn't been found
              foreach (TvdbLanguage l in s.GetAvailableLanguages())
              {
            //hasn't been found -> add it
            TvdbEpisode ep = m_downloader.DownloadEpisode(ue.Id, l);
            AddEpisodeToCache(ep);
            Log.Info("Added Episode " + ep.Id + " for series " + ep.SeriesId);
              }
        }
示例#7
0
        /// <summary>
        /// Extract a list of episodes from the given data when the data has the following format:
        /// <![CDATA[
        ///  <?xml version="1.0" encoding="UTF-8" ?>
        ///  <Episode>
        ///      <id>332179</id>
        ///      <DVD_chapter></DVD_chapter>
        ///      <DVD_discid></DVD_discid>
        ///      <DVD_episodenumber></DVD_episodenumber>
        ///      <DVD_season></DVD_season>
        ///      <Director>|Joseph McGinty Nichol|</Director>
        ///      <EpisodeName>Chuck Versus the World</EpisodeName>
        ///      <EpisodeNumber>1</EpisodeNumber>
        ///      <FirstAired>2007-09-24</FirstAired>
        ///      <GuestStars>|Julia Ling|Vik Sahay|Mieko Hillman|</GuestStars>
        ///      <IMDB_ID></IMDB_ID>
        ///      <Language>English</Language>
        ///      <Overview>Chuck Bartowski is an average computer geek...</Overview>
        ///      <ProductionCode></ProductionCode>
        ///      <Rating>9.0</Rating>
        ///      <SeasonNumber>1</SeasonNumber>
        ///      <Writer>|Josh Schwartz|Chris Fedak|</Writer>
        ///      <absolute_number></absolute_number>
        ///      <airsafter_season></airsafter_season>
        ///      <airsbefore_episode></airsbefore_episode>
        ///      <airsbefore_season></airsbefore_season>
        ///      <filename>episodes/80348-332179.jpg</filename>
        ///      <lastupdated>1201292806</lastupdated>
        ///      <seasonid>27985</seasonid>
        ///      <seriesid>80348</seriesid>
        ///  </Episode>
        ///  ]]>
        /// </summary>
        /// <param name="_data"></param>
        /// <returns></returns>
        internal List<TvdbEpisode> ExtractEpisodes(String _data)
        {
            Stopwatch watch = new Stopwatch();
              watch.Start();
              XDocument xml = XDocument.Parse(_data);
              var allEpisodes = from episode in xml.Descendants("Episode")
                        select new
                        {
                          Id = episode.Element("id").Value,
                          Combined_episodenumber = episode.Element("Combined_episodenumber").Value,
                          Combined_season = episode.Element("Combined_season").Value,
                          DVD_chapter = episode.Element("DVD_chapter").Value,
                          DVD_discid = episode.Element("DVD_discid").Value,
                          DVD_episodenumber = episode.Element("DVD_episodenumber").Value,
                          DVD_season = episode.Elements("DVD_season").Count() == 1
                                       ? episode.Element("DVD_season").Value : episode.Element("DVD_Season").Value,
                          Director = episode.Element("Director").Value,
                          EpisodeName = episode.Element("EpisodeName").Value,
                          EpisodeNumber = episode.Element("EpisodeNumber").Value,
                          FirstAired = episode.Element("FirstAired").Value,
                          GuestStars = episode.Element("GuestStars").Value,
                          IMDB_ID = episode.Element("IMDB_ID").Value,
                          Language = episode.Elements("Language").Count() == 1
                                     ? episode.Element("Language").Value : "en",
                          Overview = episode.Element("Overview").Value,
                          ProductionCode = episode.Element("ProductionCode").Value,
                          Rating = episode.Element("Rating").Value,
                          SeasonNumber = episode.Element("SeasonNumber").Value,
                          Writer = episode.Element("Writer").Value,
                          absolute_number = episode.Element("absolute_number").Value,
                          filename = episode.Element("filename").Value,
                          lastupdated = episode.Element("lastupdated").Value,
                          seasonid = episode.Element("seasonid").Value,
                          seriesid = episode.Element("seriesid").Value,
                          airsafter_season = episode.Elements("airsafter_season").Count() == 1
                                           ? episode.Element("airsafter_season").Value : "-99",
                          airsbefore_episode = episode.Elements("airsbefore_episode").Count() == 1
                                             ? episode.Element("airsbefore_episode").Value : "-99",
                          airsbefore_season = episode.Elements("airsbefore_season").Count() == 1
                                            ? episode.Element("airsbefore_season").Value : "-99"
                        };
              Log.Debug("Parsed xml file in  " + watch.ElapsedMilliseconds + " milliseconds");
              List<TvdbEpisode> retList = new List<TvdbEpisode>();
              foreach (var e in allEpisodes)
              {
            TvdbEpisode ep = new TvdbEpisode();
            ep.Id = Util.Int32Parse(e.Id);
            ep.CombinedEpisodeNumber = Util.Int32Parse(e.Combined_episodenumber);
            ep.CombinedSeason = Util.Int32Parse(e.Combined_season);
            ep.DvdChapter = Util.Int32Parse(e.DVD_chapter);
            ep.DvdDiscId = Util.Int32Parse(e.DVD_discid);
            ep.DvdEpisodeNumber = Util.Int32Parse(e.DVD_episodenumber);
            ep.DvdSeason = Util.Int32Parse(e.DVD_season);
            ep.Directors = Util.SplitTvdbString(e.Director);
            ep.EpisodeName = e.EpisodeName;
            ep.EpisodeNumber = Util.Int32Parse(e.EpisodeNumber);
            ep.AirsAfterSeason = Util.Int32Parse(e.airsafter_season);
            ep.AirsBeforeEpisode = Util.Int32Parse(e.airsbefore_episode);
            ep.AirsBeforeSeason = Util.Int32Parse(e.airsbefore_season);
            try
            {
              ep.FirstAired = e.FirstAired.Equals("") ? new DateTime(1, 1, 1) : DateTime.Parse(e.FirstAired);
            }
            catch (Exception)
            {
              ep.FirstAired = new DateTime();
            }
            ep.GuestStars = Util.SplitTvdbString(e.GuestStars);
            ep.ImdbId = e.IMDB_ID;
            ep.Language = Util.ParseLanguage(e.Language);
            ep.Overview = e.Overview;
            ep.ProductionCode = e.ProductionCode;
            ep.Rating = Util.DoubleParse(e.Rating);
            ep.SeasonNumber = Util.Int32Parse(e.SeasonNumber);
            ep.Writer = Util.SplitTvdbString(e.Writer);
            ep.AbsoluteNumber = Util.Int32Parse(e.absolute_number);
            ep.BannerPath = e.filename;
            ep.Banner = ep.BannerPath.Equals("") ? null : new TvdbEpisodeBanner(ep.Id, ep.BannerPath);
            ep.LastUpdated = Util.UnixToDotNet(e.lastupdated);
            ep.SeasonId = Util.Int32Parse(e.seasonid);
            ep.SeriesId = Util.Int32Parse(e.seriesid);

            if (ep.Id != -99) retList.Add(ep);
              }

              watch.Stop();
              Log.Debug("Extracted " + retList.Count + " Episodes in " + watch.ElapsedMilliseconds + " milliseconds");
              return retList;
        }
示例#8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_epList"></param>
        private void AddEpisodeToCache(TvdbEpisode e)
        {
            bool seriesFound = false;
              foreach (TvdbSeries s in m_loadedData.SeriesList)
              {
            if (s.Id == e.SeriesId)
            {//series for ep found
              seriesFound = true;
              Util.AddEpisodeToSeries(e, s);
              break;
            }

              }
              if (!seriesFound)
              {//the series doesn't exist yet -> add episode to dummy series
            TvdbSeries newSeries = new TvdbSeries();
            newSeries.LastUpdated = new DateTime(1, 1, 1);
            newSeries.Episodes.Add(e);
            m_loadedData.SeriesList.Add(newSeries);
              }
        }
示例#9
0
        private void FillEpisodeDetail(TvdbEpisode _episode)
        {
            lbEpisodeInformation.Text = _episode.EpisodeName + "(" + _episode.EpisodeNumber + ")";
              txtEpisodeLanguage.Text = _episode.Language != null ? _episode.Language.ToString() : "";
              txtEpisodeFirstAired.Text = _episode.FirstAired.ToShortDateString();

              lbGuestStars.Items.Clear();
              foreach (String s in _episode.GuestStars)
              {
            lbGuestStars.Items.Add(s.Trim());
              }

              lbDirectors.Items.Clear();
              foreach (String s in _episode.Directors)
              {
            lbDirectors.Items.Add(s.Trim());
              }

              lbWriters.Items.Clear();
              foreach (String s in _episode.Writer)
              {
            lbWriters.Items.Add(s.Trim());
              }

              txtEpisodeProductionCode.Text = _episode.ProductionCode;
              txtEpisodeOverview.Text = _episode.Overview;
              txtEpisodeDVDId.Text = _episode.DvdDiscId != -99 ? _episode.DvdDiscId.ToString() : "";
              txtEpisodeDVDSeason.Text = _episode.DvdSeason != -99 ? _episode.DvdSeason.ToString() : "";
              txtEpisodeDVDNumber.Text = _episode.DvdEpisodeNumber != -99 ? _episode.DvdEpisodeNumber.ToString() : "";
              txtEpisodeDVDChapter.Text = _episode.DvdChapter != -99 ? _episode.DvdChapter.ToString() : "";
              txtEpisodeAbsoluteNumber.Text = _episode.AbsoluteNumber != -99 ? _episode.AbsoluteNumber.ToString() : "";
              txtImdbId.Text = _episode.ImdbId;
        }