示例#1
0
        /// <summary>
        /// Starting Point
        /// </summary>
        public override bool Init()
        {
            FileLog.Info("Starting Trailers v{0}", PluginSettings.Version);

            PluginSettings.PerformMaintenance();
            PluginSettings.LoadSettings();

            // Initialize Extension Settings
            ExtensionSettings.Init();

            // Load Trailer Providers
            LoadTrailerProviders();

            // Listen to this event to detect skin\language changes in GUI
            GUIWindowManager.OnDeActivateWindow += new GUIWindowManager.WindowActivationHandler(GUIWindowManager_OnDeActivateWindow);
            GUIWindowManager.OnActivateWindow   += new GUIWindowManager.WindowActivationHandler(GUIWindowManager_OnActivateWindow);
            GUIWindowManager.Receivers          += new SendMessageHandler(GUIWindowManager_Receivers);

            // Listen to player events
            g_Player.PlayBackEnded   += new g_Player.EndedHandler(g_Player_PlayBackEnded);
            g_Player.PlayBackStopped += new g_Player.StoppedHandler(g_Player_PlayBackStopped);

            // Initialize translations
            Translation.Init();

            // Initilize plugins for auto trailer download
            TrailerDownloader.Init();

            // Load main skin window
            // this is a launching pad to all other windows
            string xmlSkin = GUIGraphicsContext.Skin + @"\Trailers.xml";

            FileLog.Info("Loading main skin window: " + xmlSkin);
            return(Load(xmlSkin));
        }
示例#2
0
        /// <summary>
        /// Saves the Settings
        /// </summary>
        internal static void SaveSettings()
        {
            FileLog.Info("Saving Settings");
            using (Settings xmlwriter = new MPSettings())
            {
                xmlwriter.SetValue(cTrailers, cSettingsVersion, SettingsVersion);

                xmlwriter.SetValue(cTrailers, cWebMaxRetries, WebMaxRetries);
                xmlwriter.SetValue(cTrailers, cWebTimeout, WebTimeout);
                xmlwriter.SetValue(cTrailers, cWebTimeoutIncrement, WebTimeoutIncrement);
                xmlwriter.SetValue(cTrailers, cWebRequestCacheMinutes, WebRequestCacheMinutes.ToString());
                xmlwriter.SetValueAsBool(cTrailers, cProviderLocalSearch, ProviderLocalSearch);
                xmlwriter.SetValueAsBool(cTrailers, cProviderTMDb, ProviderTMDb);
                xmlwriter.SetValueAsBool(cTrailers, cProviderOnlineVideoSearch, ProviderOnlineVideoSearch);
                xmlwriter.SetValue(cTrailers, cOnlineVideosYouTubeMovieSearchString, OnlineVideosYouTubeMovieSearchString);
                xmlwriter.SetValue(cTrailers, cOnlineVideosYouTubeShowSearchString, OnlineVideosYouTubeShowSearchString);
                xmlwriter.SetValue(cTrailers, cOnlineVideosYouTubeSeasonSearchString, OnlineVideosYouTubeSeasonSearchString);
                xmlwriter.SetValue(cTrailers, cOnlineVideosYouTubeEpisodeSearchString, OnlineVideosYouTubeEpisodeSearchString);
                xmlwriter.SetValue(cTrailers, cOnlineVideosYouTubeEpisodeSpecialSearchString, OnlineVideosYouTubeEpisodeSpecialSearchString);
                xmlwriter.SetValueAsBool(cTrailers, cOnlineVideosYouTubeEnabled, OnlineVideosYouTubeEnabled);
                xmlwriter.SetValueAsBool(cTrailers, cOnlineVideosITunesEnabled, OnlineVideosITunesEnabled);
                xmlwriter.SetValueAsBool(cTrailers, cOnlineVideosIMDbEnabled, OnlineVideosIMDbEnabled);
                xmlwriter.SetValueAsBool(cTrailers, cSearchLocalInSubFolder, SearchLocalInSubFolder);
                xmlwriter.SetValue(cTrailers, cSearchLocalAdditionalSubFolders, SearchLocalAdditionalSubFolders);
                xmlwriter.SetValueAsBool(cTrailers, cSearchLocalInDedicatedDirectory, SearchLocalInDedicatedDirectory);
                xmlwriter.SetValue(cTrailers, cSearchLocalDedicatedDirectories, SearchLocalDedicatedDirectories);
                xmlwriter.SetValue(cTrailers, cSearchLocalDedicatedSubDirectories, SearchLocalDedicatedSubDirectories);
                xmlwriter.SetValue(cTrailers, cSearchLocalDedicatedDirectorySearchPatterns, SearchLocalDedicatedDirectorySearchPatterns);
                xmlwriter.SetValueAsBool(cTrailers, cSearchLocalInCurrentMediaFolder, SearchLocalInCurrentMediaFolder);
                xmlwriter.SetValue(cTrailers, cSearchLocalCurrentMediaFolderSearchPatterns, SearchLocalCurrentMediaFolderSearchPatterns);
                xmlwriter.SetValueAsBool(cTrailers, cSearchLocalAggressiveSearch, SearchLocalAggressiveSearch);
                xmlwriter.SetValueAsBool(cTrailers, cSkipOnlineProvidersIfLocalFound, SkipOnlineProvidersIfLocalFound);
                xmlwriter.SetValueAsBool(cTrailers, cAutoPlayOnSingleLocalOrOnlineTrailer, AutoPlayOnSingleLocalOrOnlineTrailer);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadTrailersMovingPictures, AutoDownloadTrailersMovingPictures);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadTrailersMyFilms, AutoDownloadTrailersMyFilms);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadTrailersMyVideos, AutoDownloadTrailersMyVideos);
                xmlwriter.SetValue(cTrailers, cAutoDownloadStartDelay, AutoDownloadStartDelay);
                xmlwriter.SetValue(cTrailers, cAutoDownloadInterval, AutoDownloadInterval);
                xmlwriter.SetValue(cTrailers, cAutoDownloadUpdateInterval, AutoDownloadUpdateInterval);
                xmlwriter.SetValue(cTrailers, cAutoDownloadDirectory, AutoDownloadDirectory);
                xmlwriter.SetValue(cTrailers, cAutoDownloadQuality, AutoDownloadQuality);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadTrailers, AutoDownloadTrailers);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadTeasers, AutoDownloadTeasers);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadFeaturettes, AutoDownloadFeaturettes);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadClips, AutoDownloadClips);
                xmlwriter.SetValueAsBool(cTrailers, cAutoDownloadCleanup, AutoDownloadCleanup);
                xmlwriter.SetValue(cTrailers, cPreferredLanguage, PreferredLanguage);
                xmlwriter.SetValueAsBool(cTrailers, cFallbackToEnglishLanguage, FallbackToEnglishLanguage);
                xmlwriter.SetValueAsBool(cTrailers, cAlwaysGetEnglishTrailers, AlwaysGetEnglishTrailers);
                xmlwriter.SetValueAsBool(cTrailers, cReShowMenuAfterTrailerPlay, ReShowMenuAfterTrailerPlay);
            }

            Settings.SaveCache();

            FileLog.Info("Saving Persistent File Cache");
            SaveFileCache(cTVDbExternalIDs, (TVDbIds ?? "{}".FromJsonArray <ExternalID>()).ToList().ToJson());
            SaveFileCache(cIMDbExternalIDs, (IMDbIds ?? "{}".FromJsonArray <ExternalID>()).ToList().ToJson());
            SaveFileCache(cTVRageExternalIDs, (TVRageIds ?? "{}".FromJsonArray <ExternalID>()).ToList().ToJson());
        }
示例#3
0
        private void Extensions_OnSettingsChanged(string guid)
        {
            // settings change occured
            if (guid == PluginSettings.cGuid)
            {
                FileLog.Info("Settings updated externally, re-loading trailer settings.");

                // re-load settings
                PluginSettings.LoadSettings(true);
            }
        }
示例#4
0
 void GUIWindowManager_OnDeActivateWindow(int windowID)
 {
     // Settings/General window
     // this is where a user can change skins\languages from GUI
     if (windowID == (int)ExternalPluginWindows.MPSkinSettings)
     {
         //did language change?
         if (Translation.CurrentLanguage != Translation.PreviousLanguage)
         {
             FileLog.Info("Language Changed to '{0}' from GUI, initializing translations.", Translation.CurrentLanguage);
             Translation.Init();
         }
     }
 }
示例#5
0
        /// <summary>
        /// End Point (Clean up)
        /// </summary>
        public override void DeInit()
        {
            FileLog.Debug("Removing Mediaportal Hooks");
            GUIWindowManager.OnDeActivateWindow -= GUIWindowManager_OnDeActivateWindow;
            GUIWindowManager.OnActivateWindow   -= GUIWindowManager_OnActivateWindow;
            GUIWindowManager.Receivers          -= GUIWindowManager_Receivers;

            // UnLoad Trailer Providers
            UnLoadTrailerProviders();

            // save settings
            PluginSettings.SaveSettings();

            FileLog.Info("Goodbye");
            base.DeInit();
        }
示例#6
0
        private void LoadTrailerProviders()
        {
            FileLog.Info("Loading Trailer Providers");

            if (!TrailerProviders.Exists(t => t.Name == "Local Trailer Search Provider"))
            {
                TrailerProviders.Add(new LocalTrailerProvider(PluginSettings.ProviderLocalSearch));
            }

            if (!TrailerProviders.Exists(t => t.Name == "TMDb Trailer Provider"))
            {
                TrailerProviders.Add(new TMDbTrailerProvider(PluginSettings.ProviderTMDb));
            }

            if (!TrailerProviders.Exists(t => t.Name == "OnlineVideos Trailer Search Provider"))
            {
                TrailerProviders.Add(new OnlineVideoSearchProvider(PluginSettings.ProviderOnlineVideoSearch && Utility.IsPluginAvailable("OnlineVideos")));
            }
        }
示例#7
0
        public void Init()
        {
            Thread hookThread = new Thread(delegate()
            {
                try
                {
                    FileLog.Info("Adding hooks to MPEI Settings");
                    AddHooksIntoMPEISettings();
                }
                catch
                {
                    FileLog.Warning("Unable to add hooks into MPEI Settings, Extensions plugin not installed or out of date. Install the Extensions plugin to have support to change settings in the GUI and/or auto-update plugin.");
                }
            })
            {
                Name         = "Settings",
                IsBackground = true
            };

            hookThread.Start();
        }
示例#8
0
        private void UnLoadTrailerProviders()
        {
            FileLog.Info("Unloading Trailer Providers");

            if (TrailerProviders.Exists(t => t.Name == "Local Trailer Search Provider"))
            {
                var item = TrailerProviders.FirstOrDefault(t => t.Name == "Local Trailer Search Provider");
                TrailerProviders.Remove(item);
            }

            if (TrailerProviders.Exists(t => t.Name == "TMDb Trailer Provider"))
            {
                var item = TrailerProviders.FirstOrDefault(t => t.Name == "TMDb Trailer Provider");
                TrailerProviders.Remove(item);
            }

            if (TrailerProviders.Exists(t => t.Name == "OnlineVideos Trailer Search Provider"))
            {
                var item = TrailerProviders.FirstOrDefault(t => t.Name == "OnlineVideos Trailer Search Provider");
                TrailerProviders.Remove(item);
            }
        }
示例#9
0
        /// <summary>
        /// Loads the Settings
        /// </summary>
        internal static void LoadSettings(bool reload = false)
        {
            FileLog.Info("Loading Local Settings");

            using (Settings xmlreader = new MPSettings())
            {
                LogLevel                                      = xmlreader.GetValueAsInt("general", "loglevel", 1);
                WebTimeout                                    = xmlreader.GetValueAsInt(cTrailers, cWebTimeout, 5000);
                WebTimeoutIncrement                           = xmlreader.GetValueAsInt(cTrailers, cWebTimeoutIncrement, 1000);
                WebMaxRetries                                 = xmlreader.GetValueAsInt(cTrailers, cWebMaxRetries, 5);
                WebRequestCacheMinutes                        = xmlreader.GetValueAsInt(cTrailers, cWebRequestCacheMinutes, 60);
                ProviderLocalSearch                           = xmlreader.GetValueAsBool(cTrailers, cProviderLocalSearch, true);
                ProviderTMDb                                  = xmlreader.GetValueAsBool(cTrailers, cProviderTMDb, true);
                ProviderOnlineVideoSearch                     = xmlreader.GetValueAsBool(cTrailers, cProviderOnlineVideoSearch, true);
                OnlineVideosYouTubeMovieSearchString          = xmlreader.GetValueAsString(cTrailers, cOnlineVideosYouTubeMovieSearchString, "%title% %year% trailer");
                OnlineVideosYouTubeShowSearchString           = xmlreader.GetValueAsString(cTrailers, cOnlineVideosYouTubeShowSearchString, "%title% trailer");
                OnlineVideosYouTubeSeasonSearchString         = xmlreader.GetValueAsString(cTrailers, cOnlineVideosYouTubeSeasonSearchString, "%title% season %season%");
                OnlineVideosYouTubeEpisodeSearchString        = xmlreader.GetValueAsString(cTrailers, cOnlineVideosYouTubeEpisodeSearchString, "%title% season %season% episode %episode%");
                OnlineVideosYouTubeEpisodeSpecialSearchString = xmlreader.GetValueAsString(cTrailers, cOnlineVideosYouTubeEpisodeSpecialSearchString, "%title% %episodename%");
                OnlineVideosYouTubeEnabled                    = xmlreader.GetValueAsBool(cTrailers, cOnlineVideosYouTubeEnabled, true);
                OnlineVideosIMDbEnabled                       = xmlreader.GetValueAsBool(cTrailers, cOnlineVideosIMDbEnabled, true);
                OnlineVideosITunesEnabled                     = xmlreader.GetValueAsBool(cTrailers, cOnlineVideosITunesEnabled, true);
                SearchLocalInSubFolder                        = xmlreader.GetValueAsBool(cTrailers, cSearchLocalInSubFolder, true);
                SearchLocalAdditionalSubFolders               = xmlreader.GetValueAsString(cTrailers, cSearchLocalAdditionalSubFolders, "Teaser|Extras|Shorts|Featurette|Featurettes");
                SearchLocalInDedicatedDirectory               = xmlreader.GetValueAsBool(cTrailers, cSearchLocalInDedicatedDirectory, true);
                SearchLocalDedicatedDirectories               = xmlreader.GetValueAsString(cTrailers, cSearchLocalDedicatedDirectories, GetExternalDownloadDirs());
                SearchLocalDedicatedSubDirectories            = xmlreader.GetValueAsString(cTrailers, cSearchLocalDedicatedSubDirectories, "%title% (%year%)|%title%");
                SearchLocalDedicatedDirectorySearchPatterns   = xmlreader.GetValueAsString(cTrailers, cSearchLocalDedicatedDirectorySearchPatterns, "%filename%*|*%title%*%year%*|*%title%*");
                SearchLocalInCurrentMediaFolder               = xmlreader.GetValueAsBool(cTrailers, cSearchLocalInCurrentMediaFolder, true);
                SearchLocalCurrentMediaFolderSearchPatterns   = xmlreader.GetValueAsString(cTrailers, cSearchLocalCurrentMediaFolderSearchPatterns, "trailer*|%filename%*|*%title%*%year%*|*%title%*");
                SearchLocalAggressiveSearch                   = xmlreader.GetValueAsBool(cTrailers, cSearchLocalAggressiveSearch, false);
                SkipOnlineProvidersIfLocalFound               = xmlreader.GetValueAsBool(cTrailers, cSkipOnlineProvidersIfLocalFound, false);
                AutoPlayOnSingleLocalOrOnlineTrailer          = xmlreader.GetValueAsBool(cTrailers, cAutoPlayOnSingleLocalOrOnlineTrailer, false);
                AutoDownloadTrailersMovingPictures            = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadTrailersMovingPictures, false);
                AutoDownloadTrailersMyFilms                   = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadTrailersMyFilms, false);
                AutoDownloadTrailersMyVideos                  = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadTrailersMyVideos, false);
                AutoDownloadStartDelay                        = xmlreader.GetValueAsInt(cTrailers, cAutoDownloadStartDelay, 30000);
                AutoDownloadInterval                          = xmlreader.GetValueAsInt(cTrailers, cAutoDownloadInterval, 86400000);
                AutoDownloadUpdateInterval                    = xmlreader.GetValueAsInt(cTrailers, cAutoDownloadUpdateInterval, 7);
                AutoDownloadDirectory                         = xmlreader.GetValueAsString(cTrailers, cAutoDownloadDirectory, Config.GetSubFolder(Config.Dir.Config, "Trailers"));
                AutoDownloadQuality                           = xmlreader.GetValueAsString(cTrailers, cAutoDownloadQuality, "HD");
                AutoDownloadTrailers                          = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadTrailers, true);
                AutoDownloadTeasers                           = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadTeasers, true);
                AutoDownloadFeaturettes                       = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadFeaturettes, true);
                AutoDownloadClips                             = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadClips, true);
                AutoDownloadCleanup                           = xmlreader.GetValueAsBool(cTrailers, cAutoDownloadCleanup, false);
                PreferredLanguage                             = xmlreader.GetValueAsString(cTrailers, cPreferredLanguage, "en");
                FallbackToEnglishLanguage                     = xmlreader.GetValueAsBool(cTrailers, cFallbackToEnglishLanguage, true);
                AlwaysGetEnglishTrailers                      = xmlreader.GetValueAsBool(cTrailers, cAlwaysGetEnglishTrailers, true);
                ReShowMenuAfterTrailerPlay                    = xmlreader.GetValueAsBool(cTrailers, cReShowMenuAfterTrailerPlay, false);
            }

            if (!reload)
            {
                FileLog.Info("Loading Persisted File Cache");
                TVDbIds   = LoadFileCache(cTVDbExternalIDs, "{}").FromJsonArray <ExternalID>().ToList();
                IMDbIds   = LoadFileCache(cIMDbExternalIDs, "{}").FromJsonArray <ExternalID>().ToList();
                TVRageIds = LoadFileCache(cTVRageExternalIDs, "{}").FromJsonArray <ExternalID>().ToList();

                if (TVDbIds == null)
                {
                    TVDbIds = new List <ExternalID>();
                }
                if (IMDbIds == null)
                {
                    TVDbIds = new List <ExternalID>();
                }
                if (TVRageIds == null)
                {
                    TVDbIds = new List <ExternalID>();
                }
            }
        }
示例#10
0
        public static void SearchForTrailers(MediaItem searchItem)
        {
            ReShowTrailerMenu = false;

            GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() =>
            {
                var menuItems = new List <GUITrailerListItem>();

                // add enabled local sources
                foreach (var trailerProvider in TrailerProviders.Where(t => t.IsLocal && t.Enabled))
                {
                    menuItems.AddRange(trailerProvider.Search(searchItem));
                }

                // add enabled online sources
                if (menuItems.Count == 0 || !PluginSettings.SkipOnlineProvidersIfLocalFound)
                {
                    foreach (var trailerProvider in TrailerProviders.Where(t => !t.IsLocal && t.Enabled))
                    {
                        menuItems.AddRange(trailerProvider.Search(searchItem));
                    }
                }

                return(menuItems);
            },
                                                                      delegate(bool success, object result)
            {
                if (success)
                {
                    FileLog.Debug("Showing Trailer Menu for selection.");
                    var menuItems = result as List <GUITrailerListItem>;
                    if (menuItems.Count > 0)
                    {
                        #region Auto-Play
                        // only one local trailer
                        if (PluginSettings.AutoPlayOnSingleLocalOrOnlineTrailer && menuItems.Where(t => !t.IsOnlineItem && !t.IsSearchItem).Count() == 1)
                        {
                            var localTrailer = menuItems.Find(t => !t.IsOnlineItem);
                            LocalPlayer.Play(localTrailer.URL, localTrailer.CurrentMedia);
                            return;
                        }
                        // only one online trailer
                        else if (PluginSettings.AutoPlayOnSingleLocalOrOnlineTrailer && menuItems.Where(t => t.IsOnlineItem && !t.IsSearchItem).Count() == 1)
                        {
                            var onlineTrailer = menuItems.Find(t => t.IsOnlineItem && !t.IsSearchItem);
                            OnlinePlayer.Play(onlineTrailer.URL, onlineTrailer.CurrentMedia);
                            return;
                        }
                        // only one of anything - doesn't matter if AutoPlay is enabled just do it.
                        else if (menuItems.Count == 1)
                        {
                            FileLog.Info("Only a single result to show, skipping GUI menu selection dialog.");

                            if (menuItems.First().IsSearchItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems.First().URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems.First().URL);
                            }
                            else if (menuItems.First().IsOnlineItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems.First().URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems.First().URL);
                            }
                            else
                            {
                                LocalPlayer.Play(menuItems.First().URL, menuItems.First().CurrentMedia);
                            }
                            return;
                        }
                        #endregion

                        #region Show Menu
                        int selectedItem = GUIUtils.ShowMenuDialog(menuItems.First().CurrentMedia.ToString(), menuItems);
                        if (selectedItem >= 0)
                        {
                            // re-show menu after playback is enabled and there is more than one local/online trailer to select.
                            ReShowTrailerMenu = PluginSettings.ReShowMenuAfterTrailerPlay && (menuItems.Count(t => !t.IsSearchItem) > 1);
                            CurrentMediaItem  = menuItems[selectedItem].CurrentMedia;

                            // Search or Play?
                            if (menuItems[selectedItem].IsSearchItem)
                            {
                                FileLog.Info("Performing online lookup for trailer: {0}", menuItems[selectedItem].URL);
                                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, menuItems[selectedItem].URL);
                            }
                            else if (menuItems[selectedItem].IsOnlineItem)
                            {
                                // play the selected trailer
                                OnlinePlayer.Play(menuItems[selectedItem].URL, menuItems[selectedItem].CurrentMedia);
                            }
                            else
                            {
                                // play local media
                                LocalPlayer.Play(menuItems[selectedItem].URL, menuItems[selectedItem].CurrentMedia);
                            }
                        }
                        else
                        {
                            FileLog.Debug("No Trailer selected for playback or search.");
                        }
                        #endregion
                    }
                    else
                    {
                        GUIUtils.ShowNotifyDialog(Translation.Trailers, Translation.NoTrailersFound);
                    }
                }
            }, Translation.GettingTrailers, true);
        }
示例#11
0
        void GUIWindowManager_Receivers(GUIMessage message)
        {
            // check event was fired from a trailer button
            // buttons allocated are 11899, 11900 and 11901
            if (message.SenderControlId < 11899 || message.SenderControlId > 11901)
            {
                return;
            }

            bool      isDetailsView    = true;
            MediaItem currentMediaItem = null;

            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_CLICKED:
                switch (GUIWindowManager.ActiveWindow)
                {
                case (int)ExternalPluginWindows.VideoFile:
                case (int)ExternalPluginWindows.VideoTitle:
                    VideoInfoHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                case (int)ExternalPluginWindows.VideoInfo:
                    VideoInfoHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 2);
                    break;

                case (int)ExternalPluginWindows.MovingPictures:
                    MovingPicturesHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 6 : 50);
                    break;

                case (int)ExternalPluginWindows.MyFilmsDetails:
                    MyFilmsHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 10000);
                    break;

                case (int)ExternalPluginWindows.ShowTimes:
                    ShowTimesHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 42 : 50);
                    break;

                case (int)ExternalPluginWindows.TVSeries:
                    MPTVSeriesHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt movie windows
                case (int)ExternalPluginWindows.TraktRecentAddedMovies:
                case (int)ExternalPluginWindows.TraktRecentWatchedMovies:
                case (int)ExternalPluginWindows.TraktRecommendationsMovies:
                case (int)ExternalPluginWindows.TraktRelatedMovies:
                case (int)ExternalPluginWindows.TraktSearchMovies:
                case (int)ExternalPluginWindows.TraktTrendingMovies:
                case (int)ExternalPluginWindows.TraktWatchedListMovies:
                case (int)ExternalPluginWindows.TraktPopularMovies:
                case (int)ExternalPluginWindows.TraktAnticipatedMovies:
                case (int)ExternalPluginWindows.TraktBoxOffice:
                case (int)ExternalPluginWindows.TraktPersonCreditMovies:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Movie);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt show windows
                case (int)ExternalPluginWindows.TraktRecommendationsShows:
                case (int)ExternalPluginWindows.TraktRelatedShows:
                case (int)ExternalPluginWindows.TraktTrendingShows:
                case (int)ExternalPluginWindows.TraktWatchedListShows:
                case (int)ExternalPluginWindows.TraktSearchShows:
                case (int)ExternalPluginWindows.TraktPopularShows:
                case (int)ExternalPluginWindows.TraktAnticipatedShows:
                case (int)ExternalPluginWindows.TraktPersonCreditShows:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Show);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt season windows
                case (int)ExternalPluginWindows.TraktShowSeasons:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Season);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt episode windows
                case (int)ExternalPluginWindows.TraktCalendar:
                case (int)ExternalPluginWindows.TraktRecentAddedEpisodes:
                case (int)ExternalPluginWindows.TraktRecentWatchedEpisodes:
                case (int)ExternalPluginWindows.TraktSearchEpisodes:
                case (int)ExternalPluginWindows.TraktSeasonEpisodes:
                case (int)ExternalPluginWindows.TraktWatchedListEpisodes:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Episode);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt list window
                case (int)ExternalPluginWindows.TraktListItems:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.List);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                case (int)ExternalPluginWindows.NetflixAlpha:
                    NetflixHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 6 : 50);
                    break;
                }
                break;
            }

            if (currentMediaItem != null)
            {
                switch (currentMediaItem.MediaType)
                {
                case MediaItemType.Movie:
                    FileLog.Info("Searching for movie trailers on: Title='{0}', Year='{1}', IMDb='{2}', TMDb='{3}', Filename='{4}'", currentMediaItem.Title, currentMediaItem.Year.ToString(), currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>", currentMediaItem.FilenameWOExtension ?? "<empty>");
                    break;

                case MediaItemType.Show:
                    FileLog.Info("Searching for tv show trailers on: Title='{0}', Year='{1}', FirstAired='{2}', IMDb='{3}', TVDb='{4}', TMDb='{5}'", currentMediaItem.Title, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>");
                    break;

                case MediaItemType.Season:
                    FileLog.Info("Searching for tv season trailers on: Title='{0}', Season='{1}', Year='{2}', FirstAired='{3}', IMDb='{4}', TVDb='{5}', TMDb='{6}'", currentMediaItem.Title, currentMediaItem.Season, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>");
                    break;

                case MediaItemType.Episode:
                    FileLog.Info("Searching for tv episode trailers on: Title='{0}', Season='{1}', Episode='{2}', Year='{3}', FirstAired='{4}', IMDb='{5}', TVDb='{6}', TMDb='{7}', Filename='{8}'", currentMediaItem.Title, currentMediaItem.Season, currentMediaItem.Episode, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>", currentMediaItem.FilenameWOExtension ?? "<empty>");
                    break;
                }

                SearchForTrailers(currentMediaItem);
            }
        }