void GUIWindowManager_OnNewAction(Action action) { bool validWatchListItem = false; bool validRateItem = false; bool validShoutItem = false; string title = string.Empty; string year = string.Empty; string imdb = string.Empty; string tvdb = string.Empty; string season = string.Empty; string episode = string.Empty; string fanart = string.Empty; string type = "movie"; GUIWindow currentWindow = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow); GUIControl currentButton = null; switch (action.wID) { case Action.ActionType.ACTION_MOUSE_CLICK: case Action.ActionType.ACTION_KEY_PRESSED: switch (GUIWindowManager.ActiveWindow) { case (int)ExternalPluginWindows.OnlineVideos: #region Watch List Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.WatchList); if (currentButton != null && currentButton.IsFocused) { // Confirm we are in IMDB/iTunes Trailer Details view // This will give us enough information to send to trakt bool isDetails = GUIPropertyManager.GetProperty("#OnlineVideos.state").ToLowerInvariant() == "details"; string siteUtil = GUIPropertyManager.GetProperty("#OnlineVideos.selectedSiteUtil").ToLowerInvariant(); if (isDetails && (siteUtil == "imdb" || siteUtil == "itmovietrailers")) { title = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Title").Trim(); year = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Year").Trim(); if (siteUtil == "imdb") { // IMDb site exposes IMDb ID, use this to get a better match on trakt // this property is new, check for null in case user hasn't updated site imdb = GUIPropertyManager.GetProperty("#OnlineVideos.Details.IMDbId"); if (imdb == null) imdb = string.Empty; // could be a TV Show type = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Type").ToLowerInvariant(); } if ((!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)) || imdb.StartsWith("tt")) validWatchListItem = true; // Return focus to details list now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.OnlineVideos, 51); } } #endregion break; case (int)ExternalPluginWindows.VideoInfo: #region Rate Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Rate); if (currentButton != null && currentButton.IsFocused) { type = "movie"; title = GUIPropertyManager.GetProperty("#title").Trim(); year = GUIPropertyManager.GetProperty("#year").Trim(); imdb = GUIPropertyManager.GetProperty("#imdbnumber").Trim(); if (!string.IsNullOrEmpty(imdb) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year))) validRateItem = true; // Set focus to Play Button now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.VideoInfo, 2); } #endregion #region Shouts Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Shouts); if (currentButton != null && currentButton.IsFocused) { type = "movie"; title = GUIPropertyManager.GetProperty("#title").Trim(); year = GUIPropertyManager.GetProperty("#year").Trim(); imdb = GUIPropertyManager.GetProperty("#imdbnumber").Trim(); #if !MP12 fanart = string.Empty; #else fanart = string.Empty; MediaPortal.Util.FanArt.GetFanArtfilename(title, 0, out fanart); #endif if (!string.IsNullOrEmpty(imdb) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year))) validShoutItem = true; } #endregion #region Watch List Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.WatchList); if (currentButton != null && currentButton.IsFocused) { title = GUIPropertyManager.GetProperty("#title").Trim(); year = GUIPropertyManager.GetProperty("#year").Trim(); imdb = GUIPropertyManager.GetProperty("#imdbnumber").Trim(); if ((!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)) || imdb.StartsWith("tt")) validWatchListItem = true; // Set focus to Play Button now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.VideoInfo, 2); } #endregion break; case (int)ExternalPluginWindows.MovingPictures: #region Rate Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Rate); if (currentButton != null && currentButton.IsFocused) { type = "movie"; title = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.title").Trim(); year = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.year").Trim(); imdb = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.imdb_id").Trim(); if (!string.IsNullOrEmpty(imdb) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year))) validRateItem = true; // Set focus to Play Button now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.MovingPictures, 6); } #endregion #region Shouts Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Shouts); if (currentButton != null && currentButton.IsFocused) { type = "movie"; title = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.title").Trim(); year = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.year").Trim(); imdb = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.imdb_id").Trim(); fanart = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.backdropfullpath").Trim(); if (!string.IsNullOrEmpty(imdb) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year))) validShoutItem = true; } #endregion #region Watch List Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.WatchList); if (currentButton != null && currentButton.IsFocused) { title = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.title").Trim(); year = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.year").Trim(); imdb = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.imdb_id").Trim(); if ((!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)) || imdb.StartsWith("tt")) validWatchListItem = true; // Set focus to Play Button now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.MovingPictures, 6); } #endregion break; case (int)ExternalPluginWindows.TVSeries: #region Rate Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Rate); if (currentButton != null && currentButton.IsFocused) { Object obj = TVSeries.SelectedObject; if (obj != null) { switch (TVSeries.GetSelectedType(obj)) { case TVSeries.SelectedType.Episode: type = "episode"; validRateItem = TVSeries.GetEpisodeInfo(obj, out title, out tvdb, out season, out episode); break; case TVSeries.SelectedType.Series: type = "series"; validRateItem = TVSeries.GetSeriesInfo(obj, out title, out tvdb); break; default: break; } // Set focus to Facade now so we dont go in a loop GUIControl.FocusControl((int)ExternalPluginWindows.TVSeries, 50); } } #endregion #region Shouts Button currentButton = currentWindow.GetControl((int)ExternalPluginControls.Shouts); if (currentButton != null && currentButton.IsFocused) { Object obj = TVSeries.SelectedObject; if (obj != null) { switch (TVSeries.GetSelectedType(obj)) { case TVSeries.SelectedType.Episode: type = "episode"; validShoutItem = TVSeries.GetEpisodeInfo(obj, out title, out tvdb, out season, out episode); break; case TVSeries.SelectedType.Series: type = "series"; validShoutItem = TVSeries.GetSeriesInfo(obj, out title, out tvdb); break; default: break; } fanart = GUIPropertyManager.GetProperty("#TVSeries.Current.Fanart").Trim(); } } #endregion break; } break; default: break; } #region Add To Watch List if (validWatchListItem) { if (GUIUtils.ShowYesNoDialog(Translation.WatchList, string.Format("{0}\n{1} ({2})", Translation.AddThisItemToWatchList, title, year), true)) { TraktLogger.Info("Adding {0} '{1} ({2}) [{3}]' to Watch List", type, title, year, imdb); Thread syncThread = new Thread(delegate(object obj) { if (type == "movie") { TraktAPI.TraktAPI.SyncMovieLibrary(BasicHandler.CreateMovieSyncData(title, year, imdb), TraktSyncModes.watchlist); GUIWatchListMovies.ClearCache(TraktSettings.Username); if (TraktHelper.IsMovingPicturesAvailableAndEnabled) { MovingPictures.UpdateCategoriesAndFilters(); } } else { TraktAPI.TraktAPI.SyncShowWatchList(BasicHandler.CreateShowSyncData(title, year, imdb), TraktSyncModes.watchlist); GUIWatchListShows.ClearCache(TraktSettings.Username); } }) { IsBackground = true, Name = "Adding to Watch List" }; syncThread.Start(); } } #endregion #region Rate if (validRateItem) { switch (type) { case "movie": TraktLogger.Info("Rating {0} '{1} ({2}) [{3}]'", type, title, year, imdb); GUIUtils.ShowRateDialog<TraktRateMovie>(BasicHandler.CreateMovieRateData(title, year, imdb)); break; case "series": TraktLogger.Info("Rating {0} '{1} [{2}]'", type, title, tvdb); GUIUtils.ShowRateDialog<TraktRateSeries>(BasicHandler.CreateShowRateData(title, tvdb)); break; case "episode": TraktLogger.Info("Rating {0} '{1} - {2}x{3} [{4}]'", type, title, season, episode, tvdb); GUIUtils.ShowRateDialog<TraktRateEpisode>(BasicHandler.CreateEpisodeRateData(title, tvdb, season, episode)); break; } } #endregion #region Shouts if (validShoutItem) { // Initialize Shout window switch (type) { #region movie case "movie": TraktLogger.Info("Searching Shouts for {0} '{1} ({2}) [{3}]'", type, title, year, imdb); MovieShout movieInfo = new MovieShout { IMDbId = imdb, Title = title, Year = year }; GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.movie; GUIShouts.MovieInfo = movieInfo; GUIShouts.Fanart = fanart; break; #endregion #region episode case "episode": TraktLogger.Info("Searching Shouts for {0} '{1} - {2}x{3} [{4}]'", type, title, season, episode, tvdb); EpisodeShout episodeInfo = new EpisodeShout { TVDbId = tvdb, Title = title, SeasonIdx = season, EpisodeIdx = episode }; GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.episode; GUIShouts.EpisodeInfo = episodeInfo; GUIShouts.Fanart = fanart; break; #endregion #region series case "series": TraktLogger.Info("Searching Shouts for {0} '{1} [{2}]'", type, title, tvdb); ShowShout seriesInfo = new ShowShout { TVDbId = tvdb, Title = title, }; GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = seriesInfo; GUIShouts.Fanart = fanart; break; #endregion } // Launch Shout window GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); } #endregion }
public static void ShowTVShowShouts(string tvdb, string title, string fanart) { if (!File.Exists(GUIGraphicsContext.Skin + @"\Trakt.Shouts.xml")) { // let user know they need to update skin or harass skin author GUIUtils.ShowOKDialog(GUIUtils.PluginName(), Translation.SkinOutOfDate); return; } ShowShout seriesInfo = new ShowShout { TVDbId = tvdb, Title = title, }; GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = seriesInfo; GUIShouts.Fanart = fanart; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); }
public static void ShowTVShowShouts(string title, int? year, int? tvdbid, int? traktid, string imdbid, bool isWatched, string fanart, string onlineFanart = null) { if (!File.Exists(GUIGraphicsContext.Skin + @"\Trakt.Shouts.xml")) { // let user know they need to update skin or harass skin author GUIUtils.ShowOKDialog(GUIUtils.PluginName(), Translation.SkinOutOfDate); return; } ShowShout seriesInfo = new ShowShout { TvdbId = tvdbid, TraktId = traktid, ImdbId = imdbid.ToNullIfEmpty(), Title = title, Year = year }; GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = seriesInfo; GUIShouts.Fanart = fanart; GUIShouts.IsWatched = isWatched; GUIShouts.OnlineFanart = onlineFanart; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); }