public void WriteOutput(String outputFile, Movie info, DataFromFile parsedDataFromFile, FullCast cast) { XmlDocument document = new XmlDocument(); XmlNode rootNode = document.CreateElement("movie"); document.AppendChild(rootNode); XmlNode movieName = document.CreateElement("name"); movieName.InnerText = parsedDataFromFile.getName(); rootNode.AppendChild(movieName); XmlNode movieYear = document.CreateElement ("year"); movieYear.InnerText = parsedDataFromFile.getYear(); rootNode.AppendChild(movieYear); XmlNode movieRuntime = document.CreateElement("runtime"); movieRuntime.InnerText = info.Runtime; rootNode.AppendChild(movieRuntime); XmlNode movieSynopsis = document.CreateElement("synopsis"); movieSynopsis.InnerText = info.Synopsis; rootNode.AppendChild(movieSynopsis); XmlNode movieCast = document.CreateElement("cast"); rootNode.AppendChild(movieCast); Actor[] actors = cast.Cast; foreach (Actor a in actors) { XmlNode movieCastActor = document.CreateElement("actor"); movieCast.AppendChild(movieCastActor); XmlNode movieCastName = document.CreateElement("name"); movieCastName.InnerText = a.Name; movieCastActor.AppendChild(movieCastName); String[] characters = a.Characters; foreach (String s in characters) { XmlNode movieCastCharacter = document.CreateElement("character"); movieCastCharacter.InnerText = s; movieCastActor.AppendChild(movieCastCharacter); } } document.Save(outputFile); }
private static void processMovieInfo(Movie info, DataFromFile dataFromFile, String fullPath, ArrayList failedMovies) { //Check release year if (!dataFromFile.getYear().Equals(info.Year)) { failedMovies.Add(dataFromFile.getName()); logger.log("Error - directory year " + dataFromFile.getYear() + " does not equal retrieved year " + info.Year); return; } //Grab full cast data String fullCastUrl = null; FullCast fullCast = new FullCast(); info.Links.TryGetValue("cast", out fullCastUrl); if (fullCastUrl == null) { logger.log("Error - full cast url for " + dataFromFile.getName() + " was null"); } else { String rottenCastJson = dataFetcher.getCastData(fullCastUrl); fullCast = dataParser.getCastParsedData(rottenCastJson); } //Get IMDB data for synopsis String imdbNumber = null; String imdbJson = null; info.Alternate_IDs.TryGetValue("imdb", out imdbNumber); if (imdbNumber == null) { logger.log("Error - IMDB number for " + dataFromFile.getName() + " was null"); } else { imdbJson = imdbDataFetcher.getData(imdbNumber); } //Download the movie poster String posterUrl = null; info.Posters.TryGetValue("original", out posterUrl); if (posterUrl == null) { logger.log("Error - Poster url for movie " + dataFromFile.getName() + " was null"); } else { saveCover(posterUrl, fullPath, failedMovies, dataFromFile.getName()); } outputWriter.WriteOutput(fullPath + "//Info.xml", info, dataFromFile, fullCast); }