/// <summary> /// This calls the searchGUI handling the fullscreen video replacement. /// This allows to stop the video from the search GUI and gracefully go to the previous window. /// </summary> /// <param name="search"></param> /// <param name="show"></param> public static void callSearchGUI(IEnumerable <TraktSearchResult> search, TraktShowSummary show = null) { wasFullScreenVideo = GUIGraphicsContext.IsFullScreenVideo; currentSearch = search; currentTvShow = show; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.EPGShowSelect, GUIGraphicsContext.IsFullScreenVideo); }
private void ClearControls() { //resultListControl.Clear(); currentSearch = null; searchlevel = 0; currentTvShow = null; }
public static TraktEPGCacheRecord createData(TraktShowSummary data) { return(new TraktEPGCacheRecord { Type = "show", Show = data }); }
private TraktRateEpisodes GetRateEpisodeData(IEnumerable <Dictionary <string, string> > episodes) { var traktEpisodes = new List <TraktEpisode>(); foreach (var episode in episodes) { // get the show information string showTitle = GetShowName(episode[IMDbFieldMapping.cTitle]); if (string.IsNullOrEmpty(showTitle)) { continue; } // get slug of show title string slug = showTitle.GenerateSlug(); if (string.IsNullOrEmpty(slug)) { continue; } TraktShowSummary showSummary = new TraktShowSummary(); if (!ShowSummaries.TryGetValue(showTitle, out showSummary)) { // get from online UIUtils.UpdateStatus(string.Format("Retrieving data for {0}", showTitle)); showSummary = TraktAPI.TraktAPI.GetShowSummary(slug); if (showSummary == null || showSummary.Seasons == null || showSummary.Seasons.Count == 0) { UIUtils.UpdateStatus(string.Format("Unable to get info for {0}", showTitle), true); continue; } // store show summary ShowSummaries.Add(showTitle, showSummary); } var traktEpisode = GetTraktEpisodeRateData(episode, showSummary); if (traktEpisode == null) { continue; } traktEpisodes.Add(traktEpisode); } var episodeRateData = new TraktRateEpisodes { Username = AppSettings.TraktUsername, Password = AppSettings.TraktPassword, Episodes = traktEpisodes }; return(episodeRateData); }
public static void overrideVideoInfoProgram(ref EVideoInfo info, TraktShowSummary originalShow, TraktEpisode episode = null) { info.Title = originalShow.Title; info.Year = originalShow.Year.ToString(); info.Type = VideoType.Series; if (episode != null) { info.EpisodeIdx = episode.Number.ToString(); info.SeasonIdx = episode.Season.ToString(); } }
public static void overrideCurrentProgram(TraktShowSummary originalShow, TraktEpisode episode = null) { if (currentProgram != null) { lock (currentProgram) { currentProgram.Title = originalShow.Title; currentProgram.Year = originalShow.Year.ToString(); currentProgram.Type = VideoType.Series; if (episode != null) { currentProgram.EpisodeIdx = episode.Number.ToString(); currentProgram.SeasonIdx = episode.Season.ToString(); } } } }
private void GetShowDetail() { // check if we need to fetch the show detail as well // currently the season API does not give back any show // summary info except for images if (Show.UpdatedAt == null) { string slug = Show.Ids.Trakt.ToString(); if (string.IsNullOrEmpty(slug)) { if (Show.Ids.Imdb != null) { slug = Show.Ids.Imdb; } else { slug = Show.Title.StripYear(Show.Year).ToSlug(); } } var showSummary = TraktAPI.TraktAPI.GetShowSummary(slug); if (showSummary != null) { Show = showSummary; // Load Show Properties PublishShowSkinProperties(Show); // Publish Fanart var showImages = TmdbCache.GetShowImages(showSummary.Ids.Tmdb); var showBackdropFilename = TmdbCache.GetShowBackdropFilename(showImages); if (showBackdropFilename == null) { return; } if (File.Exists(showBackdropFilename)) { GUIUtils.SetProperty("#Trakt.Show.Fanart", showBackdropFilename); } } } }
private bool GetLoadingParameter() { if (_loadParameter == null) { // maybe re-loading, so check previous window id if (Show != null && (Show.Ids.Trakt != null || Show.Ids.Imdb != null || Show.Title != null)) { return(true); } return(false); } Show = _loadParameter.FromJSON <TraktShowSummary>(); if (Show == null || Show.Ids == null) { return(false); } return(true); }
private bool GetLoadingParameter() { if (_loadParameter == null) { // maybe re-loading, so check previous window id if (Show != null && Show.Ids.Trakt != null && Season != null) { return(true); } return(false); } var loadingParam = _loadParameter.FromJSON <SeasonLoadingParameter>(); if (loadingParam == null) { return(false); } // reset previous selected index if (Show != null && Season != null) { if (Show.Title != loadingParam.Show.Title || Season.Number != loadingParam.Season.Number) { PreviousSelectedIndex = 0; } } Show = loadingParam.Show; Season = loadingParam.Season; if (Show == null || Show.Ids.Trakt == null || Season == null) { return(false); } return(true); }
private TraktEpisode GetTraktEpisodeRateData(Dictionary <string, string> episode, TraktShowSummary showSummary) { if (showSummary == null || showSummary.Seasons == null || showSummary.Seasons.Count == 0) { return(null); } string episodeTitle = GetEpisodeName(episode[IMDbFieldMapping.cTitle]); // find episode title in list of episodes from show summary if (!string.IsNullOrEmpty(episodeTitle)) { TraktShowSummary.TraktSeason.TraktEpisode match = null; foreach (var season in showSummary.Seasons) { if (match != null) { continue; } match = season.Episodes.FirstOrDefault(e => string.Equals(e.Title, episodeTitle, StringComparison.InvariantCultureIgnoreCase)); } if (match != null) { return(new TraktEpisode { Episode = match.Episode, Season = match.Season, TVDbId = showSummary.TVDbId, Title = showSummary.Title, Year = showSummary.Year, Rating = int.Parse(episode[IMDbFieldMapping.cRating]) }); } } // we can also lookup by airDate string episodeAirDate = episode[IMDbFieldMapping.cReleaseDate]; if (!string.IsNullOrEmpty(episodeAirDate)) { // get epoch date long dateTimeEpoch = 0; try { var splitDate = episodeAirDate.Split('-'); // parse date and add 8hours for PST DateTime dateTime = new DateTime(int.Parse(splitDate[0]), int.Parse(splitDate[1]), int.Parse(splitDate[2])).AddHours(8); dateTimeEpoch = dateTime.ToEpoch(); } catch { UIUtils.UpdateStatus(string.Format("Unable to get info for {0}", episode[IMDbFieldMapping.cTitle]), true); return(null); } TraktShowSummary.TraktSeason.TraktEpisode match = null; foreach (var season in showSummary.Seasons) { if (match != null) { continue; } match = season.Episodes.FirstOrDefault(e => e.FirstAired == dateTimeEpoch); } if (match != null) { return(new TraktEpisode { Episode = match.Episode, Season = match.Season, TVDbId = match.TVDbId, Title = showSummary.Title, Year = showSummary.Year, Rating = int.Parse(episode[IMDbFieldMapping.cRating]) }); } } UIUtils.UpdateStatus(string.Format("Unable to get info for {0}", episode[IMDbFieldMapping.cTitle]), true); return(null); }
private void PublishShowSkinProperties(TraktShowSummary PopularItem) { GUICommon.SetShowProperties(PopularItem); }
private void PublishShowSkinProperties(TraktShowSummary show) { GUICommon.SetShowProperties(show); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { //if (GUIBackgroundTask.Instance.IsBusy) return; switch (controlId) { #region SEARCH LIST CONTROL SELECTED case (3): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { GUIListItem item = resultListControl.SelectedListItem as GUIListItem; #if DEBUG TraktLogger.Info("The button pressed has a tvTAG as: {0}, ad has a string value of: {1}", item.TVTag.GetType(), item.TVTag.ToString()); #endif #region SCROBBLEMOVIE if (item.TVTag is TraktMovieSummary) { // Get movie from traktmoviesummary TraktMovie currentMovieSelected = new TraktMovie { Title = ((TraktMovieSummary)item.TVTag).Title, Year = ((TraktMovieSummary)item.TVTag).Year, Ids = ((TraktMovieSummary)item.TVTag).Ids }; var data = new TraktScrobbleMovie { Movie = currentMovieSelected, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData((TraktMovieSummary)item.TVTag)); EbasicHandler.overrideCurrentProgram((TraktMovieSummary)item.TVTag); EbasicHandler.StartScrobble(data); } #endregion else if (item.TVTag is TraktShowSummary) //search for seasons { TraktLogger.Info("TraktShowSummary Detected"); currentTvShow = (TraktShowSummary)item.TVTag; searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchShowSeasons(((TraktShowSummary)item.TVTag).Ids.Slug), searchlevel++); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } else if (item.TVTag is TraktSeasonSummary) //Episode for episodes { #if DEBUG TraktLogger.Info("SeasonSummary Detected"); TraktLogger.Info("Season '{0}' for show {1} selected. Getting Episodes.", ((TraktSeasonSummary)item.TVTag).Number, currentTvShow.Ids.Slug); #endif searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchSeasonEpisodes(currentTvShow.Ids.Slug, ((TraktSeasonSummary)item.TVTag).Number.ToString()), searchlevel++); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } #region SCROBBLESHOW else if (item.TVTag is TraktEpisodeSummary) //found! { TraktLogger.Info("EpisodeSummary Detected"); var data = new TraktScrobbleEpisode { Show = new TraktShow { Title = currentTvShow.Title, Year = currentTvShow.Year, Ids = currentTvShow.Ids }, Episode = new TraktEpisode { Season = ((TraktEpisodeSummary)item.TVTag).Season, Number = ((TraktEpisodeSummary)item.TVTag).Number, Title = ((TraktEpisodeSummary)item.TVTag).Title, Ids = ((TraktEpisodeSummary)item.TVTag).Ids }, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; #if DEBUG TraktLogger.Info(currentTvShow.ToString()); #endif EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData(currentTvShow)); EbasicHandler.overrideCurrentProgram(currentTvShow, data.Episode); EbasicHandler.StartScrobble(data); } #endregion else if (item.TVTag.ToString() == "FirstButton") { if ((item.Label).ToString() == "Manual Search") { //popup the input dialog to search. I need to call the full GUI here. #if DEBUG TraktLogger.Info("Manual search selected"); #endif VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); //keyboard.IsSearchKeyboard = true; keyboard.Reset(); keyboard.Text = EbasicHandler.getCurrentProgram().Title; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (keyboard.IsConfirmed) { //PopulateControlWithShows(keyboard.Text); //PopulateListControl(TraktAPI.TraktAPI.SearchShowByName(keyboard.Text)); //GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); //OnMessage(msg); //GUIShowSelectGUI.setCurrentSearch(TraktAPI.TraktAPI.SearchByName(keyboard.Text)); //GUIWindowManager.ActivateWindow((int)TraktGUIWindows.EPGShowSelect); GUIShowSelectGUI.callSearchGUI(TraktAPI.TraktAPI.SearchByName(keyboard.Text)); } } else //this handles back button { TraktLogger.Info("BackButtonDetected"); PopulateListControl(searchStack.Pop(), searchlevel--); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } } } break; #endregion default: TraktLogger.Info("I don't know what's the object."); base.OnClicked(controlId, control, actionType); break; } }
public int Compare(TraktShowSummary showX, TraktShowSummary showY) { try { int rtn; switch (_sortField) { case SortingFields.ReleaseDate: rtn = showX.FirstAired.FromISO8601().CompareTo(showY.FirstAired.FromISO8601()); break; case SortingFields.Score: rtn = showX.Rating.GetValueOrDefault(0).CompareTo(showY.Rating.GetValueOrDefault(0)); if (rtn == 0) { // if same score compare votes rtn = showX.Votes.CompareTo(showY.Votes); } break; case SortingFields.Votes: rtn = 0; rtn = showX.Votes.CompareTo(showY.Votes); break; case SortingFields.Popularity: double popX = showX.Votes * showX.Rating.GetValueOrDefault(0); double popY = showY.Votes * showY.Rating.GetValueOrDefault(0); rtn = popX.CompareTo(popY); break; case SortingFields.Runtime: rtn = showX.Runtime.GetValueOrDefault(0).CompareTo(showY.Runtime.GetValueOrDefault(0)); break; // default to the title field case SortingFields.Title: default: rtn = showX.Title.CompareTo(showY.Title); break; } // if both items are identical, fallback to using the Title if (rtn == 0) { rtn = showX.Title.CompareTo(showY.Title); } if (_sortDirection == SortingDirections.Descending) { rtn = -rtn; } return(rtn); } catch { return(0); } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { //if (GUIBackgroundTask.Instance.IsBusy) return; switch (controlId) { #region SEARCH LIST CONTROL SELECTED case (873008): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { GUIListItem item = resultListControl.SelectedListItem as GUIListItem; #region SCROBBLEMOVIE if (item.TVTag is TraktMovieSummary) { // Get movie from traktmoviesummary TraktMovie currentMovieSelected = new TraktMovie { Title = ((TraktMovieSummary)item.TVTag).Title, Year = ((TraktMovieSummary)item.TVTag).Year, Ids = ((TraktMovieSummary)item.TVTag).Ids }; var data = new TraktScrobbleMovie { Movie = currentMovieSelected, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData((TraktMovieSummary)item.TVTag)); EbasicHandler.overrideCurrentProgram((TraktMovieSummary)item.TVTag); EbasicHandler.StartScrobble(data); exitGUI(); } #endregion #region SCROBBLESHOW else if (item.TVTag is TraktEpisodeSummary) //found! { TraktLogger.Info("EpisodeSummary Detected"); var data = new TraktScrobbleEpisode { Show = new TraktShow { Title = currentTvShow.Title, Year = currentTvShow.Year, Ids = currentTvShow.Ids }, Episode = new TraktEpisode { Season = ((TraktEpisodeSummary)item.TVTag).Season, Number = ((TraktEpisodeSummary)item.TVTag).Number, Title = ((TraktEpisodeSummary)item.TVTag).Title, Ids = ((TraktEpisodeSummary)item.TVTag).Ids }, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData(currentTvShow)); EbasicHandler.overrideCurrentProgram(currentTvShow, data.Episode); EbasicHandler.StartScrobble(data); exitGUI(); } #endregion else if (item.TVTag is TraktShowSummary) { TraktLogger.Info("TraktShowSummary Detected"); currentTvShow = (TraktShowSummary)item.TVTag; searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchShowSeasons(((TraktShowSummary)item.TVTag).Ids.Slug), searchlevel++); } else if (item.TVTag is TraktSeasonSummary) { searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchSeasonEpisodes(currentTvShow.Ids.Slug, ((TraktSeasonSummary)item.TVTag).Number.ToString()), searchlevel++); } else if (item.TVTag.ToString() == "FirstButton") { if ((item.Label).ToString() == "Manual Search") { //popup the input dialog to search. VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); keyboard.Reset(); keyboard.Text = EbasicHandler.getCurrentProgram().Title; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (keyboard.IsConfirmed) { PopulateListControl(TraktAPI.TraktAPI.SearchByName(keyboard.Text, "show,movie", "title")); } } else //this handles back button { PopulateListControl(searchStack.Pop(), searchlevel--); } } } break; #endregion default: TraktLogger.Info("I don't know what's the object."); base.OnClicked(controlId, control, actionType); break; } }
private void ClearWindow() { resultListControl.Clear(); currentSearch = null; currentTvShow = null; }