/// <summary> /// Saves the series. /// </summary> /// <param name="series">The series.</param> /// <param name="type">The SeriesIOType type.</param> public void SaveSeries(Series series, SeriesIOType type) { string path = series.GetSeriesPath(); if (string.IsNullOrEmpty(path)) { return; } string nfoTemplate; string posterTemplate; string fanartTemplate; string bannerTemplate; string firstEpisodePath = series.GetFirstEpisode(); if (Get.InOutCollection.RenameTV) { TvRenamerFactory.RenameSeries(series); } if (MovieNaming.IsBluRay(firstEpisodePath)) { nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesNfoTemplate; posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesPosterTemplate; fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesFanartTemplate; bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesBannerTemplate; } else if (MovieNaming.IsDVD(firstEpisodePath)) { nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesNfoTemplate; posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesPosterTemplate; fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesFanartTemplate; bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesBannerTemplate; } else { nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesNfoTemplate; posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesPosterTemplate; fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesFanartTemplate; bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesBannerTemplate; } if (type == SeriesIOType.All || type == SeriesIOType.Nfo) { // Nfo string nfoPathTo = GeneratePath.TvSeries(series, nfoTemplate, string.Empty); this.WriteNFO(this.GenerateSeriesOutput(series), nfoPathTo); series.ChangedText = false; } // Poster if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Poster) { if (!string.IsNullOrEmpty(series.PosterUrl) || !string.IsNullOrEmpty(series.PosterPath)) { string posterPathFrom; if (!string.IsNullOrEmpty(series.PosterPath) && File.Exists(series.PosterPath)) { posterPathFrom = series.PosterPath; } else { posterPathFrom = this.TvPathImageGet(series.PosterUrl); } string posterPathTo = GeneratePath.TvSeries(series, posterTemplate, posterPathFrom); this.CopyFile(posterPathFrom, posterPathTo); series.ChangedPoster = false; } } // Fanart if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Fanart) { if (!string.IsNullOrEmpty(series.FanartUrl) || !string.IsNullOrEmpty(series.FanartPath)) { string fanartPathFrom; if (!string.IsNullOrEmpty(series.FanartPath) && File.Exists(series.FanartPath)) { fanartPathFrom = series.FanartPath; } else { fanartPathFrom = this.TvPathImageGet(series.FanartUrl); } string fanartPathTo = GeneratePath.TvSeries(series, fanartTemplate, fanartPathFrom); this.CopyFile(fanartPathFrom, fanartPathTo); series.ChangedFanart = false; } } // Banner if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Banner) { if (!string.IsNullOrEmpty(series.SeriesBannerUrl) || !string.IsNullOrEmpty(series.SeriesBannerPath)) { string bannerPathFrom; if (!string.IsNullOrEmpty(series.SeriesBannerPath) && File.Exists(series.SeriesBannerPath)) { bannerPathFrom = series.SeriesBannerPath; } else { bannerPathFrom = this.TvPathImageGet(series.SeriesBannerUrl); } string bannerPathTo = GeneratePath.TvSeries(series, bannerTemplate, bannerPathFrom); this.CopyFile(bannerPathFrom, bannerPathTo); series.ChangedBanner = false; } } }
/// <summary> /// Loads the series. /// </summary> /// <param name="series"> /// The series. /// </param> /// <returns> /// Loaded succeeded /// </returns> public bool LoadSeries(Series series) { string seriesName = series.SeriesName; string seriesPath = series.GetSeriesPath(); if (!string.IsNullOrEmpty(seriesName) || !string.IsNullOrEmpty(seriesPath)) { var seriesNameHex = "Set_" + FileSystemCharChange.To( seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Hex) + "_1"; var seriesNameChar = "Set_" + FileSystemCharChange.To( seriesName, FileSystemCharChange.ConvertArea.Tv, FileSystemCharChange.ConvertType.Char) + "_1"; string nfo = Find.FindNFO("Set_" + seriesName + "_1", seriesPath); if (string.IsNullOrEmpty(nfo)) { nfo = Find.FindNFO(seriesNameHex, seriesPath); if (string.IsNullOrEmpty(nfo)) { nfo = Find.FindNFO(seriesNameChar, seriesPath); if (!string.IsNullOrEmpty(nfo)) { XmlDocument doc = XRead.OpenPath(nfo); series.SeriesName = XRead.GetString(doc, "title"); series.SeriesID = XRead.GetUInt(doc, "id"); series.Rating = XRead.GetDouble(doc, "rating"); series.Overview = XRead.GetString(doc, "plot"); series.ContentRating = XRead.GetString(doc, "certification"); series.Genre = XRead.GetStrings(doc, "genre").ToBindingList(); series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd"); series.Network = XRead.GetString(doc, "country"); if (doc.GetElementsByTagName("actor").Count > 0) { series.Actors = new BindingList<PersonModel>(); foreach (XmlNode actor in doc.GetElementsByTagName("actor")) { string xmlActor = actor.InnerXml; XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>"); string name = XRead.GetString(docActor, "name"); string role = XRead.GetString(docActor, "role"); string imageurl = XRead.GetString(docActor, "thumb"); var personModel = new PersonModel(name, imageurl, role); series.Actors.Add(personModel); } } } } } } foreach (var season in series.Seasons) { foreach (var episode in season.Value.Episodes) { if (File.Exists(episode.FilePath.PathAndFilename)) { var nfoPath = Path.Combine( episode.FilePath.FolderPath, episode.FilePath.FilenameWithOutExt + ".nfo"); if (File.Exists(nfoPath)) { var doc = XRead.OpenPath(nfoPath); episode.SeasonNumber = XRead.GetInt(doc, "season"); episode.EpisodeNumber = XRead.GetInt(doc, "episode"); episode.EpisodeName = XRead.GetString(doc, "title"); episode.Overview = XRead.GetString(doc, "plot"); episode.FirstAired = XRead.GetDateTime(doc, "aired"); } } } } return true; }
/// <summary> /// Loads the series. /// </summary> /// <param name="series"> /// The series. /// </param> /// <returns> /// Loaded succeeded /// </returns> public bool LoadSeries(Series series) { string seriesName = series.GetSeriesNameOnDisk(); string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesName) || string.IsNullOrEmpty(seriesPath)) { return false; } string nfo = Find.FindNFO(seriesName, seriesPath); if (string.IsNullOrEmpty(nfo)) { return false; } XmlDocument doc = XRead.OpenPath(nfo); series.SeriesName = XRead.GetString(doc, "title"); series.SeriesID = XRead.GetUInt(doc, "id"); series.Rating = XRead.GetDouble(doc, "rating"); series.Overview = XRead.GetString(doc, "plot"); series.ContentRating = XRead.GetString(doc, "certification"); series.Genre = XRead.GetStrings(doc, "genre").ToBindingList(); series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd"); series.Network = XRead.GetString(doc, "country"); if (doc.GetElementsByTagName("actor").Count > 0) { series.Actors = new BindingList<PersonModel>(); foreach (XmlNode actor in doc.GetElementsByTagName("actor")) { string xmlActor = actor.InnerXml; XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>"); string name = XRead.GetString(docActor, "name"); string role = XRead.GetString(docActor, "role"); string imageurl = XRead.GetString(docActor, "thumb"); var personModel = new PersonModel(name, role, imageurl); series.Actors.Add(personModel); } } return true; }
/// <summary> /// Gets the series poster. /// </summary> /// <param name="series">The series.</param> /// <returns> /// Series poster path /// </returns> public string GetSeriesPoster(Series series) { string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesPath)) { return string.Empty; } string checkPath = seriesPath + Path.DirectorySeparatorChar + "season-all.tbn"; if (File.Exists(checkPath)) { return checkPath; } return string.Empty; }
/// <summary> /// Gets the series NFO. /// </summary> /// <param name="series">The series.</param> /// <returns> /// Series NFO path /// </returns> public string GetSeriesNFO(Series series) { string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesPath)) { return string.Empty; } string checkPath = seriesPath + Path.DirectorySeparatorChar + "tvshow.nfo"; if (File.Exists(checkPath)) { return checkPath; } return string.Empty; }
/// <summary> /// Gets the series banner. /// </summary> /// <param name="series">The series.</param> /// <returns> /// Series Banner path /// </returns> public string GetSeriesBanner(Series series) { string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesPath)) { return string.Empty; } string checkPath = seriesPath + Path.DirectorySeparatorChar + "folder.jpg"; if (File.Exists(checkPath)) { return checkPath; } return string.Empty; }
/// <summary> /// Loads the series. /// </summary> /// <param name="series"> /// The series. /// </param> /// <returns> /// Loaded succeeded /// </returns> public bool LoadSeries(Series series) { string seriesName = series.GetSeriesNameOnDisk(); string seriesPath = series.GetSeriesPath(); if (string.IsNullOrEmpty(seriesName) || string.IsNullOrEmpty(seriesPath)) { return false; } string nfo = Find.FindNFO(seriesName, seriesPath); if (string.IsNullOrEmpty(nfo)) { return false; } XmlDocument doc = XRead.OpenPath(nfo); series.SeriesID = XRead.GetUInt(doc, "id"); series.SeriesName = XRead.GetString(doc, "title"); series.Rating = XRead.GetDouble(doc, "rating"); series.ContentRating = XRead.GetString(doc, "mpaa"); //series.Votes = XRead.GetInt(doc, "votes"); series.Overview = XRead.GetString(doc, "plot"); series.Runtime = XRead.GetInt(doc, "runtime"); //series.Tagline = XRead.GetString(doc, "tagline"); // Thumb // Fanart //series.EpisodeGuide = XRead.GetString(doc, "url"); // url is located in episodeguide tags series.Genre = XRead.GetStrings(doc, "genre").ToBindingList(); //series.Director = XRead.GetString(doc, "director"); series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd"); series.Status = XRead.GetString(doc, "status"); //series.Aired = XRead.GetString(doc, "aired"); series.Network = XRead.GetString(doc, "studio"); //series.Trailer = XRead.GetString(doc, "trailer"); if (doc.GetElementsByTagName("actor").Count > 0) { series.Actors = new BindingList<PersonModel>(); foreach (XmlNode actor in doc.GetElementsByTagName("actor")) { string xmlActor = actor.InnerXml; XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>"); string name = XRead.GetString(docActor, "name"); string role = XRead.GetString(docActor, "role"); string imageurl = XRead.GetString(docActor, "thumb"); var personModel = new PersonModel(name, role, imageurl); series.Actors.Add(personModel); } } return true; }