private List<BaseItem> ParseDocument(XmlDocument xDoc) { List<BaseItem> trailers = new List<BaseItem>(); XmlNodeList movieTrailers = xDoc.GetElementsByTagName("movie"); foreach (XmlNode movie in movieTrailers) { try { var currentTrailer = new FilmTrailer(); var x = movie; foreach (XmlNode node in movie.ChildNodes) { if (node.Name == "original_title") { currentTrailer.Name = node.InnerText; } if (node.Name == "movie_duration") { currentTrailer.RunningTime = Int32.Parse(node.InnerText); } if (node.Name == "production_year") { currentTrailer.ProductionYear = Int32.Parse(node.InnerText); } if (node.Name == "actors") { var actors = node.SelectNodes("./actor"); if (currentTrailer.Actors == null) currentTrailer.Actors = new List<Actor>(); foreach (XmlNode anode in actors) { string actorName = anode.InnerText; if (!string.IsNullOrEmpty(actorName)) currentTrailer.Actors.Add(new Actor { Name = actorName, Role = "" }); } } if (node.Name == "directors") { if (currentTrailer.Directors == null) currentTrailer.Directors = new List<string>(); var directors = node.SelectNodes("./director"); if (directors.Count > 0) { foreach (XmlNode dnode in directors) { currentTrailer.Directors.Add(dnode.InnerText); } } } if (node.Name == "regions") { currentTrailer.Overview = node.SelectSingleNode("./region/products/product/description").InnerText; currentTrailer.DateCreated = DateTime.Parse(node.SelectSingleNode("./region/products/product/pub_date").InnerText); currentTrailer.DateModified = currentTrailer.DateCreated; //currentTrailer.PrimaryImagePath = node.SelectSingleNode("./region/pictures/picture/url").InnerText; var pictures = node.SelectNodes("./region/pictures/picture"); foreach (XmlNode pnode in pictures) { if (pnode.Attributes["type_name"].Value == "poster") { currentTrailer.PrimaryImagePath = pnode.SelectSingleNode("./url").InnerText; } } var genres = node.SelectNodes("./region/categories/categorie"); if (currentTrailer.Genres == null) currentTrailer.Genres = new List<string>(); foreach (XmlNode gnode in genres) { currentTrailer.Genres.Add(gnode.InnerText); } var files = node.SelectNodes("./region/products/product/clips/clip/files/file"); foreach (XmlNode file in files) { if ((file.Attributes["format"].Value == "wmv" && file.Attributes["size"].Value == "xlarge") || (file.Attributes["format"].Value == "wmv" && file.Attributes["size"].Value == "xxlarge")) { foreach (XmlNode nodeFile in file) { if (nodeFile.Name == "url") { string[] pathUrl = nodeFile.InnerText.Split('?'); currentTrailer.Path = pathUrl[0]; } } } } break; } } currentTrailer.Id = currentTrailer.Path.GetMD5(); currentTrailer.SubTitle = "presented by FilmTrailer.com"; trailers.Add(currentTrailer); //Plugin.Logger.ReportInfo("FilmTrailer added trailer: " + currentTrailer.Name); } catch (Exception e) { Logger.ReportException("Failed to parse trailer document", e); } } return trailers; }
private List <BaseItem> ParseDocument(XmlDocument xDoc) { List <BaseItem> trailers = new List <BaseItem>(); XmlNodeList movieTrailers = xDoc.GetElementsByTagName("movie"); foreach (XmlNode movie in movieTrailers) { try { var currentTrailer = new FilmTrailer(); var x = movie; foreach (XmlNode node in movie.ChildNodes) { if (node.Name == "original_title") { currentTrailer.Name = node.InnerText; } if (node.Name == "movie_duration") { currentTrailer.RunningTime = Int32.Parse(node.InnerText); } if (node.Name == "production_year") { currentTrailer.ProductionYear = Int32.Parse(node.InnerText); } if (node.Name == "actors") { var actors = node.SelectNodes("./actor"); if (currentTrailer.Actors == null) { currentTrailer.Actors = new List <Actor>(); } foreach (XmlNode anode in actors) { string actorName = anode.InnerText; if (!string.IsNullOrEmpty(actorName)) { currentTrailer.Actors.Add(new Actor { Name = actorName, Role = "" }); } } } if (node.Name == "directors") { if (currentTrailer.Directors == null) { currentTrailer.Directors = new List <string>(); } var directors = node.SelectNodes("./director"); if (directors.Count > 0) { foreach (XmlNode dnode in directors) { currentTrailer.Directors.Add(dnode.InnerText); } } } if (node.Name == "regions") { currentTrailer.Overview = node.SelectSingleNode("./region/products/product/description").InnerText; currentTrailer.DateCreated = DateTime.Parse(node.SelectSingleNode("./region/products/product/pub_date").InnerText); currentTrailer.DateModified = currentTrailer.DateCreated; //currentTrailer.PrimaryImagePath = node.SelectSingleNode("./region/pictures/picture/url").InnerText; var pictures = node.SelectNodes("./region/pictures/picture"); foreach (XmlNode pnode in pictures) { if (pnode.Attributes["type_name"].Value == "poster") { currentTrailer.PrimaryImagePath = pnode.SelectSingleNode("./url").InnerText; } } var genres = node.SelectNodes("./region/categories/categorie"); if (currentTrailer.Genres == null) { currentTrailer.Genres = new List <string>(); } foreach (XmlNode gnode in genres) { currentTrailer.Genres.Add(gnode.InnerText); } var files = node.SelectNodes("./region/products/product/clips/clip/files/file"); foreach (XmlNode file in files) { if ((file.Attributes["format"].Value == "wmv" && file.Attributes["size"].Value == "xlarge") || (file.Attributes["format"].Value == "wmv" && file.Attributes["size"].Value == "xxlarge")) { foreach (XmlNode nodeFile in file) { if (nodeFile.Name == "url") { string[] pathUrl = nodeFile.InnerText.Split('?'); currentTrailer.Path = pathUrl[0]; } } } } break; } } currentTrailer.Id = currentTrailer.Path.GetMD5(); currentTrailer.SubTitle = "presented by FilmTrailer.com"; trailers.Add(currentTrailer); //Plugin.Logger.ReportInfo("FilmTrailer added trailer: " + currentTrailer.Name); } catch (Exception e) { Logger.ReportException("Failed to parse trailer document", e); } } return(trailers); }