private List <BaseItem> GetTrailerChildren() { List <BaseItem> children = new List <BaseItem>(); using (WebClient client = new WebClient()) { //Logger.ReportInfo("Getting Trailers from: "+String.Format(MBTrailerUrl,Config.Instance.SupporterKey, Plugin.PluginOptions.Instance.HDTrailers.ToString())); using (Stream stream = client.OpenRead(String.Format(MBTrailerUrl, Config.Instance.SupporterKey, Plugin.PluginOptions.Instance.HDTrailers.ToString()))) { XmlTextReader reader = new XmlTextReader(stream); reader.Read(); ITunesTrailer trailer = null; DateTimeFormatInfo dateFormat = new DateTimeFormatInfo(); dateFormat.ShortDatePattern = "yyyy-MM-dd"; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "movieinfo": if (trailer != null) { //found a new entry - add last one children.Add(trailer); } trailer = new ITunesTrailer() { DisplayMediaType = "Trailer" }; // trailer.Id = reader.GetAttribute(0); break; case "title": trailer.Name = ReadToValue(reader); trailer.Id = trailer.Name.GetMD5(); break; case "runtime": // trailer.RunningTime = ReadToValue(reader); break; case "rating": trailer.MpaaRating = ReadToValue(reader); break; case "studio": if (trailer.Studios == null) { trailer.Studios = new List <string>(); } trailer.Studios.Add(Name = ReadToValue(reader)); break; case "postdate": trailer.DateCreated = DateTime.Parse(ReadToValue(reader), dateFormat); break; case "releasedate": // trailer.ProductionYear = DateTime.Parse(ReadToValue(reader), dateFormat).Year; break; case "director": trailer.Directors = new List <string>() { ReadToValue(reader) }; break; case "description": trailer.Overview = ReadToValue(reader); break; case "cast": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "cast") { break; } if (reader.Name == "name") { if (trailer.Actors == null) { trailer.Actors = new List <Actor>(); } trailer.Actors.Add(new Actor() { Name = ReadToValue(reader) }); } } break; case "genre": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "genre") { break; } if (reader.Name == "name") { if (trailer.Genres == null) { trailer.Genres = new List <string>(); } trailer.Genres.Add(ReadToValue(reader)); } } break; case "poster": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "poster") { break; } if (reader.Name == "xlarge") { trailer.PrimaryImagePath = ReadToValue(reader); } } break; case "preview": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "preview") { break; } if (reader.Name == "large") { trailer.RealPath = ReadToValue(reader); //.Replace("movies.apple.com", "www.apple.com"); } } break; } } } if (trailer != null) { children.Add(trailer); //add the last one we built } } } return(children); }
private List<BaseItem> GetTrailerChildren() { List<BaseItem> children = new List<BaseItem>(); using (WebClient client = new WebClient()) { //Logger.ReportInfo("Getting Trailers from: "+String.Format(MBTrailerUrl,Config.Instance.SupporterKey, Plugin.PluginOptions.Instance.HDTrailers.ToString())); using (Stream stream = client.OpenRead(String.Format(MBTrailerUrl,Config.Instance.SupporterKey, Plugin.PluginOptions.Instance.HDTrailers.ToString()))) { XmlTextReader reader = new XmlTextReader(stream); reader.Read(); ITunesTrailer trailer = null; DateTimeFormatInfo dateFormat = new DateTimeFormatInfo(); dateFormat.ShortDatePattern = "yyyy-MM-dd"; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "movieinfo": if (trailer != null) { //found a new entry - add last one children.Add(trailer); } trailer = new ITunesTrailer() { DisplayMediaType = "Trailer" }; // trailer.Id = reader.GetAttribute(0); break; case "title": trailer.Name = ReadToValue(reader); trailer.Id = trailer.Name.GetMD5(); break; case "runtime": // trailer.RunningTime = ReadToValue(reader); break; case "rating": trailer.MpaaRating = ReadToValue(reader); break; case "studio": if (trailer.Studios == null) { trailer.Studios = new List<string>(); } trailer.Studios.Add(Name = ReadToValue(reader)); break; case "postdate": trailer.DateCreated = DateTime.Parse(ReadToValue(reader), dateFormat); break; case "releasedate": try { trailer.ProductionYear = DateTime.Parse(ReadToValue(reader), dateFormat).Year; } catch { } break; case "director": trailer.Directors = new List<string>() { ReadToValue(reader) }; break; case "description": trailer.Overview = ReadToValue(reader); break; case "cast": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "cast") break; if (reader.Name == "name") { if (trailer.Actors == null) { trailer.Actors = new List<Actor>(); } trailer.Actors.Add(new Actor() { Name = ReadToValue(reader) }); } } break; case "genre": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "genre") break; if (reader.Name == "name") { if (trailer.Genres == null) { trailer.Genres = new List<string>(); } trailer.Genres.Add(ReadToValue(reader)); } } break; case "poster": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "poster") break; if (reader.Name == "xlarge") { trailer.PrimaryImagePath = ReadToValue(reader); } } break; case "preview": while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "preview") break; if (reader.Name == "large") { trailer.RealPath = ReadToValue(reader); //.Replace("movies.apple.com", "www.apple.com"); } } break; } } } if (trailer != null) children.Add(trailer); //add the last one we built } } return children; }