ToString() public method

public ToString ( ) : string
return string
        public bool Scrobble(string filename)
        {
            StopScrobble();

            if (!g_Player.IsTVRecording) return false;

            // get recording details from tv database
            ControlServiceAgent layer = new ControlServiceAgent();
            Recording recording = layer.GetRecordingByFileName(filename);
            if (recording == null || string.IsNullOrEmpty(recording.Title))
            {
                TraktLogger.Info("Unable to get recording details from argus database.");
                return false;
            }

            // get year from title if available, some EPG entries contain this
            string title = null;
            string year = null;
            BasicHandler.GetTitleAndYear(recording.Title, out title, out year);

            CurrentRecording = new VideoInfo
            {
                Type = recording.EpisodeNumber != null || recording.SeriesNumber != null ? VideoType.Series : VideoType.Movie,
                Title = title,
                Year = year,
                SeasonIdx = recording.SeriesNumber == null ? null : recording.SeriesNumber.ToString(),
                EpisodeIdx = recording.EpisodeNumber == null ? null : recording.EpisodeNumber.ToString(),
                IsScrobbling = true
            };

            TraktLogger.Info("Current program details. Title='{0}', Year='{1}', Season='{2}', Episode='{3}', StartTime='{4}', Runtime='{5}'", CurrentRecording.Title, CurrentRecording.Year.ToLogString(), CurrentRecording.SeasonIdx.ToLogString(), CurrentRecording.EpisodeIdx.ToLogString(), CurrentRecording.StartTime == null ? "<empty>" : CurrentRecording.StartTime.ToString(), CurrentRecording.Runtime);

            if (CurrentRecording.Type == VideoType.Series)
            {
                TraktLogger.Info("Detected tv show playing in Argus TV Recordings. Title = '{0}'", CurrentRecording.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie playing in Argus TV Recordings. Title = '{0}'", CurrentRecording.ToString());
            }

            BasicHandler.StartScrobble(CurrentRecording);

            return true;
        }
        public void StopScrobble()
        {
            if (TraktTimer != null)
            {
                TraktTimer.Dispose();
            }

            if (CurrentProgram == null)
            {
                return;
            }

            if (IsProgramWatched(CurrentProgram) && CurrentProgram.IsScrobbling)
            {
                ScrobbleProgram(CurrentProgram);
            }
            else
            {
                #region cancel watching
                TraktLogger.Info("Stopped playback of tv-live '{0}'", CurrentProgram.ToString());

                Thread cancelWatching = new Thread(delegate(object obj)
                {
                    VideoInfo videoInfo = obj as VideoInfo;
                    if (videoInfo == null)
                    {
                        return;
                    }

                    if (videoInfo.Type == VideoType.Series)
                    {
                        TraktEpisodeScrobble scrobbleData = new TraktEpisodeScrobble {
                            UserName = TraktSettings.Username, Password = TraktSettings.Password
                        };
                        TraktResponse response = TraktAPI.TraktAPI.ScrobbleEpisodeState(scrobbleData, TraktScrobbleStates.cancelwatching);
                        TraktLogger.LogTraktResponse(response);
                    }
                    else
                    {
                        TraktMovieScrobble scrobbleData = new TraktMovieScrobble {
                            UserName = TraktSettings.Username, Password = TraktSettings.Password
                        };
                        TraktResponse response = TraktAPI.TraktAPI.ScrobbleMovieState(scrobbleData, TraktScrobbleStates.cancelwatching);
                        TraktLogger.LogTraktResponse(response);
                    }
                })
                {
                    IsBackground = true,
                    Name         = "CancelWatching"
                };

                cancelWatching.Start(CurrentProgram);
                #endregion
            }

            CurrentProgram = null;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void StopScrobble()
        {
            if (TraktTimer != null)
            {
                TraktTimer.Dispose();
            }

            if (CurrentProgram == null)
            {
                return;
            }

            if (IsProgramWatched(CurrentProgram) && CurrentProgram.IsScrobbling)
            {
                TraktLogger.Info("Playback of program on Live TV is considered watched. Title = '{0}'", CurrentProgram.ToString());
                BasicHandler.StopScrobble(CurrentProgram, true);
            }
            else
            {
                BasicHandler.StopScrobble(CurrentProgram);
            }

            CurrentProgram = null;
        }
        public bool Scrobble(string filename)
        {
            StopScrobble();

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

            // get recording details from tv database
            TvBusinessLayer layer     = new TvBusinessLayer();
            Recording       recording = layer.GetRecordingByFileName(filename);

            if (recording == null || string.IsNullOrEmpty(recording.Title))
            {
                TraktLogger.Warning("Unable to get recording details from database");
                return(false);
            }

            // get year from title if available, some EPG entries contain this
            string title = null;
            string year  = null;

            BasicHandler.GetTitleAndYear(recording.Title, out title, out year);

            CurrentRecording = new VideoInfo
            {
                Type         = !string.IsNullOrEmpty(recording.EpisodeNum) || !string.IsNullOrEmpty(recording.SeriesNum) ? VideoType.Series : VideoType.Movie,
                Title        = title,
                Year         = year,
                SeasonIdx    = recording.SeriesNum,
                EpisodeIdx   = recording.EpisodeNum,
                IsScrobbling = true
            };

            TraktLogger.Info("Current program details. Title='{0}', Year='{1}', Season='{2}', Episode='{3}', StartTime='{4}', Runtime='{5}'", CurrentRecording.Title, CurrentRecording.Year.ToLogString(), CurrentRecording.SeasonIdx.ToLogString(), CurrentRecording.EpisodeIdx.ToLogString(), CurrentRecording.StartTime == null ? "<empty>" : CurrentRecording.StartTime.ToString(), CurrentRecording.Runtime);

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

            BasicHandler.StartScrobble(CurrentRecording);

            return(true);
        }
        public bool Scrobble(string filename)
        {
            StopScrobble();

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

            try
            {
                CurrentProgram = GetCurrentProgram();
            }
            catch (Exception e)
            {
                TraktLogger.Error(e.Message);
                return(false);
            }
            if (CurrentProgram == null)
            {
                return(false);
            }
            CurrentProgram.IsScrobbling = true;

            if (CurrentProgram.Type == VideoType.Series)
            {
                TraktLogger.Info("Detected tv-series '{0}' playing in 4TR TV Live", CurrentProgram.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie '{0}' playing in 4TR TV Live", 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 '{0}' -> '{1}'", CurrentProgram.ToString(), videoInfo.ToString());
                        if (IsProgramWatched(CurrentProgram) && CurrentProgram.IsScrobbling)
                        {
                            ScrobbleProgram(CurrentProgram);
                        }
                        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.ScrobbleEpisode(videoInfo, TraktScrobbleStates.watching);
                        }
                        else
                        {
                            videoInfo.IsScrobbling = BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.watching);
                        }

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

            return(true);
        }
        private void ScrobbleProgram(VideoInfo program)
        {
            Thread scrobbleProgram = new Thread(delegate(object obj)
            {
                VideoInfo videoInfo = obj as VideoInfo;
                if (videoInfo == null)
                {
                    return;
                }

                TraktLogger.Info("Playback of '{0}' in 4TR tv-live is considered watched.", videoInfo.ToString());

                if (videoInfo.Type == VideoType.Series)
                {
                    BasicHandler.ScrobbleEpisode(videoInfo, TraktScrobbleStates.scrobble);
                }
                else
                {
                    BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.scrobble);
                }
            })
            {
                IsBackground = true,
                Name         = "Scrobble"
            };

            scrobbleProgram.Start(program);
        }
Esempio n. 8
0
        public bool Scrobble(string filename)
        {
            StopScrobble();

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

            // get recording details from tv database
            ControlServiceAgent layer     = new ControlServiceAgent();
            Recording           recording = layer.GetRecordingByFileName(filename);

            if (recording == null || string.IsNullOrEmpty(recording.Title))
            {
                TraktLogger.Info("Unable to get recording details from argus database.");
                return(false);
            }

            // get year from title if available, some EPG entries contain this
            string title = null;
            string year  = null;

            GetTitleAndYear(recording, out title, out year);

            CurrentRecording = new VideoInfo
            {
                Type         = recording.EpisodeNumber != null || recording.SeriesNumber != null ? VideoType.Series : VideoType.Movie,
                Title        = title,
                Year         = year,
                SeasonIdx    = recording.SeriesNumber == null ? null : recording.SeriesNumber.ToString(),
                EpisodeIdx   = recording.EpisodeNumber == null ? null : recording.EpisodeNumber.ToString(),
                IsScrobbling = true
            };

            if (CurrentRecording.Type == VideoType.Series)
            {
                TraktLogger.Info("Detected tv-series '{0}' playing in Argus TV-Recordings", CurrentRecording.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie '{0}' playing in Argus TV-Recordings", CurrentRecording.ToString());
            }

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

                VideoInfo videoInfo = stateInfo as VideoInfo;

                // maybe the program does not exist on trakt
                // ignore in future if it failed previously
                if (videoInfo.IsScrobbling)
                {
                    if (videoInfo.Type == VideoType.Series)
                    {
                        videoInfo.IsScrobbling = BasicHandler.ScrobbleEpisode(videoInfo, TraktScrobbleStates.watching);
                    }
                    else
                    {
                        videoInfo.IsScrobbling = BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.watching);
                    }

                    if (videoInfo.Equals(CurrentRecording))
                    {
                        CurrentRecording.IsScrobbling = videoInfo.IsScrobbling;
                    }
                }
            }), CurrentRecording, 3000, 900000);
            #endregion

            return(true);
        }
Esempio n. 9
0
        public void StopScrobble()
        {
            if (TraktTimer != null)
            {
                TraktTimer.Dispose();
            }

            if (CurrentRecording == null)
            {
                return;
            }

            // get current progress of player
            double progress = 0.0;

            if (g_Player.Duration > 0.0)
            {
                progress = (g_Player.CurrentPosition / g_Player.Duration) * 100.0;
            }

            TraktLogger.Debug("Current Position: {0}, Duration: {1}", g_Player.CurrentPosition.ToString(), g_Player.Duration.ToString());
            TraktLogger.Debug(string.Format("Percentage of '{0}' watched is {1}%", CurrentRecording.Title, progress > 100.0 ? "100" : progress.ToString("N2")));

            // if recording is at least 80% complete, consider watched
            // consider watched with invalid progress as well, we should never be exactly 0.0
            if ((progress == 0.0 || progress >= 80.0) && CurrentRecording.IsScrobbling)
            {
                // Show rate dialog
                ShowRateDialog(CurrentRecording);

                #region scrobble
                Thread scrobbleRecording = new Thread(delegate(object obj)
                {
                    VideoInfo videoInfo = obj as VideoInfo;
                    if (videoInfo == null)
                    {
                        return;
                    }

                    TraktLogger.Info("Playback of '{0}' in Argus tv-recording is considered watched.", videoInfo.ToString());

                    if (videoInfo.Type == VideoType.Series)
                    {
                        BasicHandler.ScrobbleEpisode(videoInfo, TraktScrobbleStates.scrobble);
                    }
                    else
                    {
                        BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.scrobble);
                    }
                })
                {
                    IsBackground = true,
                    Name         = "Scrobble"
                };

                scrobbleRecording.Start(CurrentRecording);
                #endregion
            }
            else
            {
                #region cancel watching
                TraktLogger.Info("Stopped playback of Argus tv-recording '{0}'", CurrentRecording.ToString());

                Thread cancelWatching = new Thread(delegate(object obj)
                {
                    VideoInfo videoInfo = obj as VideoInfo;
                    if (videoInfo == null)
                    {
                        return;
                    }

                    if (videoInfo.Type == VideoType.Series)
                    {
                        TraktEpisodeScrobble scrobbleData = new TraktEpisodeScrobble {
                            UserName = TraktSettings.Username, Password = TraktSettings.Password
                        };
                        TraktResponse response = TraktAPI.TraktAPI.ScrobbleEpisodeState(scrobbleData, TraktScrobbleStates.cancelwatching);
                        TraktLogger.LogTraktResponse(response);
                    }
                    else
                    {
                        TraktMovieScrobble scrobbleData = new TraktMovieScrobble {
                            UserName = TraktSettings.Username, Password = TraktSettings.Password
                        };
                        TraktResponse response = TraktAPI.TraktAPI.ScrobbleMovieState(scrobbleData, TraktScrobbleStates.cancelwatching);
                        TraktLogger.LogTraktResponse(response);
                    }
                })
                {
                    IsBackground = true,
                    Name         = "CancelWatching"
                };

                cancelWatching.Start(CurrentRecording);
                #endregion
            }

            CurrentRecording = null;
        }
Esempio n. 10
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;
        }
        public bool Scrobble(string filename)
        {
            StopScrobble();

            if (!g_Player.IsTVRecording) return false;

            // get recording details from tv database
            TvControlServiceAgent layer = new TvControlServiceAgent();
            Recording recording = layer.GetRecordingByFileName(filename);
            if (recording == null || string.IsNullOrEmpty(recording.Title))
            {
                TraktLogger.Info("Unable to get recording details from database.");
                return false;
            }

            // get year from title if available, some EPG entries contain this
            string title = null;
            string year = null;
            GetTitleAndYear(recording, out title, out year);

            CurrentRecording = new VideoInfo
            {
                Type = recording.EpisodeNumber != null || recording.SeriesNumber != null ? VideoType.Series : VideoType.Movie,
                Title = title,
                Year = year,
                SeasonIdx = recording.SeriesNumber == null ? null : recording.SeriesNumber.ToString(),
                EpisodeIdx = recording.EpisodeNumber == null ? null : recording.EpisodeNumber.ToString(),
                IsScrobbling = true
            };

            if (CurrentRecording.Type == VideoType.Series)
                TraktLogger.Info("Detected tv-series '{0}' playing in 4TR TV-Recordings", CurrentRecording.ToString());
            else
                TraktLogger.Info("Detected movie '{0}' playing in 4TR TV-Recordings", CurrentRecording.ToString());

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

                VideoInfo videoInfo = stateInfo as VideoInfo;

                // maybe the program does not exist on trakt
                // ignore in future if it failed previously
                if (videoInfo.IsScrobbling)
                {
                    if (videoInfo.Type == VideoType.Series)
                    {
                        videoInfo.IsScrobbling = BasicHandler.ScrobbleEpisode(videoInfo, TraktScrobbleStates.watching);
                    }
                    else
                    {
                        videoInfo.IsScrobbling = BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.watching);
                    }

                    if (videoInfo.Equals(CurrentRecording))
                        CurrentRecording.IsScrobbling = videoInfo.IsScrobbling;
                }

            }), CurrentRecording, 3000, 900000);
            #endregion

            return true;
        }
        public bool Scrobble(string filename)
        {
            StopScrobble();

            if (!g_Player.IsTV) return false;

            try
            {
                CurrentProgram = GetCurrentProgram();
            }
            catch (Exception e)
            {
                TraktLogger.Error(e.Message);
                return false;
            }
            if (CurrentProgram == null) return false;
            CurrentProgram.IsScrobbling = true;

            if (CurrentProgram.Type == VideoType.Series)
                TraktLogger.Info("Detected tv-series '{0}' playing in 4TR TV Live", CurrentProgram.ToString());
            else
                TraktLogger.Info("Detected movie '{0}' playing in 4TR TV Live", 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 '{0}' -> '{1}'", CurrentProgram.ToString(), videoInfo.ToString());
                        if (IsProgramWatched(CurrentProgram) && CurrentProgram.IsScrobbling)
                        {
                            ScrobbleProgram(CurrentProgram);
                        }
                        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.ScrobbleEpisode(videoInfo, TraktScrobbleStates.watching);
                        }
                        else
                        {
                            videoInfo.IsScrobbling = BasicHandler.ScrobbleMovie(videoInfo, TraktScrobbleStates.watching);
                        }

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

            return true;
        }