/// <summary> /// this method switches between the different databases to fetche the search result into movieDetails /// </summary> public bool GetDetails(IMDBUrl url, ref IMDBMovie movieDetails) { try { MovieInfoDatabase currentDB = null; foreach (MovieInfoDatabase db in _databaseList) { if (db.ID == url.Database) { currentDB = db; } } if (currentDB == null) { return(false); } if (currentDB.Grabber == null) { return(false); } currentDB.Grabber.GetDetails(url, ref movieDetails); return(true); } catch (Exception ex) { Log.Error("Movie database lookup GetDetails() - grabber: {0}, message : {1}", url.Database, ex.Message); return(false); } }
public void Select(IMDBMovie movie) { FilterDefinition definition = (FilterDefinition)currentView.Filters[CurrentLevel]; definition.SelectedValue = GetFieldIdValue(movie, definition.Where).ToString(); if (currentLevel + 1 < currentView.Filters.Count) { currentLevel++; } }
/// <summary> /// Constructor /// </summary> /// <param name="aMovie">The currently playing movie</param> public NowPlayingVideo(IMDBMovie aMovie) { ItemId = aMovie.ID; Summary = aMovie.Plot; Title = aMovie.Title; Tagline = aMovie.TagLine; Directors = aMovie.Director; Writers = aMovie.WritingCredits; Actors = aMovie.Cast; Rating = aMovie.Rating.ToString(); Year = aMovie.Year; Genres = aMovie.Genre; Certification = aMovie.MPARating; ImageUrl = aMovie.ThumbURL; }
/// <summary> /// Create playlist item from a file /// </summary> /// <param name="file">Path to file</param> /// <returns>Playlist item</returns> internal static MediaPortal.Playlists.PlayListItem CreatePlaylistItemFromVideoFile(string file) { FileInfo info = new FileInfo(file); MediaPortal.Playlists.PlayListItem item = new MediaPortal.Playlists.PlayListItem(); item.Description = info.Name; item.FileName = info.FullName; item.Type = PlayListItem.PlayListItemType.Video; //item.Duration IMDBMovie movie = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(file, ref movie); if (id > 0) { item.Duration = movie.RunTime; } return item; }
/// <summary> /// this method switches between the different databases to fetche the search result into movieDetails /// </summary> public bool GetDetails(IMDBUrl url, ref IMDBMovie movieDetails) { try { /* * // extract host from url, to find out which mezhod should be called * int iStart = url.URL.IndexOf(".")+1; * int iEnd = url.URL.IndexOf(".",iStart); * if ((iStart<0) || (iEnd<0)) * { * // could not extract hostname! * Log.Info("Movie DB lookup GetDetails(): could not extract hostname from {0}",url.URL); * return false; * } * string strHost = url.URL.Substring(iStart,iEnd-iStart).ToUpper();*/ MovieInfoDatabase currentDB = null; foreach (MovieInfoDatabase db in _databaseList) { if (db.ID == url.Database) { currentDB = db; } } if (currentDB == null) { return(false); } if (currentDB.Grabber == null) { return(false); } currentDB.Grabber.GetDetails(url, ref movieDetails); return(true); } catch (Exception ex) { Log.Error("Movie database lookup GetDetails() - grabber: {0}, message : {1}", url.Database, ex.Message); return(false); } }
/// <summary> /// Adds a song to a playlist /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="entry">Item that gets added</param> /// <param name="index">Index where the item should be added</param> /// <param name="refresh">Should the playlist be refreshed after the item is added</param> public static void AddItemToPlaylist(String type, PlaylistEntry entry, int index, bool refresh) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); PlayListItem item = null; //If it's a music item, try to find it in the db if (plType == PlayListType.PLAYLIST_MUSIC) { MusicDatabase mpMusicDb = MusicDatabase.Instance; Song song = new Song(); bool inDb = mpMusicDb.GetSongByFileName(entry.FileName, ref song); if (inDb) { item = ToPlayListItem(song); } } else if (plType == PlayListType.PLAYLIST_VIDEO) { IMDBMovie movie = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(entry.FileName, ref movie); if (id > 0) { item = ToPlayListItem(movie); } } if (item == null) { item = new PlayListItem(entry.Name, entry.FileName, entry.Duration); } playList.Insert(item, index); if (refresh) { RefreshPlaylistIfVisible(); } }
/// <summary> /// Creates Scrobble data based on a IMDBMovie object /// </summary> /// <param name="movie">The movie to base the object on</param> /// <returns>The Trakt scrobble data to send</returns> public static TraktMovieScrobble CreateScrobbleData(IMDBMovie movie) { string username = TraktSettings.Username; string password = TraktSettings.Password; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) return null; TraktMovieScrobble scrobbleData = new TraktMovieScrobble { Title = movie.Title, Year = movie.Year.ToString(), IMDBID = movie.IMDBNumber, PluginVersion = TraktSettings.Version, MediaCenter = "Mediaportal", MediaCenterVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(), MediaCenterBuildDate = String.Empty, UserName = username, Password = password }; return scrobbleData; }
public static void GetMovieInfoById(int lMovieId, ref IMDBMovie details) { _database.GetMovieInfoById(lMovieId, ref details); }
public void SetDurationProperty(int movieId) { if (RunTime <= 0) { IMDBMovie movie = new IMDBMovie(); VideoDatabase.GetMovieInfoById(movieId, ref movie); RunTime = movie.RunTime; } GUIPropertyManager.SetProperty("#runtime", RunTime + " " + GUILocalizeStrings.Get(2998) + " (" + Util.Utils.SecondsToHMString(RunTime * 60) + ")"); int duration = VideoDatabase.GetMovieDuration(movieId); if (duration <= 0) { GUIPropertyManager.SetProperty("#videoruntime", string.Empty); } else { GUIPropertyManager.SetProperty("#videoruntime", Util.Utils.SecondsToHMSString(duration)); } }
private void SetLatestMovieProperties() { string strSQL = "SELECT * FROM movieinfo ORDER BY dateAdded DESC LIMIT 3"; ArrayList movies = new ArrayList(); GetMoviesByFilter(strSQL, out movies, false, true, false, false); IMDBMovie movie1 = new IMDBMovie(); IMDBMovie movie2 = new IMDBMovie(); IMDBMovie movie3 = new IMDBMovie(); GUIPropertyManager.SetProperty("#myvideos.latest1.enabled", "false"); GUIPropertyManager.SetProperty("#myvideos.latest2.enabled", "false"); GUIPropertyManager.SetProperty("#myvideos.latest3.enabled", "false"); if (movies.Count > 0) { movie1 = (IMDBMovie) movies[0]; // Movie 1 GUIPropertyManager.SetProperty("#myvideos.latest1.genre", movie1.Genre.Replace(" /", ",")); // string poster = string.Empty; string titleExt = movie1.Title + "{" + movie1.ID + "}"; poster = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); GUIPropertyManager.SetProperty("#myvideos.latest1.thumb", poster); // GUIPropertyManager.SetProperty("#myvideos.latest1.title", movie1.Title); GUIPropertyManager.SetProperty("#myvideos.latest1.year", movie1.Year.ToString()); // DateTime dateAdded; DateTime.TryParseExact(movie1.DateAdded, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out dateAdded); GUIPropertyManager.SetProperty("#myvideos.latest1.dateAdded", dateAdded.ToShortDateString()); // GUIPropertyManager.SetProperty("#myvideos.latest1.runtime", movie1.RunTime + " " + GUILocalizeStrings.Get(2998) + " (" + Util.Utils.SecondsToHMString(movie1.RunTime * 60) + ")"); GUIPropertyManager.SetProperty("#myvideos.latest1.enabled", "true"); if (movies.Count > 1) { movie2 = (IMDBMovie) movies[1]; // Movie 2 GUIPropertyManager.SetProperty("#myvideos.latest2.genre", movie2.Genre.Replace(" /", ",")); // poster = string.Empty; titleExt = movie2.Title + "{" + movie2.ID + "}"; poster = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); GUIPropertyManager.SetProperty("#myvideos.latest2.thumb", poster); // GUIPropertyManager.SetProperty("#myvideos.latest2.title", movie2.Title); GUIPropertyManager.SetProperty("#myvideos.latest2.year", movie2.Year.ToString()); // DateTime.TryParseExact(movie2.DateAdded, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out dateAdded); GUIPropertyManager.SetProperty("#myvideos.latest2.dateAdded", dateAdded.ToShortDateString()); // GUIPropertyManager.SetProperty("#myvideos.latest2.runtime", movie2.RunTime + " " + GUILocalizeStrings.Get(2998) + " (" + Util.Utils.SecondsToHMString(movie2.RunTime * 60) + ")"); GUIPropertyManager.SetProperty("#myvideos.latest2.enabled", "true"); } if (movies.Count > 2) { movie3 = (IMDBMovie) movies[2]; // Movie 3 GUIPropertyManager.SetProperty("#myvideos.latest3.genre", movie3.Genre.Replace(" /", ",")); // poster = string.Empty; titleExt = movie3.Title + "{" + movie3.ID + "}"; poster = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); GUIPropertyManager.SetProperty("#myvideos.latest3.thumb", poster); // GUIPropertyManager.SetProperty("#myvideos.latest3.title", movie3.Title); GUIPropertyManager.SetProperty("#myvideos.latest3.year", movie3.Year.ToString()); // DateTime.TryParseExact(movie3.DateAdded, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out dateAdded); GUIPropertyManager.SetProperty("#myvideos.latest3.dateAdded", dateAdded.ToShortDateString()); // GUIPropertyManager.SetProperty("#myvideos.latest3.runtime", movie3.RunTime + " " + GUILocalizeStrings.Get(2998) + " (" + Util.Utils.SecondsToHMString(movie3.RunTime * 60) + ")"); GUIPropertyManager.SetProperty("#myvideos.latest3.enabled", "true"); } } }
public bool MakeNfo (int movieId) { string moviePath = string.Empty; string movieFile = string.Empty; ArrayList movieFiles = new ArrayList(); ArrayList nfoFiles = new ArrayList(); string nfoFile = string.Empty; int fileCounter = 0; try { // Get files GetFilesForMovie(movieId, ref movieFiles); foreach (string file in movieFiles) { if (!File.Exists(file)) { return false; } movieFile = file; Util.Utils.Split(movieFile, out moviePath, out movieFile); // Check for DVD folder if (movieFile.ToUpperInvariant() == "VIDEO_TS.IFO" || movieFile.ToUpperInvariant() == "INDEX.BDMV") { // Remove \VIDEO_TS from directory structure string directoryDVD = moviePath.Substring(0, moviePath.LastIndexOf(@"\")); if (Directory.Exists(directoryDVD)) { moviePath = directoryDVD; movieFile = directoryDVD; } } else { if (fileCounter > 0) { return true; } } // remove stack endings (CDx..) form filename Util.Utils.RemoveStackEndings(ref movieFile); // Remove file extension movieFile = Util.Utils.GetFilename(movieFile, true).Trim(); // Add nfo extension nfoFile = moviePath + @"\" + movieFile + ".nfo"; Util.Utils.FileDelete(nfoFile); nfoFiles.Add(nfoFile); //} IMDBMovie movieDetails = new IMDBMovie(); GetMovieInfoById(movieId, ref movieDetails); // Prepare XML XmlDocument doc = new XmlDocument(); XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null); // Main tag XmlNode mainNode = doc.CreateElement("movie"); XmlNode subNode; #region Movie fields // Filenames foreach (string strMovieFile in movieFiles) { CreateXmlNode(mainNode, doc, "filenameandpath", strMovieFile); } // Title CreateXmlNode(mainNode, doc, "title", movieDetails.Title); // Sort Title if (!string.IsNullOrEmpty(movieDetails.SortTitle)) { CreateXmlNode(mainNode, doc, "sorttitle", movieDetails.SortTitle); } else { CreateXmlNode(mainNode, doc, "sorttitle", movieDetails.Title); } // movie IMDB number CreateXmlNode(mainNode, doc, "imdb", movieDetails.IMDBNumber); CreateXmlNode(mainNode, doc, "id", movieDetails.IMDBNumber); // Language CreateXmlNode(mainNode, doc, "language", movieDetails.Language); // Country CreateXmlNode(mainNode, doc, "country", movieDetails.Country); // Year CreateXmlNode(mainNode, doc, "year", movieDetails.Year.ToString()); // Rating CreateXmlNode(mainNode, doc, "rating", movieDetails.Rating.ToString().Replace(",", ".")); // Runtime CreateXmlNode(mainNode, doc, "runtime", movieDetails.RunTime.ToString()); // MPAA CreateXmlNode(mainNode, doc, "mpaa", movieDetails.MPARating); // Votes CreateXmlNode(mainNode, doc, "votes", movieDetails.Votes); // TOp 250 CreateXmlNode(mainNode, doc, "top250", movieDetails.Top250.ToString()); // Studio CreateXmlNode(mainNode, doc, "studio", movieDetails.Studios); // Director CreateXmlNode(mainNode, doc, "director", movieDetails.Director); // Director imdbId CreateXmlNode(mainNode, doc, "directorimdb", GetActorImdbId(movieDetails.ID)); // Credits CreateXmlNode(mainNode, doc, "credits", movieDetails.WritingCredits); // Tagline CreateXmlNode(mainNode, doc, "tagline", movieDetails.TagLine); // Plot outline (short one) CreateXmlNode(mainNode, doc, "outline", movieDetails.PlotOutline); // Plot - long CreateXmlNode(mainNode, doc, "plot", movieDetails.Plot); // Review CreateXmlNode(mainNode, doc, "review", movieDetails.UserReview); // Watched string watched = "false"; if (movieDetails.Watched > 0) { watched = "true"; } CreateXmlNode(mainNode, doc, "watched", watched); // Watched count int percent = 0; int watchedCount = 0; GetMovieWatchedStatus(movieId, out percent, out watchedCount); CreateXmlNode(mainNode, doc, "playcount", watchedCount.ToString()); // Poster string titleExt = movieDetails.Title + "{" + movieId + "}"; string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); string coverFilename = moviePath + @"\" + movieFile + ".jpg"; if (File.Exists(largeCoverArtImage)) { try { File.Copy(largeCoverArtImage, coverFilename, true); File.SetAttributes(coverFilename, FileAttributes.Normal); CreateXmlNode(mainNode, doc, "thumb", movieFile + ".jpg"); } catch (Exception ex) { Log.Info("VideoDatabase: Error in creating nfo - poster node:{0}", ex.Message); } } // Fanart string faFile = string.Empty; subNode = doc.CreateElement("fanart"); for (int i = 0; i < 5; i++) { FanArt.GetFanArtfilename(movieId, i, out faFile); string index = string.Empty; if (File.Exists(faFile)) { if (i > 0) { index = i.ToString(); } try { string faFilename = moviePath + @"\" + movieFile + "-fanart" + index + ".jpg"; File.Copy(faFile, faFilename, true); File.SetAttributes(faFilename, FileAttributes.Normal); CreateXmlNode(subNode, doc, "thumb", movieFile + "-fanart" + index + ".jpg"); } catch (Exception ex) { Log.Info("VideoDatabas: Error in creating nfo - fanart section:{0}", ex.Message); } } } mainNode.AppendChild(subNode); // Genre string szGenres = movieDetails.Genre; if (szGenres.IndexOf("/") >= 0 || szGenres.IndexOf("|") >= 0) { Tokens f = new Tokens(szGenres, new[] {'/', '|'}); foreach (string strGenre in f) { if (!string.IsNullOrEmpty(strGenre)) { CreateXmlNode(mainNode, doc, "genre", strGenre.Trim()); } } } else { CreateXmlNode(mainNode, doc, "genre", movieDetails.Genre); } // Cast ArrayList castList = new ArrayList(); GetActorsByMovieID(movieId, ref castList); foreach (string actor in castList) { IMDBActor actorInfo = new IMDBActor(); subNode = doc.CreateElement("actor"); char[] splitter = {'|'}; string[] temp = actor.Split(splitter); actorInfo = GetActorInfo(Convert.ToInt32(temp[0])); CreateXmlNode(subNode, doc, "name", temp[1]); CreateXmlNode(subNode, doc, "role", temp[3]); CreateXmlNode(subNode, doc, "imdb", temp[2]); if (actorInfo != null) { CreateXmlNode(subNode, doc, "thumb", actorInfo.ThumbnailUrl); CreateXmlNode(subNode, doc, "birthdate", actorInfo.DateOfBirth); CreateXmlNode(subNode, doc, "birthplace", actorInfo.PlaceOfBirth); CreateXmlNode(subNode, doc, "deathdate", actorInfo.DateOfDeath); CreateXmlNode(subNode, doc, "deathplace", actorInfo.PlaceOfDeath); CreateXmlNode(subNode, doc, "minibiography", actorInfo.MiniBiography); CreateXmlNode(subNode, doc, "biography", actorInfo.Biography); } mainNode.AppendChild(subNode); } // User groups ArrayList userGroups = new ArrayList(); GetMovieUserGroups(movieId, userGroups); if (userGroups.Count > 0) { foreach (string userGroup in userGroups) { CreateXmlNode(mainNode, doc, "set", userGroup); } } // Trailer CreateXmlNode(mainNode, doc, "trailer", string.Empty); #endregion // End and save doc.AppendChild(mainNode); doc.InsertBefore(xmldecl, mainNode); doc.Save(nfoFile); fileCounter++; } } catch(Exception ex) { Log.Info("VideoDatabase: Error in creating nfo file:{0} Error:{1}", nfoFile ,ex.Message); return false; } return true; }
public void ImportNfoUsingVideoFile(string videoFile, bool skipExisting, bool refreshdbOnly) { try { string nfoFile = string.Empty; string path = string.Empty; bool isbdDvd = false; string nfoExt = ".nfo"; if (videoFile.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO", StringComparison.InvariantCultureIgnoreCase) >= 0) { //DVD folder path = videoFile.Substring(0, videoFile.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO", StringComparison.InvariantCultureIgnoreCase)); isbdDvd = true; } else if (videoFile.ToUpper().IndexOf(@"\BDMV\INDEX.BDMV", StringComparison.InvariantCultureIgnoreCase) >= 0) { //BD folder path = videoFile.Substring(0, videoFile.ToUpper().IndexOf(@"\BDMV\INDEX.BDMV", StringComparison.InvariantCultureIgnoreCase)); isbdDvd = true; } if (isbdDvd) { string cleanFile = string.Empty; cleanFile = Path.GetFileNameWithoutExtension(videoFile); Util.Utils.RemoveStackEndings(ref cleanFile); nfoFile = path + @"\" + cleanFile + nfoExt; if (!File.Exists(nfoFile)) { cleanFile = Path.GetFileNameWithoutExtension(path); Util.Utils.RemoveStackEndings(ref cleanFile); nfoFile = path + @"\" + cleanFile + nfoExt; } } else { string cleanFile = string.Empty; string strPath, strFilename; DatabaseUtility.Split(videoFile, out strPath, out strFilename); cleanFile = strFilename; Util.Utils.RemoveStackEndings(ref cleanFile); cleanFile = strPath + cleanFile; nfoFile = Path.ChangeExtension(cleanFile, nfoExt); } Log.Debug("Importing nfo:{0} using video file:{1}", nfoFile, videoFile); if (!File.Exists(nfoFile)) { return; } IMDBMovie movie = new IMDBMovie(); int id = GetMovieInfo(videoFile, ref movie); if (skipExisting && id > 0) { movie = null; return; } ImportNfo(nfoFile, skipExisting, refreshdbOnly); movie = null; } catch (Exception ex) { Log.Error("Error importing nfo for file {0} Error:{1} ", videoFile, ex); } }
public void GetIndexByFilter(string sql, bool filterNonWordChar, out ArrayList movieList) { movieList = new ArrayList(); try { if (null == m_db) { return; } SQLiteResultSet results = GetResults(sql); bool nonWordCharFound = false; int nwCount = 0; // Count nowWord items if (filterNonWordChar) { for (int i = 0; i < results.Rows.Count; i++) { SQLiteResultSet.Row fields = results.Rows[i]; if (Regex.Match(fields.fields[0], @"\W|\d").Success) { int iCount = Convert.ToInt32(fields.fields[1]); nwCount = nwCount + iCount; } } } for (int i = 0; i < results.Rows.Count; i++) { IMDBMovie movie = new IMDBMovie(); SQLiteResultSet.Row fields = results.Rows[i]; string value = fields.fields[0]; int countN = Convert.ToInt32(fields.fields[1]); if (filterNonWordChar && Regex.Match(fields.fields[0], @"\W|\d").Success) { if (!nonWordCharFound) { value = "#"; nonWordCharFound = true; countN = nwCount; } else { continue; } } movie.Title = value; movie.RunTime = countN; movieList.Add(movie); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void GetRandomMoviesByPath(string strPath1, ref ArrayList movies, int limit) { try { string strPath = strPath1; if (strPath.Length > 0) { if (strPath[strPath.Length - 1] == '/' || strPath[strPath.Length - 1] == '\\') { strPath = strPath.Substring(0, strPath.Length - 1); } } DatabaseUtility.RemoveInvalidChars(ref strPath); movies.Clear(); if (null == m_db) { return; } int lPathId = GetPath(strPath); if (lPathId < 0) { return; } string strSQL = String.Format("SELECT * FROM files,movieinfo WHERE files.idpath={0} AND files.idMovie=movieinfo.idMovie ORDER BY RANDOM() LIMIT {1}", lPathId, limit); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } for (int iRow = 0; iRow < results.Rows.Count; iRow++) { IMDBMovie details = new IMDBMovie(); SetMovieDetails(ref details, iRow, results); movies.Add(details); } } catch (ThreadAbortException) { // Will be logged in thread main code } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void GetRandomMoviesByActor(string strActor1, ref ArrayList movies, int limit) { try { string strActor = strActor1; DatabaseUtility.RemoveInvalidChars(ref strActor); movies.Clear(); if (null == m_db) { return; } string strSQL = String.Format( "SELECT * FROM actorlinkmovie,actors,movie,movieinfo,path WHERE path.idpath=movie.idpath AND actors.idActor=actorlinkmovie.idActor AND actorlinkmovie.idmovie=movie.idmovie AND movieinfo.idmovie=movie.idmovie AND actors.stractor='{0}' ORDER BY RANDOM() LIMIT {1}", strActor, limit); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } for (int iRow = 0; iRow < results.Rows.Count; iRow++) { IMDBMovie details = new IMDBMovie(); SetMovieDetails(ref details, iRow, results); movies.Add(details); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void GetMovies(ref ArrayList movies) { try { movies.Clear(); if (null == m_db) { return; } string strSQL = String.Format( "SELECT * FROM movie,movieinfo,path WHERE movieinfo.idmovie=movie.idmovie AND movie.idpath=path.idpath"); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } for (int iRow = 0; iRow < results.Rows.Count; iRow++) { IMDBMovie details = new IMDBMovie(); SetMovieDetails(ref details, iRow, results); movies.Add(details); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void SetDateWatched(IMDBMovie details) { try { if (null == m_db) { return; } if (details.ID < 0) { return; } if (string.IsNullOrEmpty(details.DateWatched)) { details.DateWatched = "0001-01-01 00:00:00"; } string strSQL = String.Format("UPDATE movieinfo SET dateWatched='{0}' WHERE idMovie={1}", details.DateWatched, details.ID); m_db.Execute(strSQL); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public static int GetMovieInfo(string strFilenameAndPath, ref IMDBMovie details) { return(_database.GetMovieInfo(strFilenameAndPath, ref details)); }
public static void SetMovieInfoById(int lMovieId, ref IMDBMovie details, bool updateTimeStamp) { _database.SetMovieInfoById(lMovieId, ref details, updateTimeStamp); }
public static void SetMovieInfo(string strFilenameAndPath, ref IMDBMovie details) { _database.SetMovieInfo(strFilenameAndPath, ref details); }
private void DeleteSingleMovie(string strFilenameAndPath) { try { int lPathId; int lMovieId; if (null == m_db) { return; } if (GetFile(strFilenameAndPath, out lPathId, out lMovieId, false) < 0) { return; } ClearBookMarksOfMovie(strFilenameAndPath); // Delete files attached to the movie string strSQL = String.Format( "SELECT * FROM path,files WHERE path.idPath=files.idPath AND files.idmovie={0} ORDER BY strFilename", lMovieId); SQLiteResultSet results = m_db.Execute(strSQL); for (int i = 0; i < results.Rows.Count; ++i) { int iFileId; Int32.TryParse(DatabaseUtility.Get(results, i, "files.idFile"), out iFileId); DeleteFile(iFileId); } // Delete covers IMDBMovie movieDetails = new IMDBMovie(); GetMovieInfoById(lMovieId, ref movieDetails); FanArt.DeleteCovers(movieDetails.Title, movieDetails.ID); // Delete fanarts FanArt.DeleteFanarts(movieDetails.ID); // Delete user groups RemoveUserGroupsForMovie(movieDetails.ID); // strSQL = String.Format("DELETE FROM genrelinkmovie WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM actorlinkmovie WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM movieinfo WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM movie WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public static void SetDateWatched(IMDBMovie details) { _database.SetDateWatched(details); }
public void GetMoviesByUserGroup(string strUserGroup, ref ArrayList movies) { try { DatabaseUtility.RemoveInvalidChars(ref strUserGroup); movies.Clear(); if (null == m_db) { return; } string strSQL = String.Format( "SELECT * FROM usergrouplinkmovie,usergroup,movie,movieinfo,path WHERE path.idpath=movie.idpath AND usergrouplinkmovie.idGroup=usergroup.idGroup AND usergrouplinkmovie.idmovie=movie.idmovie AND movieinfo.idmovie=movie.idmovie AND usergroup.strGroup='{0}' ORDER BY movieinfo.strTitle ASC", strUserGroup); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } for (int iRow = 0; iRow < results.Rows.Count; iRow++) { IMDBMovie details = new IMDBMovie(); SetMovieDetails(ref details, iRow, results); movies.Add(details); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public static void UpdateCDLabel(IMDBMovie movieDetails, string CDlabel) { _database.UpdateCDLabel(movieDetails, CDlabel); }
public void GetRandomMoviesByYear(string strYear, ref ArrayList movies, int limit) { try { int iYear; Int32.TryParse(strYear, out iYear); movies.Clear(); if (null == m_db) { return; } string strSQL = String.Format( "SELECT * FROM movie,movieinfo,path WHERE path.idpath=movie.idpath AND movieinfo.idmovie=movie.idmovie AND movieinfo.iYear={0} ORDER BY RANDOM() LIMIT {1}", iYear, limit); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } for (int iRow = 0; iRow < results.Rows.Count; iRow++) { IMDBMovie details = new IMDBMovie(); SetMovieDetails(ref details, iRow, results); movies.Add(details); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void SetMovieInfo(string strFilenameAndPath, ref IMDBMovie details) { if (strFilenameAndPath.Length == 0) { return; } int lMovieId = GetMovie(strFilenameAndPath, true); if (lMovieId < 0) { return; } details.ID = lMovieId; SetMovieInfoById(lMovieId, ref details); string strPath, strFileName; DatabaseUtility.Split(strFilenameAndPath, out strPath, out strFileName); details.Path = strPath; details.File = strFileName; }
// Changed - added user review public void GetMoviesByFilter(string sql, out ArrayList movies, bool actorTable, bool movieinfoTable, bool genreTable, bool usergroupTable) { movies = new ArrayList(); try { if (null == m_db) { return; } SQLiteResultSet results = GetResults(sql); IMDBMovie movie; for (int i = 0; i < results.Rows.Count; i++) { movie = new IMDBMovie(); SQLiteResultSet.Row fields = results.Rows[i]; if (actorTable && !movieinfoTable) { movie.Actor = fields.fields[1]; movie.ActorID = (int)Math.Floor(0.5d + Double.Parse(fields.fields[0])); } if (genreTable && !movieinfoTable) { movie.SingleGenre = fields.fields[1]; movie.GenreID = (int)Math.Floor(0.5d + Double.Parse(fields.fields[0])); } if (usergroupTable && !movieinfoTable) { movie.SingleUserGroup = fields.fields[1]; movie.UserGroupID = (int)Math.Floor(0.5d + Double.Parse(fields.fields[0])); } if (movieinfoTable) { SetMovieDetails(ref movie, i, results); // FanArt search need this (for database GUI view) // Share view is handled in GUIVideoFiles class) ArrayList files = new ArrayList(); GetFilesForMovie(movie.ID, ref files); if (files.Count > 0) { // We need only first file if there is multiple files for one movie, fanart class will handle filename movie.File = files[0].ToString(); } } movies.Add(movie); } } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void SetMovieInfoById(int lMovieId, ref IMDBMovie details) { SetMovieInfoById(lMovieId, ref details, false); }
public void UpdateCDLabel(IMDBMovie movieDetails, string CDlabel) { if (movieDetails == null) { return; } try { string sql = String.Format("SELECT idPath FROM path WHERE cdlabel = '{0}'", movieDetails.CDLabel); SQLiteResultSet results = m_db.Execute(sql); int idPath; Int32.TryParse(DatabaseUtility.Get(results, 0, "idPath"), out idPath); sql = String.Format("UPDATE path SET cdlabel = '{0}' WHERE idPath = '{1}'", CDlabel, idPath); results = m_db.Execute(sql); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
public void SetMovieInfoById(int lMovieId, ref IMDBMovie details, bool updateTimeStamp) { try { details.ID = lMovieId; IMDBMovie details1 = details; IMDBMovie existingDetails = new IMDBMovie(); VideoDatabase.GetMovieInfoById(details1.ID, ref existingDetails); // Cast string strLine = details1.Cast; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Cast = strLine; // Director strLine = details1.Director; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Director = strLine; // add director Id int lDirector = - 1; if (details1.DirectorID < 1 && !string.IsNullOrEmpty(details1.Director)) { lDirector = AddActor("", details1.Director); AddActorToMovie(details1.ID, lDirector, GUILocalizeStrings.Get(199).Replace(":", string.Empty)); if (!CheckMovieImdbId(details1.IMDBNumber)) { // Add actors from cast ArrayList vecActors = new ArrayList(); ArrayList vecRoles = new ArrayList(); if (details1.Cast != Strings.Unknown) { string castFix = details1.Cast.Replace("''", "'"); char[] splitter = { '\n', ',' }; string[] actors = castFix.Split(splitter); for (int i = 0; i < actors.Length; ++i) { int pos = actors[i].IndexOf(" as "); string actor = actors[i]; string role = string.Empty; if (pos >= 0) { if (actor.Length >= pos + 4) { role = actor.Substring(pos + 4); } actor = actors[i].Substring(0, pos); } actor = actor.Trim(); role = role.Trim(); int lActorId = AddActor(string.Empty, actor); vecActors.Add(lActorId); vecRoles.Add(role); } } for (int i = 0; i < vecActors.Count; i++) { AddActorToMovie(lMovieId, (int)vecActors[i], (string)vecRoles[i]); } } } else { lDirector = details1.DirectorID; } // Plot strLine = details1.Plot; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Plot = strLine; // User Review strLine = details1.UserReview; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.UserReview = strLine; // Plot outline strLine = details1.PlotOutline; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.PlotOutline = strLine; // Tagline strLine = details1.TagLine; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.TagLine = strLine; // Cover strLine = details1.ThumbURL; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.ThumbURL = strLine; // Fanart strLine = details1.FanartURL; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.FanartURL = strLine; // Date Added details1.DateAdded = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // Date Watched if (details1.DateWatched == string.Empty && existingDetails.ID >= 0) { details1.DateWatched = existingDetails.DateWatched; } if (string.IsNullOrEmpty(details1.DateWatched)) { details1.DateWatched = "0001-01-01 00:00:00"; } // Watched status if (details1.Watched < 1 && existingDetails.ID >= 0) { details1.Watched = existingDetails.Watched; } // Search string strLine = details1.SearchString; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.SearchString = strLine; // Title strLine = details1.Title.Trim(); DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Title = strLine; // SortTtitle strLine = details1.SortTitle.Trim(); if (!string.IsNullOrEmpty(strLine)) { DatabaseUtility.RemoveInvalidChars(ref strLine); details1.SortTitle = strLine; } else { details1.SortTitle = details1.Title; } // Votes strLine = details1.Votes; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Votes = strLine; // Writers strLine = details1.WritingCredits; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.WritingCredits = strLine; // Genres //Clear old genres link for movie RemoveGenresForMovie(lMovieId); strLine = details1.Genre; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Genre = strLine; // IMDB Movie ID strLine = details1.IMDBNumber; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.IMDBNumber = strLine; // MPAA Rating strLine = details1.MPARating; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.MPARating = strLine; // Studios strLine = details1.Studios; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Studios = strLine; // Country strLine = details1.Country; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Country = strLine; // Language strLine = details1.Language; DatabaseUtility.RemoveInvalidChars(ref strLine); details1.Language = strLine; // Last update if (updateTimeStamp) { details1.LastUpdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else { details1.LastUpdate = existingDetails.LastUpdate; } // add all genres string szGenres = details.Genre; ArrayList vecGenres = new ArrayList(); if (szGenres != Strings.Unknown) { if (szGenres.IndexOf("/") >= 0 || szGenres.IndexOf("|") >= 0) { Tokens f = new Tokens(szGenres, new[] {'/', '|'}); foreach (string strGenre in f) { strGenre.Trim(); if (!string.IsNullOrEmpty(strGenre)) { int lGenreId = AddGenre(strGenre); vecGenres.Add(lGenreId); } } } else { string strGenre = details.Genre; strGenre.Trim(); int lGenreId = AddGenre(strGenre); vecGenres.Add(lGenreId); } } for (int i = 0; i < vecGenres.Count; ++i) { AddGenreToMovie(lMovieId, (int)vecGenres[i]); } string strRating = String.Format("{0}", details1.Rating); if (strRating == "") { strRating = "0.0"; } string strSQL = String.Format("SELECT * FROM movieinfo WHERE idmovie={0}", lMovieId); // Log.Error("dbs:{0}", strSQL); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { // Insert new movie info - no date watched update strSQL = String.Format( "INSERT INTO movieinfo ( idMovie, idDirector, strPlotOutline, strPlot, strTagLine, strVotes, fRating, strCast, strCredits, iYear, strGenre, strPictureURL, strTitle, IMDBID, mpaa, runtime, iswatched, strUserReview, strFanartURL, strDirector, dateAdded, studios, country, language, lastupdate, strSortTitle) VALUES({0},{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}',{9},'{10}','{11}','{12}','{13}','{14}',{15},{16},'{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}')", lMovieId, lDirector, details1.PlotOutline, details1.Plot, details1.TagLine, details1.Votes, strRating, details1.Cast, details1.WritingCredits, details1.Year, details1.Genre, details1.ThumbURL, details1.Title, details1.IMDBNumber, details1.MPARating, details1.RunTime, details1.Watched, details1.UserReview, details1.FanartURL, details1.Director, details1.DateAdded, details1.Studios, details1.Country, details1.Language, details1.LastUpdate, details1.SortTitle); // Log.Error("dbs:{0}", strSQL); m_db.Execute(strSQL); // Update latest movies SetLatestMovieProperties(); } else { // Update movie info (no dateAdded update) strSQL = String.Format( "UPDATE movieinfo SET idDirector={0}, strPlotOutline='{1}', strPlot='{2}', strTagLine='{3}', strVotes='{4}', fRating='{5}', strCast='{6}',strCredits='{7}', iYear={8}, strGenre='{9}', strPictureURL='{10}', strTitle='{11}', IMDBID='{12}', mpaa='{13}', runtime={14}, iswatched={15} , strUserReview='{16}', strFanartURL='{17}' , strDirector ='{18}', dateWatched='{19}', studios = '{20}', country = '{21}', language = '{22}' , lastupdate = '{23}', strSortTitle = '{24}' WHERE idMovie={25}", lDirector, details1.PlotOutline, details1.Plot, details1.TagLine, details1.Votes, strRating, details1.Cast, details1.WritingCredits, details1.Year, details1.Genre, details1.ThumbURL, details1.Title, details1.IMDBNumber, details1.MPARating, details1.RunTime, details1.Watched, details1.UserReview, details1.FanartURL, details1.Director, details1.DateWatched ,details1.Studios, details1.Country, details1.Language, details1.LastUpdate, details1.SortTitle, lMovieId); // Log.Error("dbs:{0}", strSQL); m_db.Execute(strSQL); } VideoDatabase.GetMovieInfoById(details1.ID, ref details1); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} src:{2}, stack:{1}", ex.Message, ex.Source, ex.StackTrace); Open(); } }
public void ImportNfo(string nfoFile, bool skipExisting, bool refreshdbOnly) { IMDBMovie movie = new IMDBMovie(); bool isMovieFolder = Util.Utils.IsFolderDedicatedMovieFolder(Path.GetFullPath(nfoFile)); bool useInternalNfoScraper = false; using (Profile.Settings xmlreader = new Profile.MPSettings()) { // Use only nfo scrapper useInternalNfoScraper = xmlreader.GetValueAsBool("moviedatabase", "useonlynfoscraper", false); } try { XmlDocument doc = new XmlDocument(); doc.Load(nfoFile); Log.Debug("Importing nfo file:{0}", nfoFile); if (doc.DocumentElement != null) { int id = -1; XmlNodeList movieList = doc.DocumentElement.SelectNodes("/movie"); if (movieList == null) { Log.Debug("Movie tag for nfo file:{0} not exist. Nfo skipped.", nfoFile); return; } foreach (XmlNode nodeMovie in movieList) { string genre = string.Empty; string cast = string.Empty; string path = string.Empty; string nfofileName = string.Empty; #region nodes XmlNode nodeTitle = nodeMovie.SelectSingleNode("title"); XmlNode nodeSortTitle = nodeMovie.SelectSingleNode("sorttitle"); XmlNode nodeRating = nodeMovie.SelectSingleNode("rating"); XmlNode nodeYear = nodeMovie.SelectSingleNode("year"); XmlNode nodeDuration = nodeMovie.SelectSingleNode("runtime"); XmlNode nodePlotShort = nodeMovie.SelectSingleNode("outline"); XmlNode nodePlot = nodeMovie.SelectSingleNode("plot"); XmlNode nodeTagline = nodeMovie.SelectSingleNode("tagline"); XmlNode nodeDirector = nodeMovie.SelectSingleNode("director"); XmlNode nodeDirectorImdb = nodeMovie.SelectSingleNode("directorimdb"); XmlNode nodeImdbNumber = nodeMovie.SelectSingleNode("imdb"); XmlNode nodeIdImdbNumber = nodeMovie.SelectSingleNode("id"); XmlNode nodeMpaa = nodeMovie.SelectSingleNode("mpaa"); XmlNode nodeTop250 = nodeMovie.SelectSingleNode("top250"); XmlNode nodeVotes = nodeMovie.SelectSingleNode("votes"); XmlNode nodeStudio = nodeMovie.SelectSingleNode("studio"); XmlNode nodePlayCount = nodeMovie.SelectSingleNode("playcount"); XmlNode nodeWatched = nodeMovie.SelectSingleNode("watched"); XmlNode nodeFanart = nodeMovie.SelectSingleNode("fanart"); XmlNode nodePoster = nodeMovie.SelectSingleNode("thumb"); XmlNode nodeLanguage = nodeMovie.SelectSingleNode("language"); XmlNode nodeCountry = nodeMovie.SelectSingleNode("country"); XmlNode nodeReview = nodeMovie.SelectSingleNode("review"); XmlNode nodeCredits = nodeMovie.SelectSingleNode("credits"); #endregion #region Moviefiles // Get path from *.nfo file) Util.Utils.Split(nfoFile, out path, out nfofileName); // Movie filename to search from gathered files from nfo path nfofileName = Util.Utils.GetFilename(nfofileName, true); // Get all video files from nfo path ArrayList files = new ArrayList(); GetVideoFiles(path, ref files); bool isDvdBdFolder = false; foreach (String file in files) { //Log.Debug("Import nfo-processing video file:{0} (Total files: {1})", file, files.Count); string logFilename = Path.GetFileName(file); if ((file.ToUpperInvariant().Contains("VIDEO_TS.IFO") || file.ToUpperInvariant().Contains("INDEX.BDMV")) && files.Count == 1) { var pattern = Util.Utils.StackExpression(); int stackSequence = -1; // seq 0 = [x-y], seq 1 = CD1, Part1.... int digit = 0; for (int i = 0; i < pattern.Length; i++) { if (pattern[i].IsMatch(file)) { digit = Convert.ToInt16(pattern[i].Match(file).Groups["digit"].Value); stackSequence = i; break; } } if (digit > 1) { Log.Debug("Import nfo-file: {0} is stack part.", file); string filename; string tmpPath = string.Empty; DatabaseUtility.Split(file, out path, out filename); try { if (stackSequence == 0) { string strReplace = "[" + digit; int stackIndex = path.LastIndexOf(strReplace); tmpPath = path.Remove(stackIndex, 2); tmpPath = tmpPath.Insert(stackIndex, "[1"); } else { int stackIndex = path.LastIndexOf(digit.ToString()); tmpPath = path.Remove(stackIndex, 1); tmpPath = tmpPath.Insert(stackIndex, "1"); } int movieId = VideoDatabase.GetMovieId(tmpPath + filename); int pathId = VideoDatabase.AddPath(path); Log.Debug("Import nfo-Adding file: {0}", logFilename); VideoDatabase.AddFile(movieId, pathId, filename); return; } catch(Exception ex) { Log.Error("Import nfo error-stack check for path {0} Error: {1}", path, ex.Message); return; } } id = VideoDatabase.AddMovie(file, true); movie.ID = id; isDvdBdFolder = true; } else { string tmpFile = string.Empty; string tmpPath = string.Empty; // Read filename Util.Utils.Split(file, out tmpPath, out tmpFile); // Remove extension tmpFile = Util.Utils.GetFilename(tmpFile, true); // Remove stack endings (CD1...) Util.Utils.RemoveStackEndings(ref tmpFile); Util.Utils.RemoveStackEndings(ref nfofileName); // Check and add to vdb and get movieId if (tmpFile.Equals(nfofileName, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Import nfo-Adding file: {0}", logFilename); id = VideoDatabase.AddMovie(file, true); movie.ID = id; } else if (isMovieFolder && tmpPath.Length > 0) // Every movie in it's own folder, compare by folder name { try { tmpPath = tmpPath.Substring(tmpPath.LastIndexOf(@"\") + 1).Trim(); if (tmpPath.Equals(nfofileName, StringComparison.InvariantCultureIgnoreCase) || nfofileName.ToLowerInvariant() == "movie") { Log.Debug("Import nfo-Adding file: {0}", logFilename); id = VideoDatabase.AddMovie(file, true); movie.ID = id; } else { Log.Debug("Import nfo-Skipping file:{0}", logFilename); } } catch (Exception ex) { Log.Error("Import nfo-Error comparing path name. File:{0} Err.:{1}", file, ex.Message); } } else { Log.Debug("Import nfo-Skipping file: {0}", logFilename); } } } #endregion #region Check for existing movie or refresh database only GetMovieInfoById(id, ref movie); if (skipExisting && !movie.IsEmpty || refreshdbOnly && movie.IsEmpty || id < 1) { Log.Debug("Import nfo-Skipping import for movieId = {0}).", id); return; } movie = new IMDBMovie(); movie.ID = id; #endregion #region Genre XmlNodeList genres = nodeMovie.SelectNodes("genre"); foreach (XmlNode nodeGenre in genres) { if (nodeGenre.InnerText != null) { if (genre.Length > 0) { genre += " / "; } genre += nodeGenre.InnerText; } } if (string.IsNullOrEmpty(genre)) { genres = nodeMovie.SelectNodes("genres/genre"); foreach (XmlNode nodeGenre in genres) { if (nodeGenre.InnerText != null) { if (genre.Length > 0) { genre += " / "; } genre += nodeGenre.InnerText; } } } movie.Genre = genre; #endregion #region Credits (Writers) // Writers if (nodeCredits != null) { movie.WritingCredits = nodeCredits.InnerText; } #endregion #region DateAdded movie.DateAdded = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); #endregion #region Title // Title if (nodeTitle != null) { movie.Title = nodeTitle.InnerText; } #endregion #region Sort Title // SortTitle if (nodeSortTitle != null) { if (!string.IsNullOrEmpty(nodeTitle.InnerText)) { movie.SortTitle = nodeSortTitle.InnerText; } else { movie.SortTitle = movie.Title; } } #endregion #region Language // Title if (nodeLanguage != null) { movie.Language = nodeLanguage.InnerText; } #endregion #region Country // Title if (nodeCountry != null) { movie.Country = nodeCountry.InnerText; } #endregion #region IMDB number // IMDB number if (nodeImdbNumber != null) { if (CheckMovieImdbId(nodeImdbNumber.InnerText)) { movie.IMDBNumber = nodeImdbNumber.InnerText; } } if (string.IsNullOrEmpty(movie.IMDBNumber) && nodeIdImdbNumber != null) { if (CheckMovieImdbId(nodeIdImdbNumber.InnerText)) { movie.IMDBNumber = nodeIdImdbNumber.InnerText; } } #endregion #region CD/DVD labels // CD label movie.CDLabel = string.Empty; // DVD label movie.DVDLabel = string.Empty; #endregion #region Director // Director string dirImdb = string.Empty; if (nodeDirectorImdb != null) { dirImdb = nodeDirectorImdb.InnerText; if (!CheckActorImdbId(dirImdb)) { dirImdb = string.Empty; } } if (nodeDirector != null) { movie.Director = nodeDirector.InnerText; movie.DirectorID = VideoDatabase.AddActor(dirImdb, movie.Director); } #endregion #region Studio // Studio if (nodeStudio != null) { movie.Studios = nodeStudio.InnerText; } #endregion #region MPAA // MPAA if (nodeMpaa != null) { movie.MPARating = nodeMpaa.InnerText; } else { movie.MPARating = "NR"; } #endregion #region Plot/Short plot // Plot if (nodePlot != null) { movie.Plot = nodePlot.InnerText; } else { movie.Plot = string.Empty; } // Short plot if (nodePlotShort != null) { movie.PlotOutline = nodePlotShort.InnerText; } else { movie.PlotOutline = string.Empty; } #endregion #region Review // Title if (nodeReview != null) { movie.UserReview = nodeReview.InnerText; } #endregion #region Rating (n.n/10) // Rating if (nodeRating != null) { double rating = 0; if (Double.TryParse(nodeRating.InnerText.Replace(".", ","), out rating)) { movie.Rating = (float) rating; if (movie.Rating > 10.0f) { movie.Rating /= 10.0f; } } } #endregion #region Duration // Duration if (nodeDuration != null) { int runtime = 0; if (Int32.TryParse(nodeDuration.InnerText, out runtime)) { movie.RunTime = runtime; } else { string regex = "(?<h>[0-9]*)h.(?<m>[0-9]*)"; MatchCollection mc = Regex.Matches(nodeDuration.InnerText, regex, RegexOptions.Singleline | RegexOptions.IgnoreCase); if (mc.Count > 0) { foreach (Match m in mc) { int hours = 0; Int32.TryParse(m.Groups["h"].Value, out hours); int minutes = 0; Int32.TryParse(m.Groups["m"].Value, out minutes); hours = hours*60; minutes = hours + minutes; movie.RunTime = minutes; } } else { regex = @"\d*\s*min."; if (Regex.Match(nodeDuration.InnerText, regex, RegexOptions.IgnoreCase).Success) { regex = @"\d*"; int minutes = 0; Int32.TryParse(Regex.Match(nodeDuration.InnerText, regex).Value, out minutes); movie.RunTime = minutes; } } } } else { movie.RunTime = 0; } #endregion #region Tagline // Tagline if (nodeTagline != null) { movie.TagLine = nodeTagline.InnerText; } #endregion #region TOP250 // Top250 if (nodeTop250 != null) { int top250 = 0; Int32.TryParse(nodeTop250.InnerText, out top250); movie.Top250 = top250; } else { movie.Top250 = 0; } #endregion #region votes // Votes if (nodeVotes != null) { movie.Votes = nodeVotes.InnerText; } #endregion #region Watched/watched count // Watched int percent = 0; int watchedCount = 0; GetMovieWatchedStatus(movie.ID, out percent, out watchedCount); if (watchedCount < 1) { if (nodeWatched != null) { if (nodeWatched.InnerText.ToLowerInvariant() == "true" || nodeWatched.InnerText == "1") { movie.Watched = 1; VideoDatabase.SetMovieWatchedStatus(movie.ID, true, 100); } else { movie.Watched = 0; VideoDatabase.SetMovieWatchedStatus(movie.ID, false, 0); } } // Watched count if (nodePlayCount != null) { watchedCount = 0; Int32.TryParse(nodePlayCount.InnerText, out watchedCount); SetMovieWatchedCount(movie.ID, watchedCount); if (watchedCount > 0 && movie.Watched == 0) { movie.Watched = 1; VideoDatabase.SetMovieWatchedStatus(movie.ID, true, 100); } else if (watchedCount == 0 && movie.Watched > 0) { SetMovieWatchedCount(movie.ID, 1); } } } else { movie.Watched = 1; } #endregion #region Year // Year if (nodeYear != null) { int year = 0; Int32.TryParse(nodeYear.InnerText, out year); movie.Year = year; } #endregion #region poster // Poster string thumbJpgFile = string.Empty; string thumbTbnFile = string.Empty; string thumbFolderJpgFile = string.Empty; string thumbFolderTbnFile = string.Empty; string titleExt = movie.Title + "{" + id + "}"; string jpgExt = @".jpg"; string tbnExt = @".tbn"; string folderJpg = @"\folder.jpg"; string folderTbn = @"\folder.tbn"; if (isDvdBdFolder) { thumbJpgFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + jpgExt; thumbTbnFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + tbnExt; thumbFolderJpgFile = path + @"\" + folderJpg; thumbFolderTbnFile = path + @"\" + folderTbn; } else { thumbJpgFile = path + @"\" + nfofileName + jpgExt; thumbTbnFile = path + @"\" + nfofileName + tbnExt; if (isMovieFolder) { thumbFolderJpgFile = path + @"\" + folderJpg; thumbFolderTbnFile = path + @"\" + folderTbn; } } if (nodePoster != null) { // Local source cover if (File.Exists(thumbJpgFile)) { CreateCovers(titleExt, thumbJpgFile, movie); } else if (File.Exists(thumbTbnFile)) { CreateCovers(titleExt, thumbTbnFile, movie); } else if (!string.IsNullOrEmpty(thumbFolderJpgFile) && File.Exists(thumbFolderJpgFile)) { CreateCovers(titleExt, thumbFolderJpgFile, movie); } else if (!string.IsNullOrEmpty(thumbFolderTbnFile) && File.Exists(thumbFolderTbnFile)) { CreateCovers(titleExt, thumbFolderTbnFile, movie); } else if (!nodePoster.InnerText.StartsWith("http:") && File.Exists(nodePoster.InnerText)) { CreateCovers(titleExt, nodePoster.InnerText, movie); } else if (!nodePoster.InnerText.StartsWith("http:") && File.Exists(path + @"\" + nodePoster.InnerText)) { CreateCovers(titleExt, path + @"\" + nodePoster.InnerText, movie); } // web source cover else if (nodePoster.InnerText.StartsWith("http:")) { try { string imageUrl = nodePoster.InnerText; if (imageUrl.Length > 0) { string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); if (!File.Exists(coverArtImage)) { string imageExtension = Path.GetExtension(imageUrl); if (imageExtension == string.Empty) { imageExtension = jpgExt; } string temporaryFilename = "MPTempImage"; temporaryFilename += imageExtension; temporaryFilename = Path.Combine(Path.GetTempPath(), temporaryFilename); Util.Utils.FileDelete(temporaryFilename); Util.Utils.DownLoadAndOverwriteCachedImage(imageUrl, temporaryFilename); if (File.Exists(temporaryFilename)) { if (Util.Picture.CreateThumbnail(temporaryFilename, largeCoverArtImage, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall)) { Util.Picture.CreateThumbnail(temporaryFilename, coverArtImage, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge); } } Util.Utils.FileDelete(temporaryFilename); } } } catch (Exception ex) { Log.Error("Import nfo - Poster node: {0}", ex.Message); } movie.ThumbURL = nodePoster.InnerText; } // MP scrapers cover else { if (movie.ThumbURL == string.Empty && !useInternalNfoScraper) { // IMPAwards IMPAwardsSearch impSearch = new IMPAwardsSearch(); impSearch.SearchCovers(movie.Title, movie.IMDBNumber); if ((impSearch.Count > 0) && (impSearch[0] != string.Empty)) { movie.ThumbURL = impSearch[0]; } // If no IMPAwards lets try TMDB TMDBCoverSearch tmdbSearch = new TMDBCoverSearch(); if (impSearch.Count == 0) { tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber); if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty)) { movie.ThumbURL = tmdbSearch[0]; } } // All fail, last try IMDB if (impSearch.Count == 0 && tmdbSearch.Count == 0) { IMDBSearch imdbSearch = new IMDBSearch(); imdbSearch.SearchCovers(movie.IMDBNumber, true); if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty)) { movie.ThumbURL = imdbSearch[0]; } } } string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); if (movie.ID >= 0) { if (!string.IsNullOrEmpty(movie.ThumbURL)) { Util.Utils.FileDelete(largeCoverArt); Util.Utils.FileDelete(coverArt); } // Save cover thumbs if (!string.IsNullOrEmpty(movie.ThumbURL)) { IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt); } } } } else // Node thumb not exist { if (File.Exists(thumbJpgFile)) { CreateCovers(titleExt, thumbJpgFile, movie); } else if (File.Exists(thumbTbnFile)) { CreateCovers(titleExt, thumbTbnFile, movie); } else if (!string.IsNullOrEmpty(thumbFolderJpgFile) && File.Exists(thumbFolderJpgFile)) { CreateCovers(titleExt, thumbFolderJpgFile, movie); } else if (!string.IsNullOrEmpty(thumbFolderTbnFile) && File.Exists(thumbFolderTbnFile)) { CreateCovers(titleExt, thumbFolderTbnFile, movie); } else if (movie.ThumbURL == string.Empty && !useInternalNfoScraper) { // IMPAwards IMPAwardsSearch impSearch = new IMPAwardsSearch(); impSearch.SearchCovers(movie.Title, movie.IMDBNumber); if ((impSearch.Count > 0) && (impSearch[0] != string.Empty)) { movie.ThumbURL = impSearch[0]; } // If no IMPAwards lets try TMDB TMDBCoverSearch tmdbSearch = new TMDBCoverSearch(); if (impSearch.Count == 0) { tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber); if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty)) { movie.ThumbURL = tmdbSearch[0]; } } // All fail, last try IMDB if (impSearch.Count == 0 && tmdbSearch.Count == 0) { IMDBSearch imdbSearch = new IMDBSearch(); imdbSearch.SearchCovers(movie.IMDBNumber, true); if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty)) { movie.ThumbURL = imdbSearch[0]; } } string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); if (movie.ID >= 0) { if (!string.IsNullOrEmpty(movie.ThumbURL)) { Util.Utils.FileDelete(largeCoverArt); Util.Utils.FileDelete(coverArt); } // Save cover thumbs if (!string.IsNullOrEmpty(movie.ThumbURL)) { IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt); } } } } #endregion #region Fanart // Fanart XmlNodeList fanartNodeList = nodeMovie.SelectNodes("fanart/thumb"); int faIndex = 0; bool faFound = false; string faFile = string.Empty; FanArt fa = new FanArt(); foreach (XmlNode fanartNode in fanartNodeList) { if (fanartNode != null) { faFile = path + @"\" + fanartNode.InnerText; if (File.Exists(faFile)) { fa.GetLocalFanart(id, "file://" + faFile, faIndex); movie.FanartURL = faFile; faFound = true; } } faIndex ++; if (faIndex == 5) { break; } } if (!faFound) { List<string> localFanart = new List<string>(); faIndex = 0; faFile = path + @"\" + nfofileName + "-fanart.jpg"; localFanart.Add(faFile); faFile = path + @"\" + nfofileName + "-backdrop.jpg"; localFanart.Add(faFile); faFile= path + @"\" + "backdrop.jpg"; localFanart.Add(faFile); faFile = path + @"\" + "fanart.jpg"; localFanart.Add(faFile); foreach (string fanart in localFanart) { if (File.Exists(fanart)) { fa.GetLocalFanart(id, "file://" + fanart, faIndex); movie.FanartURL = fanart; faFound = true; break; } } if (!faFound && !useInternalNfoScraper) { fa.GetTmdbFanartByApi(movie.ID, movie.IMDBNumber, string.Empty, false, 1, string.Empty); } } #endregion #region Cast // Cast parse XmlNodeList actorsList = nodeMovie.SelectNodes("actor"); foreach (XmlNode nodeActor in actorsList) { string name = string.Empty; string role = string.Empty; string actorImdbId = string.Empty; string line = string.Empty; XmlNode nodeActorName = nodeActor.SelectSingleNode("name"); XmlNode nodeActorRole = nodeActor.SelectSingleNode("role"); XmlNode nodeActorImdbId = nodeActor.SelectSingleNode("imdb"); XmlNode nodeActorBirthDate = nodeActor.SelectSingleNode("birthdate"); XmlNode nodeActorBirthPlace = nodeActor.SelectSingleNode("birthplace"); XmlNode nodeActorDeathDate = nodeActor.SelectSingleNode("deathdate"); XmlNode nodeActorDeathPlace = nodeActor.SelectSingleNode("deathplace"); XmlNode nodeActorMiniBio = nodeActor.SelectSingleNode("minibiography"); XmlNode nodeActorBiography= nodeActor.SelectSingleNode("biography"); XmlNode nodeActorThumbnail = nodeActor.SelectSingleNode("thumb"); if (nodeActorName != null && nodeActorName.InnerText != null) { name = nodeActorName.InnerText; } if (nodeActorRole != null && nodeActorRole.InnerText != null) { role = nodeActorRole.InnerText; } if (nodeActorImdbId != null) { if (CheckActorImdbId(nodeActorImdbId.InnerText)) { actorImdbId = nodeActorImdbId.InnerText; } } if (!string.IsNullOrEmpty(name)) { if (!string.IsNullOrEmpty(role)) { line = String.Format("{0} as {1}\n", name, role); } else { line = String.Format("{0}\n", name); } cast += line; int actId = VideoDatabase.AddActor(actorImdbId, name); VideoDatabase.AddActorToMovie(id, actId, role); if (CheckActorImdbId(actorImdbId)) { IMDBActor info = new IMDBActor(); info.IMDBActorID = actorImdbId; if (nodeActorBirthDate != null) { info.DateOfBirth = nodeActorBirthDate.InnerText; } if (nodeActorBirthPlace != null) { info.PlaceOfBirth = nodeActorBirthPlace.InnerText; } if (nodeActorDeathDate != null) { info.DateOfDeath = nodeActorDeathDate.InnerText; } if (nodeActorDeathPlace != null) { info.PlaceOfDeath = nodeActorDeathPlace.InnerText; } if (nodeActorMiniBio != null) { info.MiniBiography = nodeActorMiniBio.InnerText; } if (nodeActorBiography != null) { info.Biography = nodeActorBiography.InnerText; } if (info.DateOfBirth != string.Empty || info.PlaceOfBirth != string.Empty|| info.DateOfDeath != string.Empty || info.PlaceOfBirth != string.Empty || info.MiniBiography != string.Empty || info.Biography != string.Empty) { SetActorInfo(actId, info); } } } } // Cast movie.Cast = cast; #endregion #region UserGroups XmlNodeList userGroups = nodeMovie.SelectNodes("set"); foreach (XmlNode nodeUserGroup in userGroups) { string strUserGroup = string.Empty; if (nodeUserGroup != null && nodeUserGroup.InnerText != null) { strUserGroup = nodeUserGroup.InnerText; if (!string.IsNullOrEmpty(strUserGroup)) { int iUserGroup = AddUserGroup(strUserGroup); AddUserGroupToMovie(movie.ID, iUserGroup); } } } #endregion VideoDatabase.SetMovieInfoById(id, ref movie, true); } } } catch (Exception ex) { Log.Error("videodatabase exception error importing nfo file {0}:{1} ", nfoFile, ex.Message); } }
public void DeleteMovieInfoById(long lMovieId) { try { if (null == m_db) { return; } if (lMovieId == -1) { return; } Log.Info("Removing movie:{0}", lMovieId); // Delete movie file stop time data ArrayList files = new ArrayList(); VideoDatabase.GetFilesForMovie((int)lMovieId, ref files); foreach (string file in files) { int fileId = VideoDatabase.GetFileId(file); VideoDatabase.DeleteMovieStopTime(fileId); } IMDBMovie movie = new IMDBMovie(); GetMovieInfoById((int) lMovieId, ref movie); // Delete movie cover FanArt.DeleteCovers(movie.Title, (int) lMovieId); // Delete movie fanart FanArt.DeleteFanarts((int) lMovieId); // Delete user groups for movie RemoveUserGroupsForMovie((int) lMovieId); string strSQL = String.Format("DELETE FROM genrelinkmovie WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM actorlinkmovie WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM movieinfo WHERE idmovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM files WHERE idMovie={0}", lMovieId); m_db.Execute(strSQL); strSQL = String.Format("DELETE FROM movie WHERE idMovie={0}", lMovieId); m_db.Execute(strSQL); // Update latest movies SetLatestMovieProperties(); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
private void CreateCovers(string titleExt, string coverImage, IMDBMovie movie) { movie.ThumbURL = coverImage; string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt); if (Util.Picture.CreateThumbnail(coverImage, largeCoverArt, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall)) { Util.Picture.CreateThumbnail(coverImage, coverArt, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge); } }
public int GetMovieInfo(string strFilenameAndPath, ref IMDBMovie details) { int lMovieId = GetMovie(strFilenameAndPath, false); if (lMovieId < 0) { return -1; } if (!HasMovieInfo(strFilenameAndPath)) { return -1; } GetMovieInfoById(lMovieId, ref details); return lMovieId; }
private void SetMovieDetails(ref IMDBMovie details, int iRow, SQLiteResultSet results) { if (details == null || iRow < 0 || results == null) { return; } double rating = 0; Double.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.fRating"), out rating); details.Rating = (float)rating; if (details.Rating > 10.0f) { details.Rating /= 10.0f; } details.Director = DatabaseUtility.Get(results, iRow, "movieinfo.strDirector").Replace("''", "'"); // Add directorID try { details.DirectorID = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.idDirector")); } catch (Exception) { details.DirectorID = -1; } details.WritingCredits = DatabaseUtility.Get(results, iRow, "movieinfo.strCredits").Replace("''", "'"); details.TagLine = DatabaseUtility.Get(results, iRow, "movieinfo.strTagLine").Replace("''", "'"); details.PlotOutline = DatabaseUtility.Get(results, iRow, "movieinfo.strPlotOutline").Replace("''", "'"); details.Plot = DatabaseUtility.Get(results, iRow, "movieinfo.strPlot").Replace("''", "'"); // Added user review details.UserReview = DatabaseUtility.Get(results, iRow, "movieinfo.strUserReview").Replace("''", "'"); details.Votes = DatabaseUtility.Get(results, iRow, "movieinfo.strVotes"); details.Cast = DatabaseUtility.Get(results, iRow, "movieinfo.strCast").Replace("''", "'"); details.Year = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.iYear")); details.Genre = DatabaseUtility.Get(results, iRow, "movieinfo.strGenre").Trim(); details.ThumbURL = DatabaseUtility.Get(results, iRow, "movieinfo.strPictureURL"); // Fanart details.FanartURL = DatabaseUtility.Get(results, iRow, "movieinfo.strFanartURL"); // Date Added details.DateAdded = DatabaseUtility.Get(results, iRow, "movieinfo.dateAdded"); // Date Watched details.DateWatched = DatabaseUtility.Get(results, iRow, "movieinfo.dateWatched"); details.Title = DatabaseUtility.Get(results, iRow, "movieinfo.strTitle").Replace("''", "'"); details.Path = DatabaseUtility.Get(results, iRow, "path.strPath"); details.DVDLabel = DatabaseUtility.Get(results, iRow, "movie.discid"); details.IMDBNumber = DatabaseUtility.Get(results, iRow, "movieinfo.IMDBID"); Int32 lMovieId = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.idMovie")); details.SearchString = String.Format("{0}", details.Title); details.CDLabel = DatabaseUtility.Get(results, iRow, "path.cdlabel"); details.MPARating = DatabaseUtility.Get(results, iRow, "movieinfo.mpaa"); int runtime = 0; Int32.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.runtime"), out runtime); details.RunTime = runtime; int watched = 0; Int32.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.iswatched"), out watched); details.Watched = watched; details.ID = lMovieId; details.Studios = DatabaseUtility.Get(results, iRow, "movieinfo.studios"); details.Country = DatabaseUtility.Get(results, iRow, "movieinfo.country"); details.Language = DatabaseUtility.Get(results, iRow, "movieinfo.language"); details.LastUpdate = DatabaseUtility.Get(results, iRow, "movieinfo.lastupdate"); details.SortTitle = DatabaseUtility.Get(results, iRow, "movieinfo.strSortTitle").Replace("''", "'"); if (string.IsNullOrEmpty(details.Path) && details.ID > 0) { string strSQL = String.Format( "SELECT path.strPath FROM movie,path WHERE path.idpath=movie.idpath AND movie.idMovie = {0}", details.ID); results = m_db.Execute(strSQL); details.Path = DatabaseUtility.Get(results, 0, "path.strPath"); } if (details.ID > 0) { int percent = 0; int watchedCount = 0; GetMovieWatchedStatus(details.ID, out percent, out watchedCount); details.WatchedPercent = percent; details.WatchedCount = watchedCount; string movieFilename = string.Empty; ArrayList files = new ArrayList(); GetFilesForMovie(details.ID, ref files); int duration = GetMovieDuration(details.ID); details.Duration = duration; if (files.Count > 0) { movieFilename = (string) files[0]; } details.VideoFileName = movieFilename; details.VideoFilePath = details.Path; VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo(); GetVideoFilesMediaInfo(movieFilename, ref mInfo, false); details.MediaInfo = mInfo; } }
// Changed Added DirectorID, userrev, fanart public void GetMovieInfoById(int lMovieId, ref IMDBMovie details) { try { string strSQL = String.Format( "SELECT * FROM movieinfo,movie,path WHERE path.idpath=movie.idpath AND movie.idMovie=movieinfo.idMovie AND movieinfo.idmovie={0}", lMovieId); SQLiteResultSet results = m_db.Execute(strSQL); if (results.Rows.Count == 0) { return; } SetMovieDetails(ref details, 0, results); } catch (ThreadAbortException) { // Will be logged in thread main code } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }
/// <summary> /// this method switches between the different databases to fetche the search result into movieDetails /// </summary> public bool GetDetails(IMDBUrl url, ref IMDBMovie movieDetails) { try { MovieInfoDatabase currentDB = null; foreach (MovieInfoDatabase db in _databaseList) { if (db.ID == url.Database) { currentDB = db; } } if (currentDB == null) { return false; } if (currentDB.Grabber == null) { return false; } currentDB.Grabber.GetDetails(url, ref movieDetails); return true; } catch (Exception ex) { Log.Error("Movie database lookup GetDetails() - grabber: {0}, message : {1}", url.Database, ex.Message); return false; } }
public void SetWatched(IMDBMovie details) { try { if (null == m_db) { return; } if (details.ID < 0) { return; } string strSQL = String.Format("UPDATE movieinfo SET iswatched={0}, datewatched = '{1}' WHERE idMovie={2}", details.Watched, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), details.ID); m_db.Execute(strSQL); } catch (Exception ex) { Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } }