private void ImportBackground(MovieSheetsGenerator generator, MoviesheetsUpdateManager metadatamanager) { if (!FileManager.Configuration.Options.MovieSheetsOptions.DoNotAutopopulateBackdrop) { bool _backgrDone = AutoloadBackdrop(generator, FileManager.Configuration.Options.MovieSheetsOptions.AutopopulateFromMetadata, metadatamanager, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanartjpgAsBackground, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanartjpgAsBackgroundName, MoviesheetImageType.Background); if (!_backgrDone) { if (Backdrops != null && Backdrops.Count() != 0) { //update backdrop (if no backdrop selected then choose first one) if (!File.Exists(generator.BackdropTempPath)) { string _backPath = ChooseARandomBackdrop(false); if (!string.IsNullOrEmpty(_backPath)) { generator.UpdateBackdrop(MoviesheetImageType.Background, _backPath); } } } } } }
private void AddBackdropToLists(BackdropItem item, bool asFirst) { if (item != null) { (Backdrops as List <BackdropBase>).Insert(asFirst ? 0 : Math.Max(0, Backdrops.Count() - 1), item); (OwnBackdrops as List <BackdropBase>).Insert(asFirst ? 0 : Math.Max(0, OwnBackdrops.Count() - 1), item); } }
private string ChooseARandomBackdrop(bool allowWideBanners) { if (Backdrops != null && Backdrops.Count() > 0) { IEnumerable <BackdropBase> _tempPool = null; // if I have taken backdrops then remove them from the temporary pool if (m_TakenBackdrops != null && m_TakenBackdrops.Count() < Backdrops.Count()) { _tempPool = from c in Backdrops from d in m_TakenBackdrops where c.OriginalUrl != d.OriginalUrl select c; } if (_tempPool == null || _tempPool.Count() == 0) { _tempPool = Backdrops; } // remove from the candidates the banners if the AllowWideBanners is false if (!allowWideBanners) { _tempPool = from c in _tempPool where !c.IsBanner select c; } if (_tempPool != null && _tempPool.Count() != 0) { BackdropBase _backdrop = null; Random _rand = new Random(); do { int _idx = _rand.Next(0, _tempPool.Count() - 1); _backdrop = _tempPool.ElementAt(_idx); } while (_backdrop == null); m_TakenBackdrops.Add(_backdrop); // remember it as taken ;) return(_backdrop.OriginalUrl); } else { return(null); } } else { return(null); } }
private void ImportFanarts(MovieSheetsGenerator generator, MoviesheetsUpdateManager metadatamanager) { if (!FileManager.Configuration.Options.MovieSheetsOptions.DoNotAutopopulateFanart) { bool _f1done = AutoloadBackdrop(generator, FileManager.Configuration.Options.MovieSheetsOptions.AutopopulateFromMetadata, metadatamanager, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart1jpgAsBackground, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart1jpgAsBackgroundName, MoviesheetImageType.Fanart1); bool _f2done = AutoloadBackdrop(generator, FileManager.Configuration.Options.MovieSheetsOptions.AutopopulateFromMetadata, metadatamanager, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart2jpgAsBackground, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart2jpgAsBackgroundName, MoviesheetImageType.Fanart2); bool _f3done = AutoloadBackdrop(generator, FileManager.Configuration.Options.MovieSheetsOptions.AutopopulateFromMetadata, metadatamanager, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart3jpgAsBackground, FileManager.Configuration.Options.MovieSheetsOptions.AutoSelectFanart3jpgAsBackgroundName, MoviesheetImageType.Fanart3); if (Backdrops != null && Backdrops.Count() != 0) { if (!_f1done) { string _s = ChooseARandomBackdrop(false); if (!string.IsNullOrEmpty(_s)) { generator.UpdateBackdrop(MoviesheetImageType.Fanart1, _s); } } if (!_f2done) { string _s = null; if (FileManager.Configuration.Options.GetBannerAsFanart2) { BackdropBase _banner = GetSpecialBackdrop(false, true); if (_banner != null) { _s = _banner.OriginalUrl; } } if (string.IsNullOrEmpty(_s)) { _s = ChooseARandomBackdrop(false); } if (!string.IsNullOrEmpty(_s)) { generator.UpdateBackdrop(MoviesheetImageType.Fanart2, _s); } } if (!_f3done) { string _s = null; if (FileManager.Configuration.Options.RetrieveEpisodeScreenshots) { BackdropBase _screenshot = GetSpecialBackdrop(true, false); if (_screenshot != null) { _s = _screenshot.OriginalUrl; } } if (string.IsNullOrEmpty(_s)) { _s = ChooseARandomBackdrop(false); } if (!string.IsNullOrEmpty(_s)) { generator.UpdateBackdrop(MoviesheetImageType.Fanart3, _s); } } } } }