/// <summary> /// Updates all information of this episode from the given /// episode... /// </summary> /// <param name="episode">new episode</param> internal void UpdateEpisodeInfo(TvdbEpisode episode) { LastUpdated = episode.LastUpdated; BannerPath = episode.BannerPath; Banner = episode.Banner; AbsoluteNumber = episode.AbsoluteNumber; CombinedEpisodeNumber = episode.CombinedEpisodeNumber; CombinedSeason = episode.CombinedSeason; Directors = episode.Directors; DvdChapter = episode.DvdChapter; DvdDiscId = episode.DvdDiscId; DvdEpisodeNumber = episode.DvdEpisodeNumber; DvdSeason = episode.DvdSeason; EpisodeName = episode.EpisodeName; EpisodeNumber = episode.EpisodeNumber; FirstAired = episode.FirstAired; GuestStars = episode.GuestStars; ImdbId = episode.ImdbId; Language = episode.Language; Overview = episode.Overview; ProductionCode = episode.ProductionCode; Rating = episode.Rating; SeasonId = episode.SeasonId; SeasonNumber = episode.SeasonNumber; Writer = episode.Writer; }
/// <summary> /// Make the update /// </summary> /// <param name="interval">interval of update</param> /// <param name="zipped">zipped downloading yes/no</param> /// <param name="reloadOldContent"> </param> /// <returns>true if successful, false otherwise</returns> private bool MakeUpdate(Interval interval, bool zipped, bool reloadOldContent) { Log.Info("Started update (" + interval + ")"); Stopwatch watch = new Stopwatch(); watch.Start(); DateTime startUpdate = DateTime.Now; if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.Downloading, "Downloading " + (zipped ? " zipped " : " unzipped") + " updated content (" + interval.ToString() + ")", 0, 0)); } //update all flagged series List<TvdbSeries> updateSeries; List<TvdbEpisode> updateEpisodes; List<TvdbBanner> updateBanners; List<int> updatedSeriesIds = new List<int>(); List<int> updatedEpisodeIds = new List<int>(); List<int> updatedBannerIds = new List<int>(); DateTime updateTime = _downloader.DownloadUpdate(out updateSeries, out updateEpisodes, out updateBanners, interval, zipped); List<int> cachedSeries = _cacheProvider.GetCachedSeries(); //list of all series that have been loaded from cache //and need to be saved to cache at the end of the update Dictionary<int, TvdbSeries> seriesToSave = new Dictionary<int, TvdbSeries>(); if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.SeriesUpdate, "Begin updating series", 0, 25)); } int countUpdatedSeries = updateSeries.Count; int countSeriesDone = 0; int lastProgress = 0;//send progress event at least every 1 percent String updateText = "Updating series"; if (reloadOldContent) { //if the last time an item (series or episode) was updated is longer ago than the timespan //we downloaded updates for, it's neccessary to completely reload the object to ensure that //the data is up to date. DateTime lastupdated = GetLastUpdate(); TimeSpan span = new TimeSpan(); switch (interval) { case Interval.Day: span = span.Add(new TimeSpan(1, 0, 0, 0)); break; case Interval.Week: span = span.Add(new TimeSpan(7, 0, 0, 0)); break; case Interval.Month: span = span.Add(new TimeSpan(30, 0, 0, 0)); break; } if (lastupdated < DateTime.Now - span) {//the last update of the cache is longer ago than the timespan we make the update for List<int> allSeriesIds = _cacheProvider.GetCachedSeries(); foreach (int s in allSeriesIds) { //TvdbSeries series = _cacheProvider.LoadSeriesFromCache(s); TvdbSeries series = seriesToSave.ContainsKey(s) ? seriesToSave[s] : _cacheProvider.LoadSeriesFromCache(s); //ForceReload(series, false); if (series.LastUpdated > DateTime.Now - span) { //the series object is up to date, but some episodes might not be foreach (TvdbEpisode e in series.Episodes) { if (e.LastUpdated < DateTime.Now - span) { if (TvDbUtils.FindEpisodeInList(e.Id, updateEpisodes) == null) {//The episode is not in the updates.xml file TvdbEpisode newEp = new TvdbEpisode(); newEp.Id = e.Id; newEp.LastUpdated = DateTime.Now; updateEpisodes.Add(newEp); } if (!seriesToSave.ContainsKey(series.Id)) seriesToSave.Add(series.Id, series); } } } else {//the series hasn't been updated recently -> we need to do a complete re-download ForceReload(series, false);//redownload series and save it to cache countUpdatedSeries++; countSeriesDone++; int currProg = (int)(100.0 / countUpdatedSeries * countSeriesDone); updatedSeriesIds.Add(series.Id); updateText = "Reloaded series " + series.SeriesName + "(" + series.Id + ")"; if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.SeriesUpdate, updateText, currProg, 25 + currProg / 4)); } //if (!seriesToSave.ContainsKey(series.Id)) seriesToSave.Add(series.Id, series); } } } } foreach (TvdbSeries us in updateSeries) { if (_abortUpdate) break;//the update has been aborted //Update series that have been already cached foreach (int s in cachedSeries) { if (us.Id == s) {//changes occured in series TvdbSeries series; series = seriesToSave.ContainsKey(s) ? seriesToSave[s] : _cacheProvider.LoadSeriesFromCache(s); int currProg = (int)(100.0 / countUpdatedSeries * countSeriesDone); bool updated = UpdateSeries(series, us.LastUpdated, currProg); if (updated) {//the series has been updated updatedSeriesIds.Add(us.Id); updateText = "Updated series " + series.SeriesName + "(" + series.Id + ")"; //store the updated series to cache if (!seriesToSave.ContainsKey(series.Id)) seriesToSave.Add(series.Id, series); } if (updated || currProg > lastProgress) {//the series has been updated OR the last event was fired at least one percent ago if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.SeriesUpdate, updateText, currProg, 25 + currProg / 4)); } lastProgress = currProg; } break; } } countSeriesDone++; } int countEpisodeUpdates = updateEpisodes.Count; int countEpisodesDone = 0; lastProgress = 0; updateText = "Updating episodes"; //update all flagged episodes foreach (TvdbEpisode ue in updateEpisodes) { if (_abortUpdate) break;//the update has been aborted foreach (int s in cachedSeries) { if (ue.SeriesId == s) {//changes occured in series TvdbSeries series; series = seriesToSave.ContainsKey(s) ? seriesToSave[s] : _cacheProvider.LoadSeriesFromCache(ue.SeriesId); int progress = (int)(100.0 / countEpisodeUpdates * countEpisodesDone); String text = ""; bool updated = UpdateEpisode(series, ue, progress, out text); if (updated) {//The episode was updated or added updatedEpisodeIds.Add(ue.Id); if (!seriesToSave.ContainsKey(series.Id)) seriesToSave.Add(series.Id, series); updateText = text; } if (updated || progress > lastProgress) { if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.EpisodesUpdate, updateText, progress, 50 + progress / 4)); } } break; } } countEpisodesDone++; } int countUpdatedBanner = updateBanners.Count; int countBannerDone = 0; lastProgress = 0; // todo: update banner information here -> wait for forum response regarding // missing banner id within updates (atm. I'm matching banners via path) foreach (TvdbBanner b in updateBanners) { if (_abortUpdate) break;//the update has been aborted foreach (int s in cachedSeries) { if (b.SeriesId == s) {//banner for this series has changed int currProg = (int)(100.0 / countUpdatedBanner * countBannerDone); TvdbSeries series = seriesToSave.ContainsKey(s) ? seriesToSave[s] : _cacheProvider.LoadSeriesFromCache(b.SeriesId); bool updated = UpdateBanner(series, b); if (updated) { updatedBannerIds.Add(b.Id); if (!seriesToSave.ContainsKey(series.Id)) seriesToSave.Add(series.Id, series); } if (updated || currProg > lastProgress) { if (UpdateProgressed != null) {//update has started, we're downloading the updated content from tvdb UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.BannerUpdate, "Updating banner " + b.BannerPath + "(id=" + b.Id + ")", currProg, 75 + currProg / 4)); } } break; } } countBannerDone++; } if (!_abortUpdate) {//update has finished successfully if (UpdateProgressed != null) { UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.FinishUpdate, "Update finished, saving loaded information to cache", 100, 100)); } } else {//the update has been aborted if (UpdateProgressed != null) { UpdateProgressed(new UpdateProgressEventArgs(UpdateProgressEventArgs.UpdateStage.FinishUpdate, "Update aborted by user, " + (_abortUpdateSaveChanges ? " saving " : " not saving ") + "already loaded information to cache", 100, 100)); } } if (!_abortUpdate || _abortUpdateSaveChanges) {//store the information we downloaded to cache Log.Info("Saving all series to cache that have been modified during the update (" + seriesToSave.Count + ")"); foreach (KeyValuePair<int, TvdbSeries> kvp in seriesToSave) {//Save all series to cache that have been modified during the update try { _cacheProvider.SaveToCache(kvp.Value); } catch (Exception ex) { Log.Warn("Couldn't save " + kvp.Key + " to cache: " + ex); } } } if (!_abortUpdate) {//update finished and wasn't aborted //set the last updated time to time of this update _loadedData.LastUpdated = updateTime; _cacheProvider.SaveToCache(_loadedData); } watch.Stop(); Log.Info("Finished update (" + interval + ") in " + watch.ElapsedMilliseconds + " milliseconds"); if (UpdateFinished != null) { if (!_abortUpdate || _abortUpdateSaveChanges) {//we either updated everything successfully or we at least saved the changes made before the update completed UpdateFinished(new UpdateFinishedEventArgs(startUpdate, DateTime.Now, updatedSeriesIds, updatedEpisodeIds, updatedBannerIds)); } else {//we didn't update anything because the update was aborted UpdateFinished(new UpdateFinishedEventArgs(startUpdate, DateTime.Now, new List<int>(), new List<int>(), new List<int>())); } } return true; }
/// <summary> /// Retrieve the episode with the given parameters. This function will find /// episodes that are already cached. /// </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> /// <exception cref="TvdbInvalidXmlException"><para>Exception is thrown when there was an error parsing the xml files. </para> /// <para>Feel free to post a detailed description of this issue on http://code.google.com/p/tvdblib /// or http://forums.thetvdb.com/</para></exception> /// <exception cref="TvdbContentNotFoundException">The episode/series/banner couldn't be located on the tvdb server.</exception> /// <exception cref="TvdbNotAvailableException">Exception is thrown when thetvdb isn't available.</exception> public TvdbEpisode GetEpisode(int seriesId, int seasonNr, int episodeNr, TvdbEpisode.EpisodeOrdering order, TvdbLanguage language) { TvdbEpisode episode = null; if (_cacheProvider != null && _cacheProvider.Initialised) { if (_cacheProvider.IsCached(seriesId, language, true, false, false)) { TvdbSeries series = _cacheProvider.LoadSeriesFromCache(seriesId); if (series.Language != language) { series.SetLanguage(language); } if (series.Episodes != null) { foreach (TvdbEpisode e in series.Episodes) { if (e.EpisodeNumber == episodeNr && e.SeasonNumber == seasonNr && order == TvdbEpisode.EpisodeOrdering.DefaultOrder || e.DvdEpisodeNumber == episodeNr && e.SeasonNumber == seasonNr && order == TvdbEpisode.EpisodeOrdering.DvdOrder || e.AbsoluteNumber == episodeNr && order == TvdbEpisode.EpisodeOrdering.AbsoluteOrder) {//We found the episode that matches the episode number according to the given ordering episode = e; break; } } } } } return episode ?? _downloader.DownloadEpisode(seriesId, seasonNr, episodeNr, order, language); }
/// <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="series">Series of the updating episode</param> /// <param name="episode">Episode that is updated</param> /// <param name="progress">Progress of the update run</param> /// <param name="text">Description of the current update</param> /// <returns>true if episode has been updated, false if not (e.g. timestamp of updated episode older than /// timestamp of existing episode</returns> private bool UpdateEpisode(TvdbSeries series, TvdbEpisode episode, int progress, out String text) { bool updateDone = false; text = ""; TvdbLanguage currentLanguage = series.Language; foreach (KeyValuePair<TvdbLanguage, TvdbSeriesFields> kvp in series.SeriesTranslations) { if (series.EpisodesLoaded) { bool found = false; List<TvdbEpisode> eps = kvp.Value.Episodes; if (eps != null && eps.Count > 0) { //check all episodes if the updated episode is in it foreach (TvdbEpisode e in eps.Where(e => e.Id == episode.Id)) { found = true; if (e.LastUpdated < episode.LastUpdated) { //download episode which has been updated TvdbEpisode newEpisode = null; try { newEpisode = _downloader.DownloadEpisode(e.Id, kvp.Key); } catch (TvdbContentNotFoundException) { Log.Warn("Couldn't download episode " + e.Id + "(" + e.EpisodeName + ")"); } //update information of episode with new episodes informations if (newEpisode != null) { newEpisode.LastUpdated = episode.LastUpdated; #region fix for http://forums.thetvdb.com/viewtopic.php?f=8&t=3993 //xml of single episodes doesn't contain CombinedSeason and CombinedEpisodeNumber, so if //we have values for those, don't override them //-> http://forums.thetvdb.com/viewtopic.php?f=8&t=3993 //todo: remove this once tvdb fixed that issue if (e.CombinedSeason != Util.NO_VALUE && newEpisode.CombinedSeason == 0) { newEpisode.CombinedSeason = e.CombinedSeason; } if (e.CombinedEpisodeNumber != Util.NO_VALUE && newEpisode.CombinedEpisodeNumber == 0) { newEpisode.CombinedEpisodeNumber = e.CombinedEpisodeNumber; } #endregion e.UpdateEpisodeInfo(newEpisode); e.Banner.CacheProvider = _cacheProvider; e.Banner.SeriesId = series.Id; e.Banner.UnloadBanner(false); e.Banner.UnloadThumb(false); text = "Added/Updated episode " + series.SeriesName + " " + e.SeasonNumber + "x" + e.EpisodeNumber + "(id: " + e.Id + ")"; Log.Info("Updated Episode " + e.SeasonNumber + "x" + e.EpisodeNumber + " for series " + series.SeriesName + "(id: " + e.Id + ", lang: " + e.Language.Abbriviation + ")"); updateDone = true; } } break; } } if (!found) { //episode hasn't been found //hasn't been found -> add it to series TvdbEpisode ep = null; try { ep = _downloader.DownloadEpisode(episode.Id, kvp.Key); } catch (TvdbContentNotFoundException ex) { Log.Warn("Problem downloading " + episode.Id + ": " + ex); } if (ep != null) { kvp.Value.Episodes.Add(ep); //sort the episodes according to default (aired) order kvp.Value.Episodes.Sort(new EpisodeComparerAired()); text = "Added/Updated episode " + series.SeriesName + " " + ep.SeasonNumber + "x" + ep.EpisodeNumber + "(id: " + ep.Id + ")"; Log.Info("Added Episode " + ep.SeasonNumber + "x" + ep.EpisodeNumber + " for series " + series.SeriesName + "(id: " + ep.Id + ", lang: " + ep.Language.Abbriviation + ")"); updateDone = true; } } } else { Log.Debug("Not handling episode " + episode.Id + ", because series " + series.SeriesName + " hasn't loaded episodes"); updateDone = false; } } series.SetLanguage(currentLanguage); return updateDone; }
/// <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; } }
/// <summary> /// <para>Gets the episodes for the given Season in the given order (aired or dvd). Absolute is also possible but makes no sense since /// there are no seasons with absoulte ordering. Use GetEpisodesAbsoluteOrder() instead.</para> /// /// <para>For more information on episode ordering <see href="http://thetvdb.com/wiki/index.php/Category:Episodes">thetvdb wiki</see></para> /// </summary> /// <returns>List of episodes</returns> public List<TvdbEpisode> GetEpisodes(int season, TvdbEpisode.EpisodeOrdering order) { List<TvdbEpisode> episodes = new List<TvdbEpisode>(); _episodes.ForEach(delegate(TvdbEpisode e) { if (e.SeasonNumber == season) episodes.Add(e); }); switch (order) { case TvdbEpisode.EpisodeOrdering.DefaultOrder: episodes.Sort(new EpisodeComparerAired()); break; case TvdbEpisode.EpisodeOrdering.DvdOrder: episodes.Sort(new EpisodeComparerDvd()); break; case TvdbEpisode.EpisodeOrdering.AbsoluteOrder: episodes.Sort(new EpisodeComparerAbsolute()); break; } return episodes; }
/// <summary> /// <para>Download the episode (specified by series id, Season number, episode number, language and episode order) from http://thetvdb.com.</para> /// <para>It is possible to retrieve episodes by aired order (aka default order), DVD order and absolute order. For a detailled description of these /// options see: http://thetvdb.com/wiki/index.php/Category:Episodes</para> /// </summary> /// <param name="seriesId">series id</param> /// <param name="seasonNr">Season nr</param> /// <param name="episodeNr">episode nr</param> /// <param name="language">language</param> /// <param name="order">order</param> /// <returns>The episode object or null if the episode could't be found</returns> /// <exception cref="TvdbInvalidXmlException"><para>Exception is thrown when there was an error parsing the xml files. </para> /// <para>Feel free to post a detailed description of this issue on http://code.google.com/p/tvdblib /// or http://forums.thetvdb.com/</para></exception> /// <exception cref="TvdbContentNotFoundException">The episode/series/banner couldn't be located on the tvdb server.</exception> /// <exception cref="TvdbNotAvailableException">Exception is thrown when thetvdb isn't available.</exception> public TvdbEpisode DownloadEpisode(int seriesId, int seasonNr, int episodeNr, TvdbEpisode.EpisodeOrdering order, TvdbLanguage language) { String xml = ""; String link = ""; String orderString = null; switch (order) { case TvdbEpisode.EpisodeOrdering.AbsoluteOrder: orderString = "absolute"; break; case TvdbEpisode.EpisodeOrdering.DefaultOrder: orderString = "default"; break; case TvdbEpisode.EpisodeOrdering.DvdOrder: orderString = "dvd"; break; } try { link = TvdbLinkCreator.CreateEpisodeLink(_apiKey, seriesId, seasonNr, episodeNr, orderString, language); xml = DownloadString(link); List<TvdbEpisode> epList = _xmlHandler.ExtractEpisodes(xml); return epList != null && epList.Count == 1 ? epList[0] : null; } catch (XmlException ex) { Log.Error("Error parsing the xml file " + link + "\n\n" + xml, ex); throw new TvdbInvalidXmlException("Error parsing the xml file " + link + "\n\n" + xml); } catch (WebException ex) { throw HandleContentWebException( string.Format("Couldn't download episode {0}/{1}/{2}/{3}/{4}, maybe the episode or the ordering doesn't exist", seriesId, order, seasonNr, episodeNr, language.Abbriviation), ex); } }
/// <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.Elements("Combined_episodenumber").Count() == 1 ? episode.Element("Combined_episodenumber").Value : "0", Combined_season = episode.Elements("Combined_season").Count() == 1 ? episode.Element("Combined_season").Value : "0", 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 : Util.NO_VALUE.ToString(), airsbefore_episode = episode.Elements("airsbefore_episode").Count() == 1 ? episode.Element("airsbefore_episode").Value : Util.NO_VALUE.ToString(), airsbefore_season = episode.Elements("airsbefore_season").Count() == 1 ? episode.Element("airsbefore_season").Value : Util.NO_VALUE.ToString() }; //Log.Debug("Parsed xml file in " + watch.ElapsedMilliseconds + " milliseconds"); List<TvdbEpisode> retList = new List<TvdbEpisode>(); foreach (var e in allEpisodes) { int id = Util.Int32Parse(e.Id); if (id == Util.NO_VALUE) continue; TvdbEpisode ep = new TvdbEpisode { Id = id, CombinedEpisodeNumber = Util.DoubleParse(e.Combined_episodenumber), CombinedSeason = Util.DoubleParse(e.Combined_season), DvdChapter = Util.Int32Parse(e.DVD_chapter), DvdDiscId = Util.Int32Parse(e.DVD_discid), DvdEpisodeNumber = Util.DoubleParse(e.DVD_episodenumber), DvdSeason = Util.Int32Parse(e.DVD_season), Directors = Util.SplitTvdbString(e.Director), EpisodeName = e.EpisodeName, EpisodeNumber = Util.Int32Parse(e.EpisodeNumber), AirsAfterSeason = Util.Int32Parse(e.airsafter_season), AirsBeforeEpisode = Util.Int32Parse(e.airsbefore_episode), AirsBeforeSeason = Util.Int32Parse(e.airsbefore_season), GuestStars = Util.SplitTvdbString(e.GuestStars), ImdbId = e.IMDB_ID, Language = TvDbUtils.ParseLanguage(e.Language), Overview = e.Overview, ProductionCode = e.ProductionCode, Rating = Util.DoubleParse(e.Rating), SeasonNumber = Util.Int32Parse(e.SeasonNumber), Writer = Util.SplitTvdbString(e.Writer), AbsoluteNumber = Util.Int32Parse(e.absolute_number), BannerPath = e.filename, LastUpdated = Util.UnixToDotNet(e.lastupdated), SeasonId = Util.Int32Parse(e.seasonid), SeriesId = Util.Int32Parse(e.seriesid), Banner = new TvdbEpisodeBanner(id, e.filename) }; DateTime firstAired; ep.FirstAired = DateTime.TryParse(e.FirstAired, out firstAired) ? firstAired : DateTime.MinValue; retList.Add(ep); } //watch.Stop(); //Log.Debug("Extracted " + retList.Count + " Episodes in " + watch.ElapsedMilliseconds + " milliseconds"); return retList; }
/// <summary> /// Updates all information of this episode from the given /// episode... /// </summary> /// <param name="episode">new episode</param> internal void UpdateEpisodeInfo(TvdbEpisode episode) { LastUpdated = episode.LastUpdated; BannerPath = episode.BannerPath; Banner = episode.Banner; AbsoluteNumber = episode.AbsoluteNumber; CombinedEpisodeNumber = episode.CombinedEpisodeNumber; CombinedSeason = episode.CombinedSeason; Directors = episode.Directors; DvdChapter = episode.DvdChapter; DvdDiscId = episode.DvdDiscId; DvdEpisodeNumber = episode.DvdEpisodeNumber; DvdSeason = episode.DvdSeason; EpisodeName = episode.EpisodeName; EpisodeNumber = episode.EpisodeNumber; FirstAired = episode.FirstAired; GuestStars = episode.GuestStars; ImdbId = episode.ImdbId; Language = episode.Language; Overview = episode.Overview; ProductionCode = episode.ProductionCode; Rating = episode.Rating; SeasonId = episode.SeasonId; SeasonNumber = episode.SeasonNumber; Writer = episode.Writer; }