// Collection/DVD/Credits/* private void HandleCredits(OMLSDKTitle title, XPathNavigator creditsNavigator) { List<string> writersAlreadyAdded = new List<string>(); List<string> producersAlreadyAdded = new List<string>(); foreach (XPathNavigator creditNavigator in creditsNavigator.SelectChildren("Credit", string.Empty)) { string creditType = creditNavigator.GetAttribute("CreditType", string.Empty); OMLSDKPerson person = new OMLSDKPerson(ReadFullName(creditNavigator)); switch (creditType) { case "Direction": title.AddDirector(person); break; case "Writing": title.AddWriter(person); break; case "Production": title.AddProducer(person); break; } } }
public bool SearchForMovie(string movieName, int maxResults) { if (_xmlFile == null) Initialize(PluginName, null); if (_xmlFile == null) return false; if (!File.Exists(_xmlFile)) return false; DataSet ds = new DataSet(); ds.ReadXml(_xmlFile); movieName = movieName.ToLowerInvariant(); List<DataRow> dvds = (from dvd in ds.Tables["DVD"].AsEnumerable() where dvd.Field<String>("Title").ToLowerInvariant().Contains(movieName) select dvd).ToList<DataRow>(); List<OMLSDKTitle> dvdList = new List<OMLSDKTitle>(); foreach (DataRow dr in dvds) { OMLSDKTitle t = new OMLSDKTitle(); t.Name = (String)dr["Title"]; t.ParentalRating = (String)dr["Rating"]; t.Synopsis = (String)dr["Overview"]; t.CountryOfOrigin = (String)dr["CountryOfOrigin"]; t.UPC = (String)dr["UPC"]; t.OriginalName = (String)dr["OriginalTitle"]; t.SortName = (String)dr["SortTitle"]; int runTime; if (int.TryParse((String)dr["RunningTime"], out runTime)) t.Runtime = runTime; DateTime dtReleased; if (DateTime.TryParse((String)dr["Released"], out dtReleased)) t.ReleaseDate = dtReleased; int prodYr; if (int.TryParse((String)dr["ProductionYear"], out prodYr)) t.ProductionYear = prodYr; t.FrontCoverPath = Path.Combine(DVDProfilerImageDir, (String)dr["ID"] + @"f.jpg"); t.BackCoverPath = Path.Combine(DVDProfilerImageDir, (String)dr["ID"] + @"b.jpg"); if (ds.Relations.Contains("DVD_Format")) { DataRow Format = dr.GetChildRows("DVD_Format")[0]; t.VideoStandard = (String)Format["FormatVideoStandard"]; t.VideoResolution = (String)Format["FormatAspectRatio"]; } if (ds.Relations.Contains("DVD_Genres") && ds.Relations.Contains("Genres_Genre")) { DataRow genres = dr.GetChildRows("DVD_Genres")[0]; foreach (DataRow gen in genres.GetChildRows("Genres_Genre")) { String genre = (String)gen[0]; t.Genres.Add(genre); } } if (ds.Relations.Contains("DVD_Actors") && ds.Relations.Contains("Actors_Actor")) { DataRow actors = dr.GetChildRows("DVD_Actors")[0]; foreach (DataRow actor in actors.GetChildRows("Actors_Actor")) { String fullName = String.Format(@"{0} {1}", actor["FirstName"], actor["LastName"]); t.AddActingRole(fullName, (String)actor["Role"]); } } if (ds.Relations.Contains("DVD_Credits") && ds.Relations.Contains("Credits_Credit")) { DataRow credits = dr.GetChildRows("DVD_Credits")[0]; foreach (DataRow credit in credits.GetChildRows("Credits_Credit")) { String CreditType = (String)credit["CreditType"]; String fullName = String.Format(@"{0} {1}", credit["FirstName"], credit["LastName"]); if (CreditType == "Direction") { t.AddDirector(new OMLSDKPerson(fullName)); } else if (CreditType == "Writing") { t.AddWriter(new OMLSDKPerson(fullName)); } else if (CreditType == "Production") { t.AddProducer(new OMLSDKPerson(fullName)); } } } List<String> _studios = new List<String>(); if (ds.Relations.Contains("DVD_Studios") && ds.Relations.Contains("Studios_Studio")) { DataRow studios = dr.GetChildRows("DVD_Studios")[0]; foreach (DataRow studio in studios.GetChildRows("Studios_Studio")) { _studios.Add((String)studio[0]); } } t.Studio = String.Join("; ", _studios.ToArray<String>()); dvdList.Add(t); } _searchResult = new DVDProfilerSearchResult(dvdList, dvds.Count, dvds.Count); bool rslt = (dvds.Count > 0); ds.Dispose(); ds = null; return rslt; }
public override void ProcessFile(string file) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(file); XmlNodeList nodeList = xDoc.SelectNodes("//movielist/movie"); foreach (XmlNode movieNode in nodeList) { OMLSDKTitle newTitle = new OMLSDKTitle(); XPathNavigator nav = movieNode.CreateNavigator(); newTitle.MetadataSourceID = GetChildNodesValue(nav, "id"); if (nav.MoveToChild("coverfront", "")) { newTitle.FrontCoverPath = nav.Value; nav.MoveToParent(); } if (nav.MoveToChild("coverback", "")) { newTitle.BackCoverPath = nav.Value; nav.MoveToParent(); } if (nav.MoveToChild("country", "")) { if (nav.MoveToChild("displayname", "")) { newTitle.CountryOfOrigin = nav.Value; nav.MoveToParent(); } nav.MoveToParent(); } if (nav.MoveToChild("title", "")) { newTitle.Name = nav.Value; nav.MoveToParent(); } /*if (nav.MoveToChild("plot", "")) { newTitle.Synopsis = nav.Value; nav.MoveToParent(); }*/ // Fix from DVDJunkie // http://www.ornskov.dk/forum/index.php?topic=1605.msg12171#msg12171 if (nav.MoveToChild("plot", "")) { string plot = nav.Value; plot = plot.Replace("<B>", ""); plot = plot.Replace("<b>", ""); plot = plot.Replace("</B>", ""); plot = plot.Replace("</b>", ""); plot = plot.Replace("<I>", ""); plot = plot.Replace("<i>", ""); plot = plot.Replace("</I>", ""); plot = plot.Replace("</i>", ""); newTitle.Synopsis = plot; nav.MoveToParent(); } /*if (nav.MoveToChild("releasedate", "")) { XPathNavigator localNav = nav.CreateNavigator(); //XmlNode rdYear = nav.SelectSingleNode("year"); //XmlNode rdMonth = nav.SelectSingleNode("month"); //XmlNode rdDay = nav.SelectSingleNode("day"); //if (rdYear != null && rdMonth != null && rdDay != null) //{ // DateTime rd = new DateTime(Int32.Parse(rdYear.InnerText), // Int32.Parse(rdMonth.InnerText), // Int32.Parse(rdDay.InnerText)); // if (rd != null) // newTitle.ReleaseDate = rd; //} nav.MoveToParent(); }*/ // Fix from DVDJunkie // http://www.ornskov.dk/forum/index.php?topic=1605.msg12171#msg12171 //hwh 12-7-09 if (nav.MoveToChild("releasedate", "")) { XPathNavigator localNav = nav.CreateNavigator(); string rdate = GetChildNodesValue(localNav, "date"); try { if (!string.IsNullOrEmpty(rdate)) newTitle.ProductionYear = Convert.ToInt32(rdate); } catch (FormatException) { } nav.MoveToParent(); } //hwh 12-7-09 if (nav.MoveToChild("dvdreleasedate", "")) { XPathNavigator localNav = nav.CreateNavigator(); string rdate = GetChildNodesValue(localNav, "date"); try { if (!string.IsNullOrEmpty(rdate)) newTitle.ReleaseDate = DateTime.Parse(rdate); } catch (ArgumentException) { } catch (FormatException) { } nav.MoveToParent(); } if (nav.MoveToChild("mpaarating", "")) { newTitle.ParentalRating = GetChildNodesValue(nav, "displayname"); nav.MoveToParent(); } if (nav.MoveToChild("upc", "")) { newTitle.UPC = nav.Value; nav.MoveToParent(); } if (nav.MoveToChild("runtimeminutes", "")) { //newTitle.Runtime = nav.ValueAsInt; newTitle.Runtime = ConvertStringToInt(nav.Value); nav.MoveToParent(); } if (nav.MoveToChild("genres", "")) { XPathNodeIterator genreIter = nav.SelectChildren("genre", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < genreIter.Count; i++) { newTitle.AddGenre(GetChildNodesValue(localNav, "displayname")); localNav.MoveToNext("genre", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("cast", "")) { XPathNodeIterator starIter = nav.SelectChildren("star", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < starIter.Count; i++) { string role = GetChildNodesValue(localNav, "role"); XPathNavigator personNav = localNav.SelectSingleNode("person"); if (personNav != null) { string name = GetChildNodesValue(personNav, "displayname"); if (!string.IsNullOrEmpty(role) && !string.IsNullOrEmpty(name)) { newTitle.AddActingRole(name, role); } } localNav.MoveToNext("star", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("crew", "")) { XPathNodeIterator crewMemberIter = nav.SelectChildren("crewmember", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < crewMemberIter.Count; i++) { string role = GetChildNodesValue(localNav, "role"); XPathNavigator cmNav = localNav.SelectSingleNode("person"); if (cmNav != null) { string name = GetChildNodesValue(cmNav, "displayname"); if (!string.IsNullOrEmpty(role) && !string.IsNullOrEmpty(name)) { switch (role.ToLower()) { case "director": newTitle.AddDirector(new OMLSDKPerson(name)); break; case "writer": newTitle.AddWriter(new OMLSDKPerson(name)); break; default: break; } } } localNav.MoveToNext("crewmember", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("subtitles", "")) { XPathNodeIterator subtitleIter = nav.SelectChildren("subtitle", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < subtitleIter.Count; i++) { newTitle.AddSubtitle(GetChildNodesValue(localNav, "displayname")); localNav.MoveToNext("subtitle", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("audios", "")) { XPathNodeIterator audioIter = nav.SelectChildren("audio", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < audioIter.Count; i++) { newTitle.AddAudioTrack(GetChildNodesValue(localNav, "displayname")); localNav.MoveToNext("audio", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("studios", "")) { XPathNodeIterator studioIter = nav.SelectChildren("studio", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < studioIter.Count; i++) { newTitle.Studio = GetChildNodesValue(localNav, "displayname"); localNav.MoveToNext("studio", ""); } } nav.MoveToParent(); } if (nav.MoveToChild("links", "")) { XPathNodeIterator linkIter = nav.SelectChildren("link", ""); if (nav.MoveToFirstChild()) { XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < linkIter.Count; i++) { string type = GetChildNodesValue(localNav, "urltype"); if (!string.IsNullOrEmpty(type)) { if (type.ToUpper().CompareTo("MOVIE") == 0) { string path = GetChildNodesValue(localNav, "url"); if (!string.IsNullOrEmpty(path)) { try { FileInfo fi = new FileInfo(path); if (fi.Exists) { string ext = fi.Extension.Substring(1); if (!string.IsNullOrEmpty(ext)) { if (IsSupportedFormat(ext)) { OMLSDKDisk disk = new OMLSDKDisk(); disk.Format = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), ext, true); disk.Path = path; disk.Name = GetChildNodesValue(localNav, "description"); newTitle.AddDisk(disk); } } } } catch (Exception ex) { SDKUtilities.DebugLine("MovieCollectorzPlugin: {0}", ex); } } } } localNav.MoveToNext("link", ""); } } } if (ValidateTitle(newTitle)) { try { AddTitle(newTitle); } catch (Exception e) { SDKUtilities.DebugLine("[MovieCollectorzPlugin] Error adding row: " + e.Message); } } else SDKUtilities.DebugLine("[MovieCollectorzPlugin] Error saving row"); } }