StartScrobbleMovie() static private method

Starts scrobbling a movie from a videoInfo object
static private StartScrobbleMovie ( VideoInfo videoInfo ) : bool
videoInfo VideoInfo
return bool
Beispiel #1
0
        public bool Scrobble(string filename)
        {
            StopScrobble();

            if (!g_Player.IsTV)
            {
                return(false);
            }

            CurrentProgram = GetCurrentProgram();

            if (CurrentProgram == null)
            {
                return(false);
            }
            CurrentProgram.IsScrobbling = true;

            if (CurrentProgram.Type == VideoType.Series)
            {
                TraktLogger.Info("Detected tv show playing on Live TV. Title = '{0}'", CurrentProgram.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie playing on Live TV. Title = '{0}'", CurrentProgram.ToString());
            }

            #region Scrobble Timer

            TraktTimer = new Timer(new TimerCallback((stateInfo) =>
            {
                Thread.CurrentThread.Name = "Scrobble";

                // get the current program airing on tv now
                // this may have changed since last status update on trakt
                VideoInfo videoInfo = GetCurrentProgram();

                if (videoInfo != null)
                {
                    // if we are watching something different,
                    // check if we should mark previous as watched
                    if (!videoInfo.Equals(CurrentProgram))
                    {
                        TraktLogger.Info("Detected new tv program has started. Previous Program = '{0}', New Program = '{1}'", CurrentProgram.ToString(), videoInfo.ToString());
                        if (IsProgramWatched(CurrentProgram) && CurrentProgram.IsScrobbling)
                        {
                            TraktLogger.Info("Playback of program on Live TV is considered watched. Title = '{0}'", CurrentProgram.ToString());
                            BasicHandler.StopScrobble(CurrentProgram, true);
                        }
                        CurrentProgram.IsScrobbling = true;
                    }

                    // continue watching new program
                    // dont try to scrobble if previous attempt failed
                    if (CurrentProgram.IsScrobbling)
                    {
                        if (videoInfo.Type == VideoType.Series)
                        {
                            videoInfo.IsScrobbling = BasicHandler.StartScrobbleEpisode(videoInfo);
                        }
                        else
                        {
                            videoInfo.IsScrobbling = BasicHandler.StartScrobbleMovie(videoInfo);
                        }

                        // set current program to new program
                        CurrentProgram = videoInfo;
                    }
                }
            }), null, 1000, 300000);

            #endregion

            return(true);
        }