예제 #1
0
        public static TraktScrobbleMovie GetOriginalMovieTitle(EVideoInfo info, double playerprogress)
        {
            IEnumerable <TraktSearchResult> movieMatch = TraktAPI.TraktAPI.SearchByName(info.Title, "movie", "Title");
            IEnumerator <TraktSearchResult> p          = movieMatch.GetEnumerator();

            if (!(p.MoveNext()))
            {
#if DEBUG
                TraktLogger.Info("No result found for '{0}'", info.Title);
#endif
                return(null);
            }
#if DEBUG
            TraktLogger.Info("Fetching informations for '{0}'. Matched to '{1}'", info.Title, p.Current.Movie.Title);
#endif
            var scrobbleData = new TraktScrobbleMovie
            {
                Movie = new TraktMovie
                {
                    Ids   = new TraktMovieId(),
                    Title = p.Current.Movie.Title.ToString(),
                    Year  = info.Year.ToNullableInt32()
                },
                Progress   = playerprogress,
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version
            };

            return(scrobbleData);
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        private TraktScrobbleMovie CreateMovieData(MediaItem mediaItem)
        {
            var movieScrobbleData = new TraktScrobbleMovie
            {
                Movie = new TraktMovie
                {
                    Ids = new TraktMovieId {
                        Imdb = GetMovieImdbId(mediaItem), Tmdb = GetMovieTmdbId(mediaItem)
                    },
                    Title = GetMovieTitle(mediaItem),
                    Year  = GetVideoYear(mediaItem)
                },
                AppDate    = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                AppVersion = APP_VERSION
            };

            return(movieScrobbleData);
        }
        /// <summary>
        /// Creates data object for movie scrobbling
        /// </summary>
        internal static TraktScrobbleMovie CreateMovieScrobbleData(VideoInfo info)
        {
            // create scrobble data
            var scrobbleData = new TraktScrobbleMovie
            {
                Movie = new TraktMovie
                {
                    Ids   = new TraktMovieId(),
                    Title = info.Title,
                    Year  = info.Year.ToNullableInt32()
                },
                Progress   = GetPlayerProgress(info),
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version
            };

            return(scrobbleData);
        }
예제 #6
0
        private TraktScrobbleMovie CreateMovieScrobbleData(ITrackingInfo info, double progress = 0)
        {
            var scrobbleData = new TraktScrobbleMovie
            {
                Movie = new TraktMovie
                {
                    Ids = new TraktMovieId {
                        Imdb = info.ID_IMDB, Tmdb = info.ID_TMDB.ToNullableInt32()
                    },
                    Title = info.Title,
                    Year  = (int)info.Year
                },
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version,
                Progress   = progress
            };

            return(scrobbleData);
        }
예제 #7
0
        /// <summary>
        /// Report to trakt.tv that a movie is being watched, or has been watched.
        /// </summary>
        /// <param name="movie">The movie being watched/scrobbled</param>
        /// <param name="mediaStatus">MediaStatus enum dictating whether item is being watched or scrobbled</param>
        /// <param name="traktUser">The user that watching the current movie</param>
        /// <param name="progressPercent"></param>
        /// <returns>A standard TraktResponse Data Contract</returns>
        public async Task <TraktScrobbleResponse> SendMovieStatusUpdateAsync(Movie movie, MediaStatus mediaStatus, TraktUser traktUser, float progressPercent)
        {
            var movieData = new TraktScrobbleMovie
            {
                app_date    = DateTimeOffset.Now.Date.ToString("yyyy-MM-dd"),
                app_version = _appHost.ApplicationVersionString,
                progress    = progressPercent,
                movie       = new TraktMovie
                {
                    title = movie.Name,
                    year  = movie.ProductionYear,
                    ids   = new TraktMovieId
                    {
                        imdb = movie.GetProviderId(MetadataProvider.Imdb),
                        tmdb = movie.GetProviderId(MetadataProvider.Tmdb).ConvertToInt()
                    }
                }
            };

            string url;

            switch (mediaStatus)
            {
            case MediaStatus.Watching:
                url = TraktUris.ScrobbleStart;
                break;

            case MediaStatus.Paused:
                url = TraktUris.ScrobblePause;
                break;

            default:
                url = TraktUris.ScrobbleStop;
                break;
            }

            using (var response = await PostToTrakt(url, movieData, CancellationToken.None, traktUser).ConfigureAwait(false))
            {
                return(await JsonSerializer.DeserializeAsync <TraktScrobbleResponse>(response, _jsonOptions).ConfigureAwait(false));
            }
        }
예제 #8
0
        /// <summary>
        /// Report to trakt.tv that a movie is being watched, or has been watched.
        /// </summary>
        /// <param name="movie">The movie being watched/scrobbled</param>
        /// <param name="mediaStatus">MediaStatus enum dictating whether item is being watched or scrobbled</param>
        /// <param name="traktUser">The user that watching the current movie</param>
        /// <param name="progressPercent"></param>
        /// <returns>A standard TraktResponse Data Contract</returns>
        public async Task <TraktScrobbleResponse> SendMovieStatusUpdateAsync(Movie movie, MediaStatus mediaStatus, TraktUser traktUser, float progressPercent)
        {
            var movieData = new TraktScrobbleMovie
            {
                AppDate    = DateTime.Today.ToString("yyyy-MM-dd"),
                AppVersion = _appHost.ApplicationVersion.ToString(),
                Progress   = progressPercent,
                Movie      = new TraktMovie
                {
                    Title = movie.Name,
                    Year  = movie.ProductionYear,
                    Ids   = new TraktMovieId
                    {
                        Imdb = movie.GetProviderId(MetadataProviders.Imdb),
                        Tmdb = movie.GetProviderId(MetadataProviders.Tmdb).ConvertToInt()
                    }
                }
            };

            string url;

            switch (mediaStatus)
            {
            case MediaStatus.Watching:
                url = TraktUris.ScrobbleStart;
                break;

            case MediaStatus.Paused:
                url = TraktUris.ScrobblePause;
                break;

            default:
                url = TraktUris.ScrobbleStop;
                break;
            }

            using (var response = await PostToTrakt(url, movieData, CancellationToken.None, traktUser))
            {
                return(_jsonSerializer.DeserializeFromStream <TraktScrobbleResponse>(response));
            }
        }
예제 #9
0
        /// <summary>
        /// Creates Scrobble data based on a IMDBMovie object
        /// </summary>
        /// <param name="movie">The movie to base the object on</param>
        /// <returns>The Trakt scrobble data to send</returns>
        private static TraktScrobbleMovie CreateScrobbleData(IMDBMovie movie)
        {
            double progress = (g_Player.CurrentPosition / (g_Player.Duration == 0.0 ? movie.RunTime * 60.0 : g_Player.Duration)) * 100.0;

            var scrobbleData = new TraktScrobbleMovie
            {
                Movie = new TraktMovie
                {
                    Ids = new TraktMovieId {
                        Imdb = movie.IMDBNumber.ToNullIfEmpty()
                    },
                    Title = movie.Title,
                    Year  = movie.Year
                },
                AppDate    = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version,
                Progress   = Math.Round(progress, 2)
            };

            return(scrobbleData);
        }
예제 #10
0
    /// <summary>
    /// Report to trakt.tv that a movie is being watched, or has been watched.
    /// </summary>
    /// <param name="movie">The movie being watched/scrobbled</param>
    /// <param name="mediaStatus">MediaStatus enum dictating whether item is being watched or scrobbled</param>
    /// <param name="traktUser">The user that watching the current movie</param>
    /// <param name="progressPercent"></param>
    /// <returns>A standard TraktResponse Data Contract</returns>
    public async Task <TraktScrobbleResponse> SendMovieStatusUpdateAsync(Movie movie, MediaStatus mediaStatus, TraktUser traktUser, float progressPercent)
    {
        var movieData = new TraktScrobbleMovie
        {
            AppDate    = DateTimeOffset.Now.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture),
            AppVersion = _appHost.ApplicationVersionString,
            Progress   = progressPercent,
            Movie      = new TraktMovie
            {
                Title = movie.Name,
                Year  = movie.ProductionYear,
                Ids   = GetTraktIMDBTMDBIds <Movie, TraktMovieId>(movie)
            }
        };

        string url;

        switch (mediaStatus)
        {
        case MediaStatus.Watching:
            url = TraktUris.ScrobbleStart;
            break;

        case MediaStatus.Paused:
            url = TraktUris.ScrobblePause;
            break;

        default:
            url = TraktUris.ScrobbleStop;
            break;
        }

        using (var response = await PostToTrakt(url, movieData, traktUser, CancellationToken.None).ConfigureAwait(false))
        {
            return(await JsonSerializer.DeserializeAsync <TraktScrobbleResponse>(response, _jsonOptions).ConfigureAwait(false));
        }
    }
        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;
            }
        }