public static TVShow ReadTvShowNFO(string folder) { TVShow T = new TVShow(); // read the movie file XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnodeTvShow; FileStream fs = new FileStream(folder, FileMode.Open, FileAccess.Read); xmldoc.Load(fs); xmlnodeTvShow = xmldoc.ChildNodes[0]; XmlNode xmlnodeTitle = xmlnodeTvShow.SelectSingleNode("title"); T.title = xmlnodeTitle.InnerText; XmlNode xmlnodeYear = xmlnodeTvShow.SelectSingleNode("year"); T.year = xmlnodeYear.InnerText; XmlNodeList xmlnodeGenre = xmlnodeTvShow.SelectNodes("genre"); List<string> genres = new List<string>(); foreach (XmlNode genre in xmlnodeGenre) genres.Add(genre.InnerText); T.genre = genres; XmlNode xmlnodeId = xmlnodeTvShow.SelectSingleNode("id"); T.id = int.Parse(xmlnodeId.InnerText); XmlNode xmlnodePath = xmlnodeTvShow.SelectSingleNode("episodeguide").FirstChild; T.filePath = xmlnodePath.InnerText; XmlNode xmlnodeSummary = xmlnodeTvShow.SelectSingleNode("outline"); T.summary = xmlnodeSummary.InnerText; XmlNode xmlnodeSeasons = xmlnodeTvShow.SelectSingleNode("season"); T.NumberOfSeasons = Convert.ToInt32(xmlnodeSeasons.InnerText); XmlNode xmlnodeEpisodes = xmlnodeTvShow.SelectSingleNode("episode"); T.NumberOfEpisodes = Convert.ToInt32(xmlnodeEpisodes.InnerText); // return the new movie object return T; }
public static void WriteTvShowNFO(TVShow T) { // where does the file need to go? StringBuilder sb = new StringBuilder(); sb.AppendLine("<tvshow>"); sb.AppendLine("<title>" + T.title + "</title>"); sb.AppendLine("<year>" + T.year + "</year>"); sb.AppendLine("<season>" + T.NumberOfSeasons + "</season>"); sb.AppendLine("<episode>" + T.NumberOfEpisodes + "</episode>"); sb.AppendLine("<outline>" + T.summary + "</outline>"); foreach (string genre in T.genre) sb.AppendLine("<genre>" + genre + "</genre>"); sb.AppendLine("<id>" + T.id + "</id>"); sb.AppendLine("<episodeguide>"); sb.AppendLine("<url>" + T.filePath + "</url>"); sb.AppendLine("</episodeguide>"); sb.AppendLine("</tvshow>"); //write the file File.WriteAllText(T.filePath + "\\tvshow.nfo", sb.ToString()); }