public static void CreateNfoFile(SeriesInfo seriesInfo, string folderPath, string fileName, TVRenameShow tvRenameShow) { // create document XDocument infoDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); XElement rootElem = new XElement("tvshow", new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"), new XAttribute(XNamespace.Xmlns + "xsd", "http://www.w3.org/2001/XMLSchema")); // populate with correct nodes from series info if (tvRenameShow.UseCustomShowName) { rootElem.Add(new XElement("title", tvRenameShow.CustomShowName ?? string.Empty)); } else { rootElem.Add(new XElement("title", seriesInfo.Title ?? string.Empty)); } rootElem.Add(new XElement("id", seriesInfo.ID)); rootElem.Add(new XElement("rating", seriesInfo.Rating ?? string.Empty)); rootElem.Add(new XElement("mpaa", seriesInfo.MpaaClassification ?? string.Empty)); rootElem.Add(new XElement("premiered", seriesInfo.DatePremiered ?? string.Empty)); rootElem.Add(new XElement("studio", seriesInfo.Studio ?? string.Empty)); rootElem.Add(new XElement("plot", seriesInfo.Plot ?? string.Empty)); // actors foreach (var actorInfo in seriesInfo.Actors) { XElement actorElem = new XElement("actor"); actorElem.Add(new XElement("name", actorInfo.Name ?? string.Empty)); actorElem.Add(new XElement("role", actorInfo.Role ?? string.Empty)); actorElem.Add(new XElement("thumb", actorInfo.ThumbnailUrl ?? string.Empty)); rootElem.Add(actorElem); } infoDoc.Add(rootElem); // write document out to correct directory ConsoleLogger.LogStart("Creating NFO file..."); if (!CustomConfiguration.DisableAllFileSystemActions) { infoDoc.Save(folderPath + "\\" + fileName); } ConsoleLogger.LogEnd("done."); }
public static void CreateNfoFile(SeriesInfo seriesInfo, EpisodeInfo episodeInfo, string folderPath, string fileName, TVRenameShow tvRenameShow) { // create document XDocument infoDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); XElement rootElem = new XElement("episodedetails"); // populate with correct nodes from series info and episode info rootElem.Add(new XElement("title", episodeInfo.EpisodeName ?? string.Empty)); rootElem.Add(new XElement("rating", episodeInfo.Rating > 0 ? episodeInfo.Rating.ToString() : string.Empty)); rootElem.Add(new XElement("season", episodeInfo.SeasonNumber)); if (tvRenameShow.UseDvdOrder) { rootElem.Add(new XElement("episode", episodeInfo.DvdEpisodeNumber)); } else { rootElem.Add(new XElement("episode", episodeInfo.EpisodeNumber)); } rootElem.Add(new XElement("plot", episodeInfo.Overview ?? string.Empty)); rootElem.Add(new XElement("thumb", episodeInfo.ThumbnailUrl ?? string.Empty)); rootElem.Add(new XElement("playcount", 0)); rootElem.Add(new XElement("lastplayed", string.Empty)); rootElem.Add(new XElement("credits", episodeInfo.Writer ?? string.Empty)); rootElem.Add(new XElement("director", episodeInfo.Director ?? string.Empty)); rootElem.Add(new XElement("aired", episodeInfo.FirstAired ?? string.Empty)); //rootElem.Add(new XElement("premiered", episodeInfo.FirstAired ?? string.Empty)); rootElem.Add(new XElement("mpaa", seriesInfo.MpaaClassification ?? string.Empty)); rootElem.Add(new XElement("premiered", seriesInfo.DatePremiered ?? string.Empty)); rootElem.Add(new XElement("studio", seriesInfo.Studio ?? string.Empty)); // actors from series foreach (var actorInfo in seriesInfo.Actors) { XElement actorElem = new XElement("actor"); actorElem.Add(new XElement("name", actorInfo.Name ?? string.Empty)); actorElem.Add(new XElement("role", actorInfo.Role ?? string.Empty)); actorElem.Add(new XElement("thumb", actorInfo.ThumbnailUrl ?? string.Empty)); rootElem.Add(actorElem); } // actors from episode foreach (var actorInfo in episodeInfo.GuestActors) { XElement actorElem = new XElement("actor"); actorElem.Add(new XElement("name", actorInfo.Name ?? string.Empty)); actorElem.Add(new XElement("role", actorInfo.Role ?? string.Empty)); actorElem.Add(new XElement("thumb", actorInfo.ThumbnailUrl ?? string.Empty)); rootElem.Add(actorElem); } infoDoc.Add(rootElem); // write document out to correct directory ConsoleLogger.LogStart("Creating episode NFO file..."); if (!CustomConfiguration.DisableAllFileSystemActions) { infoDoc.Save(folderPath + "\\" + fileName); } ConsoleLogger.LogEnd("done."); }