// Removes Artwork From a Movie public void RemoveOrphanArtwork() { float count = 0; float total = DBMovieInfo.GetAll().Count; foreach (DBMovieInfo currMovie in DBMovieInfo.GetAll()) { //OnProgress(count / total); count++; if (currMovie.ID == null) { continue; } // get the list of elements to remove List <string> toRemove = new List <string>(); foreach (string currCoverPath in currMovie.AlternateCovers) { if (!new FileInfo(currCoverPath).Exists) { toRemove.Add(currCoverPath); } } // remove them foreach (string currItem in toRemove) { currMovie.AlternateCovers.Remove(currItem); } // reset default cover is needed if (!currMovie.AlternateCovers.Contains(currMovie.CoverFullPath)) { if (currMovie.AlternateCovers.Count == 0) { currMovie.CoverFullPath = " "; } else { currMovie.CoverFullPath = currMovie.AlternateCovers[0]; } } // get rid of the backdrop link if it doesnt exist if (currMovie.BackdropFullPath.Trim().Length > 0 && !new FileInfo(currMovie.BackdropFullPath).Exists) { currMovie.BackdropFullPath = " "; } currMovie.Commit(); } //OnProgress(1.0); }
public SearchForm() { InitializeComponent(); allMovies = DBMovieInfo.GetAll(); BuildIndexes(); foreach (SearchMode mode in Enum.GetValues(typeof(SearchMode))) { searchModeComboBox.Items.Add(mode.GetName()); } searchModeComboBox.SelectedIndex = 0; }
private void LookForMissingArtwork() { foreach (DBMovieInfo currMovie in DBMovieInfo.GetAll()) { try { if (currMovie.ID == null) { continue; } if (currMovie.CoverFullPath.Trim().Length == 0) { MovingPicturesCore.DataProviderManager.GetArtwork(currMovie); // because this operation can take some time we check again // if the movie was not deleted while we were getting artwork if (currMovie.ID == null) { continue; } currMovie.Commit(); } if (currMovie.BackdropFullPath.Trim().Length == 0) { new LocalProvider().GetBackdrop(currMovie); MovingPicturesCore.DataProviderManager.GetBackdrop(currMovie); // because this operation can take some time we check again // if the movie was not deleted while we were getting the backdrop if (currMovie.ID == null) { continue; } currMovie.Commit(); } } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving artwork for " + currMovie.Title, e); } } }
public void Download() { // get all movies in database var localMovies = DBMovieInfo.GetAll(); FileLog.Info("{0} movies in MovingPictures database", localMovies.Count); // get locally cached trailers var cache = TrailerDownloader.LoadMovieList(MoviePluginSource.MovingPictures); // process local movies var movieList = new List <Movie>(); foreach (var movie in localMovies) { // add to cache if it doesn't already exist if (!cache.Movies.Exists(m => m.IMDbID == (movie.ImdbID ?? string.Empty).Trim() && m.Title == movie.Title && m.Year == movie.Year.ToString())) { FileLog.Info("Adding Title='{0}', Year='{1}', IMDb='{2}', TMDb='{3}' to movie trailer cache.", movie.Title, movie.Year, movie.ImdbID ?? "<empty>", GetTmdbID(movie) ?? "<empty>"); movieList.Add(new Movie { File = movie.LocalMedia.First().FullPath, IMDbID = movie.ImdbID, TMDbID = GetTmdbID(movie), Plot = movie.Summary, Cast = movie.Actors.ToString(), Directors = movie.Directors.ToString(), Writers = movie.Writers.ToString(), Year = movie.Year.ToString(), Title = movie.Title, Poster = movie.CoverFullPath, Fanart = movie.BackdropFullPath, Genres = movie.Genres.ToString() }); } } // remove any movies from cache that are no longer in local collection cache.Movies.RemoveAll(c => !localMovies.Exists(l => (l.ImdbID ?? string.Empty).Trim() == c.IMDbID && l.Title == c.Title && l.Year.ToString() == c.Year)); // add any new local movies to cache since last time cache.Movies.AddRange(movieList); // process the movie cache and download trailers TrailerDownloader.ProcessAndDownloadTrailers(cache, MoviePluginSource.MovingPictures); return; }
// look for any movies with a cover but no thumbnail and regenerate as needed. private void CreateMissingThumbnails() { foreach (DBMovieInfo currMovie in DBMovieInfo.GetAll()) { try { // if this movie is not committed or we have no cover, move on if (currMovie.ID == null || string.IsNullOrEmpty(currMovie.CoverFullPath.Trim())) { continue; } // if the thumbnail file is missing or we have no reference to a thumb file if (!File.Exists(currMovie.CoverThumbFullPath) || string.IsNullOrEmpty(currMovie.CoverThumbFullPath.Trim())) { currMovie.GenerateThumbnail(); currMovie.Commit(); } } catch (Exception e) { logger.ErrorException("Error creating thumbnail for " + currMovie.Title, e); } } }
private LatestsCollection GetLatestMovingPictures() { latestMovies = new LatestsCollection(); latestMovingPictures = new Hashtable(); LatestsCollection latests = new LatestsCollection(); try { List <DBMovieInfo> vMovies = null; if (Restricted) { vMovies = MovingPicturesCore.Settings.ParentalControlsFilter.Filter(DBMovieInfo.GetAll()).ToList(); } else { vMovies = DBMovieInfo.GetAll(); } foreach (var item in vMovies) { if (CurrentFacade.Type == LatestsFacadeType.Watched) { if (item.UserSettings[0].WatchedCount == 0) { continue; } } else if (CurrentFacade.UnWatched && (item.UserSettings[0].WatchedCount > 0)) { continue; } if (CurrentFacade.Type == LatestsFacadeType.Rated) { if (item.Score == 0.0) { continue; } } string sTimestamp = item.DateAdded.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture); string fanart = item.CoverThumbFullPath; if (string.IsNullOrEmpty(fanart)) { fanart = "DefaultVideoBig.png"; // "DefaultFolderBig.png"; } string fbanner = string.Empty; string fclearart = string.Empty; string fclearlogo = string.Empty; string fcd = string.Empty; string aposter = string.Empty; string abg = string.Empty; if (Utils.FanartHandler) { Parallel.Invoke ( () => fbanner = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner), () => fclearart = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt), () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo), () => fcd = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt), () => aposter = UtilsFanartHandler.GetAnimatedForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.Animated.MoviesPoster), () => abg = UtilsFanartHandler.GetAnimatedForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.Animated.MoviesBackground) ); } latests.Add(new Latest(sTimestamp, fanart, item.BackdropFullPath, item.Title, null, null, null, item.Genres.ToPrettyString(2), item.Score.ToString(CultureInfo.CurrentCulture), Math.Round(item.Score, MidpointRounding.AwayFromZero).ToString(CultureInfo.CurrentCulture), item.Certification, GetMovieRuntime(item), item.Year.ToString(CultureInfo.CurrentCulture), null, null, null, item, item.ID.ToString(), item.Summary, null, fbanner, fclearart, fclearlogo, fcd, aposter, abg)); if (item.WatchedHistory.Count > 0) { latests[latests.Count - 1].DateWatched = item.WatchedHistory[item.WatchedHistory.Count - 1].DateWatched.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture); } Utils.ThreadToSleep(); } if (vMovies != null) { vMovies.Clear(); } vMovies = null; CurrentFacade.HasNew = false; Utils.SortLatests(ref latests, CurrentFacade.Type, CurrentFacade.LeftToRight); int x = 0; for (int x0 = 0; x0 < latests.Count; x0++) { try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); DBMovieInfo Movie = (DBMovieInfo)latests[x0].Playable; latests[x0].IsNew = ((dTmp > Utils.NewDateTime) && (Movie.UserSettings[0].WatchedCount <= 0)); if (latests[x0].IsNew) { CurrentFacade.HasNew = true; } } catch { } latestMovies.Add(latests[x0]); latestMovingPictures.Add(x0 + 1, latests[x0].Playable); Utils.ThreadToSleep(); // logger.Debug("*** Latest [{7}] {0}:{1}:{2} - {3} - {4} {5} - {6}", x, CurrentFacade.Type, CurrentFacade.LeftToRight, latests[x0].Title, latests[x0].DateAdded, latests[x0].DateWatched, latests[x0].Rating, CurrentFacade.ControlID); x++; if (x == Utils.FacadeMaxNum) { break; } } } catch (Exception ex) { logger.Error("GetLatestMovingPictures: " + ex.ToString()); } if (latests != null) { latests.Clear(); } latests = null; if (latestMovies != null && !MainFacade) { logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMovies.Count); } return(latestMovies); }