Example #1
0
        private void CreateScrobbleData(IPlayerSlotController psc)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || pc.CurrentMediaItem == null)
            {
                return;
            }
            IMediaPlaybackControl pmc = pc.CurrentPlayer as IMediaPlaybackControl;

            if (pmc == null)
            {
                return;
            }

            _duration = pmc.Duration;

            if (IsMovie(pc.CurrentMediaItem))
            {
                Guid movieMediaItemId = pc.CurrentMediaItem.MediaItemId;
                currentPlayingMediaItem = GetMediaItem(movieMediaItemId, new Guid[] { MediaAspect.ASPECT_ID, ExternalIdentifierAspect.ASPECT_ID, MovieAspect.ASPECT_ID });
                _dataMovie = CreateMovieData(currentPlayingMediaItem);
            }

            if (IsSeries(pc.CurrentMediaItem))
            {
                Guid seriesMediaItemId = pc.CurrentMediaItem.MediaItemId;
                currentPlayingMediaItem = GetMediaItem(seriesMediaItemId, new Guid[] { MediaAspect.ASPECT_ID, ExternalIdentifierAspect.ASPECT_ID, EpisodeAspect.ASPECT_ID });
                _dataEpisode            = CreateEpisodeData(currentPlayingMediaItem);
            }
        }
Example #2
0
        private TraktScrobbleEpisode CreateEpisodeData(MediaItem mediaItem)
        {
            var episodeScrobbleData = new TraktScrobbleEpisode
            {
                Episode = new TraktEpisode
                {
                    Ids = new TraktEpisodeId
                    {
                        Tvdb = GetTvdbId(mediaItem),
                        Imdb = GetSeriesImdbId(mediaItem)
                    },
                    Title  = GetSeriesTitle(mediaItem),
                    Season = GetSeasonIndex(mediaItem),
                    Number = GetEpisodeIndex(mediaItem)
                },
                Show = new TraktShow
                {
                    Ids = new TraktShowId
                    {
                        Tvdb = GetTvdbId(mediaItem),
                        Imdb = GetSeriesImdbId(mediaItem)
                    },
                    Title = GetSeriesTitle(mediaItem),
                    Year  = GetVideoYear(mediaItem)
                },
                AppDate    = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                AppVersion = APP_VERSION
            };

            return(episodeScrobbleData);
        }
Example #3
0
        private TraktScrobbleEpisode CreateEpisodeScrobbleData(ITrackingInfo info, double progress = 0)
        {
            var scrobbleData = new TraktScrobbleEpisode
            {
                Episode = new TraktEpisode
                {
                    Ids    = new TraktEpisodeId(),
                    Number = (int)info.Episode,
                    Season = (int)info.Season
                },
                Show = new TraktShow
                {
                    Ids = new TraktShowId {
                        Imdb = info.ID_IMDB, Tmdb = info.ID_TMDB.ToNullableInt32(), Tvdb = info.ID_TVDB.ToNullableInt32()
                    },
                    Title = info.Title,
                    Year  = info.Year > 0 ? (int?)info.Year : null
                },
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version,
                Progress   = progress
            };

            return(scrobbleData);
        }
Example #4
0
        private void CreateScrobbleData(IPlayerSlotController psc)
        {
            IPlayerContext pc = PlayerContext.GetPlayerContext(psc);

            if (pc == null || pc.CurrentMediaItem == null)
            {
                return;
            }
            IMediaPlaybackControl pmc = pc.CurrentPlayer as IMediaPlaybackControl;

            if (pmc == null)
            {
                return;
            }

            var mediaItem = pc.CurrentMediaItem;

            _duration = pmc.Duration;
            bool isMovie  = mediaItem.Aspects.ContainsKey(MovieAspect.ASPECT_ID);
            bool isSeries = mediaItem.Aspects.ContainsKey(SeriesAspect.ASPECT_ID);

            if (isMovie)
            {
                _dataMovie = CreateMovieData(mediaItem);
            }

            if (isSeries)
            {
                _dataEpisode = CreateEpisodeData(mediaItem);
            }
        }
        /// <summary>
        /// Creates data object for episode scrobbling
        /// </summary>
        internal static TraktScrobbleEpisode CreateEpisodeScrobbleData(VideoInfo info)
        {
            // create scrobble data
            var scrobbleData = new TraktScrobbleEpisode
            {
                Show = new TraktShow
                {
                    Ids   = new TraktShowId(),
                    Title = info.Title,
                    Year  = info.Year.ToNullableInt32()
                },
                Episode = new TraktEpisode
                {
                    Ids    = new TraktEpisodeId(),
                    Number = info.EpisodeIdx.ToInt(),
                    Season = info.SeasonIdx.ToInt()
                },
                Progress   = GetPlayerProgress(info),
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version
            };

            return(scrobbleData);
        }
        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;
            }
        }
        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;
            }
        }