Пример #1
0
        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);
            }
        }
Пример #2
0
        private BackdropBase GetSpecialBackdrop(bool isScreenshot, bool isWideBanner)
        {
            BackdropBase _result = null;

            foreach (BackdropBase _b in Backdrops)
            {
                if (isScreenshot && _b.IsScreenshot)
                {
                    _result = _b;
                    break;
                }
                if (isWideBanner && _b.IsBanner)
                {
                    _result = _b;
                    break;
                }
            }

            return(_result);
        }
Пример #3
0
        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);
                        }
                    }
                }
            }
        }