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.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); }