/// <summary> /// update the XBMC .nfo file /// </summary> /// <param name="videoItemFile"></param> /// <param name="videoItem"></param> /// <returns></returns> public bool UpdateXBMC(VideoInfo videoInfo) { // MyLog.Add("UpdateXBMC"); string videoFullName = null; string fileContents = null; if (videoInfo.files == null || videoInfo.files.xbmc == null) { if (Config.settings.createXBMC) { videoFullName = videoInfo.videoDirectory + @"\movie.nfo"; fileContents = GetDefaultXBMCxml(); } else { return(false); } } else if (!Config.settings.updateXBMC) { return(false); } else { videoFullName = videoInfo.GetFullName(videoInfo.files.xbmc); fileContents = MyFile.ReadAllText(videoFullName); } if (fileContents == null || videoFullName == null) { return(false); } VideoItem videoItem = videoInfo.videoItem; XmlDocument doc = MyXMLDoc.LoadXml(fileContents); if (doc == null) { return(false); } MyXMLDoc.SetSingleNodeString(doc, "/movie/title", videoItem.title); MyXMLDoc.SetSingleNodeString(doc, "/movie/plot", videoItem.plot); MyXMLDoc.SetSingleNodeString(doc, "/movie/set", videoItem.movieset); MyXMLDoc.SetSingleNodeString(doc, "/movie/tagline", videoItem.tagline); MyXMLDoc.SetSingleNodeString(doc, "/movie/id", videoItem.imdbId); MyXMLDoc.SetSingleNodeString(doc, "/movie/tmdbId", videoItem.tmdbId); MyXMLDoc.SetSingleNodeString(doc, "/movie/mpaa", videoItem.mpaa); MyXMLDoc.SetSingleNodeDecimal(doc, "/movie/rating", videoItem.imdbRating); MyXMLDoc.SetSingleNodeInt(doc, "/movie/year", videoItem.year); MyXMLDoc.SetSingleNodeInt(doc, "/movie/runtime", videoItem.runtime); MyXMLDoc.SetSingleNodeInt(doc, "/movie/playcount", videoItem.playCount); int watched = VideoFileEnums.watched.GetValueByKey(videoItem.watched); // either watched or not if (watched != 0 && watched != 1) { watched = 0; } MyXMLDoc.SetSingleNodeInt(doc, "/movie/watched", watched); bool ret = MyXMLDoc.SaveXML(doc, videoFullName); if (ret) { MyLog.Add("wrote " + videoFullName); } else { MyLog.Add("error writing to " + videoFullName); } return(ret); }
/// <summary> /// update the MB .xml file /// </summary> /// <param name="videoItemFile"></param> /// <param name="videoItem"></param> /// <returns></returns> public bool UpdateMB(VideoInfo videoInfo) { string videoFullName = null; string fileContents = null; if (videoInfo.files == null || videoInfo.files.mb == null) { if (Config.settings.createMB) { videoFullName = videoInfo.videoDirectory + @"\movie.xml"; fileContents = GetDefaultMBxml(); } else { return(false); } } else if (!Config.settings.updateMB) { return(false); } else { videoFullName = videoInfo.GetFullName(videoInfo.files.mb); fileContents = MyFile.ReadAllText(videoFullName); } if (fileContents == null || videoFullName == null) { return(false); } VideoItem videoItem = videoInfo.videoItem; XmlDocument doc = MyXMLDoc.LoadXml(fileContents); if (doc == null) { return(false); } MyXMLDoc.SetSingleNodeString(doc, "/Title/LocalTitle", videoItem.title); MyXMLDoc.SetSingleNodeString(doc, "/Title/Overview", videoItem.plot); MyXMLDoc.SetSingleNodeString(doc, "/Title/set", videoItem.movieset); MyXMLDoc.SetSingleNodeString(doc, "/Title/tagline", videoItem.tagline); MyXMLDoc.SetSingleNodeString(doc, "/Title/IMDB", videoItem.imdbId); MyXMLDoc.SetSingleNodeString(doc, "/Title/TMDbId", videoItem.tmdbId); MyXMLDoc.SetSingleNodeString(doc, "/Title/ContentRating", videoItem.mpaa); MyXMLDoc.SetSingleNodeDecimal(doc, "/Title/Rating", videoItem.imdbRating); MyXMLDoc.SetSingleNodeInt(doc, "/Title/ProductionYear", videoItem.year); MyXMLDoc.SetSingleNodeInt(doc, "/Title/RunningTime", videoItem.runtime); bool ret = MyXMLDoc.SaveXML(doc, videoFullName); if (ret) { MyLog.Add("wrote " + videoFullName); } else { MyLog.Add("error writing to " + videoFullName); } return(ret); }