public static TmdbEpisodeImages GetEpisodeImages(int?id, int season, int episode, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it var episodeImages = Episodes.FirstOrDefault(e => e.Id == id && e.Season == season && e.Episode == episode); if (episodeImages != null) { if (forceUpdate) { return(episodeImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbEpisodeImageMaxCacheAge, 0, 0, 0, 0)) < Convert.ToDateTime(episodeImages.RequestAge)) { return(episodeImages); } TraktLogger.Info("Episode image cache expired. TMDb ID = '{0}', Season = '{1}', Episode = '{2}', Request Age = '{3}'", id, season, episode, episodeImages.RequestAge); RemoveEpisodeImagesFromCache(episodeImages, season, episode); } // get movie images from tmdb and add to the cache episodeImages = TmdbAPI.TmdbAPI.GetEpisodeImages(id.ToString(), season, episode); AddEpisodeImagesToCache(episodeImages, id, season, episode); return(episodeImages); }
public static TmdbSeasonImages GetSeasonImages(int?id, int season, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it var seasonImages = Seasons.FirstOrDefault(s => s.Id == id && s.Season == season); if (seasonImages != null) { if (forceUpdate) { return(seasonImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbSeasonImageMaxCacheAge, 0, 0, 0, 0)) < Convert.ToDateTime(seasonImages.RequestAge)) { return(seasonImages); } TraktLogger.Info("Season image cache expired. TMDb ID = '{0}', Season = '{1}', Request Age = '{2}'", id, season, seasonImages.RequestAge); RemoveSeasonImagesFromCache(seasonImages, season); } // get movie images from tmdb and add to the cache seasonImages = TmdbAPI.TmdbAPI.GetSeasonImages(id.ToString(), season); AddSeasonImagesToCache(seasonImages, id, season); return(seasonImages); }
public static TmdbMovieImages GetMovieImages(int?id, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it var movieImages = Movies.FirstOrDefault(m => m.Id == id); if (movieImages != null) { if (forceUpdate) { return(movieImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbMovieImageMaxCacheAge, 0, 0, 0, 0)) < Convert.ToDateTime(movieImages.RequestAge)) { return(movieImages); } TraktLogger.Info("Movie image cache expired. TMDb ID = '{0}', Request Age = '{1}'", id, movieImages.RequestAge); RemoveMovieImagesFromCache(movieImages); } // get movie images from tmdb and add to the cache movieImages = TmdbAPI.TmdbAPI.GetMovieImages(id.ToString()); AddMovieImagesToCache(movieImages); return(movieImages); }
public void StopScrobble() { istStoppingScrobble = true; if (TraktTimer != null) { TraktTimer.Dispose(); } if (EbasicHandler.getCurrentProgram() == null) { return; } if (IsProgramWatched(EbasicHandler.getCurrentProgram()) && EbasicHandler.IsCurrentProgramScrobbling()) { TraktLogger.Info("Playback of program on Live TV is considered watched. Title = '{0}'", EbasicHandler.getCurrentProgram().ToString()); BasicHandler.StopScrobble(EbasicHandler.getCurrentProgram(), true); } else { BasicHandler.StopScrobble(EbasicHandler.getCurrentProgram()); } EbasicHandler.clearCurrentProgram(); }
public OnlineVideos(int priority) { TraktLogger.Info("Initialising OnlineVideos plugin handler"); // check if plugin exists otherwise plugin could accidently get added to list string pluginFilename = Path.Combine(Config.GetSubFolder(Config.Dir.Plugins, "Windows"), "OnlineVideos.MediaPortal1.dll"); if (!File.Exists(pluginFilename)) { throw new FileNotFoundException("Plugin not found!"); } else { var fvi = FileVersionInfo.GetVersionInfo(pluginFilename); if (new Version(fvi.FileVersion) < new Version(1, 9, 0, 3341)) { throw new FileLoadException("Plugin does not meet the minimum requirements, check you have the latest version installed!"); } } TraktLogger.Debug("Adding Hooks to OnlineVideos"); // Subscribe to Player Events ovObject = (GUIOnlineVideos)GUIWindowManager.GetWindow((int)ExternalPluginWindows.OnlineVideos); ovObject.TrackVideoPlayback += new GUIOnlineVideos.TrackVideoPlaybackHandler(TrackVideoPlayback); Priority = priority; }
protected override void OnPageLoad() { base.OnPageLoad(); if (string.IsNullOrEmpty(_loadParameter) && CurrentPerson == null) { TraktLogger.Info("Exiting Person Summary as there is no loading parameter or current person set"); GUIWindowManager.ActivateWindow(GUIWindowManager.GetPreviousActiveWindow()); return; } // Clear GUI Properties ClearProperties(); // Init Properties InitProperties(); // Load the correct view switch (CurrentView) { case View.Summary: LoadPersonSummary(); break; case View.MovieCredits: LoadMovieCredits(); break; case View.ShowCredits: LoadShowCredits(); break; } }
/// <summary> /// Gets the current program /// </summary> /// <returns></returns> private VideoInfo GetCurrentProgram() { VideoInfo videoInfo = new VideoInfo(); // get current program details Program program = TVHome.Navigator.Channel.CurrentProgram; if (program == null || string.IsNullOrEmpty(program.Title)) { TraktLogger.Info("Unable to get current program from database."); return(null); } else { string title = null; string year = null; GetTitleAndYear(program, out title, out year); videoInfo = new VideoInfo { Type = !string.IsNullOrEmpty(program.EpisodeNum) || !string.IsNullOrEmpty(program.SeriesNum) ? VideoType.Series : VideoType.Movie, Title = title, Year = year, SeasonIdx = program.SeriesNum, EpisodeIdx = program.EpisodeNum, StartTime = program.StartTime, Runtime = GetRuntime(program) }; } return(videoInfo); }
/// <summary> /// Gets the current program /// </summary> /// <returns></returns> private VideoInfo GetCurrentProgram() { VideoInfo videoInfo = new VideoInfo(); // get current program details Program program = TVHome.Navigator.Channel.CurrentProgram; if (program == null || string.IsNullOrEmpty(program.Title)) { TraktLogger.Info("Unable to get current program from database"); return(null); } else { string title = null; string year = null; BasicHandler.GetTitleAndYear(program.Title, out title, out year); videoInfo = new VideoInfo { Type = !string.IsNullOrEmpty(program.EpisodeNum) || !string.IsNullOrEmpty(program.SeriesNum) ? VideoType.Series : VideoType.Movie, Title = title, Year = year, SeasonIdx = program.SeriesNum, EpisodeIdx = program.EpisodeNum, StartTime = program.StartTime, Runtime = GetRuntime(program) }; TraktLogger.Info("Current program details. Title='{0}', Year='{1}', Season='{2}', Episode='{3}', StartTime='{4}', Runtime='{5}'", videoInfo.Title, videoInfo.Year.ToLogString(), videoInfo.SeasonIdx.ToLogString(), videoInfo.EpisodeIdx.ToLogString(), videoInfo.StartTime == null ? "<empty>" : videoInfo.StartTime.ToString(), videoInfo.Runtime); } return(videoInfo); }
internal static void StartScrobble(object scrobbledata) { var scrobbleThread = new Thread((objVideoInfo) => { if (scrobbledata is TraktScrobbleEpisode) { var info = objVideoInfo as TraktScrobbleEpisode; #if DEBUG TraktLogger.Info("Starting new thread to manually scrobble show: {0}, S{1}xE{2}", info.Show.Title, info.Episode.Season, info.Episode.Number); TraktLogger.Info(info.ToString()); #endif var response = TraktAPI.TraktAPI.StartEpisodeScrobble(info); //TraktLogger.LogTraktResponse(response); } else if (scrobbledata is TraktScrobbleMovie) { var info = objVideoInfo as TraktScrobbleMovie; #if DEBUG TraktLogger.Info("Starting new thread to manually scrobble movie: {0},{1}", info.Movie.Title, info.Movie.Year); #endif var response = TraktAPI.TraktAPI.StartMovieScrobble(info); TraktLogger.LogTraktResponse(response); } else { TraktLogger.Info("Bad data passed {0}", objVideoInfo.ToString()); } }) { IsBackground = true, Name = "Scrobble" }; scrobbleThread.Start(scrobbledata); }
private void OnRateItem(MFMovie movie, string value) { TraktLogger.Info("Received rating event from MyFilms"); if (TraktSettings.AccountStatus != ConnectionState.Connected) { return; } // don't do anything if movie is blocked if (TraktSettings.BlockedFilenames.Contains(movie.File) || TraktSettings.BlockedFolders.Any(f => movie.File.ToLowerInvariant().Contains(f.ToLowerInvariant()))) { TraktLogger.Info("Movie {0} is on the blocked list so we didn't update Trakt", movie.Title); return; } // My Films is a 100 point scale out of 10. Treat as decimal and then round off string rating = Math.Round(Convert.ToDecimal(value), MidpointRounding.AwayFromZero).ToString(); TraktRateResponse response = null; Thread rateThread = new Thread((o) => { MFMovie tMovie = o as MFMovie; response = TraktAPI.TraktAPI.RateMovie(CreateRateData(tMovie, rating)); TraktAPI.TraktAPI.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(movie); }
private void OnToggleWatched(MFMovie movie, bool watched, int count) { TraktLogger.Info("Received togglewatched event from My Films"); if (TraktSettings.AccountStatus != ConnectionState.Connected) { return; } // don't do anything if movie is blocked if (TraktSettings.BlockedFilenames.Contains(movie.File) || TraktSettings.BlockedFolders.Any(f => movie.File.ToLowerInvariant().Contains(f.ToLowerInvariant()))) { TraktLogger.Info("Movie {0} is on the blocked list so we didn't update Trakt", movie.Title); return; } Thread toggleWatchedThread = new Thread((o) => { MFMovie tMovie = o as MFMovie; TraktResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(tMovie), watched ? TraktSyncModes.seen : TraktSyncModes.unseen); TraktAPI.TraktAPI.LogTraktResponse(response); }) { IsBackground = true, Name = "ToggleWatched" }; toggleWatchedThread.Start(movie); }
private void OnStoppedMovie(MFMovie movie) { if (TraktSettings.AccountStatus != ConnectionState.Connected) { return; } if (!TraktSettings.BlockedFilenames.Contains(movie.File) && !TraktSettings.BlockedFolders.Any(f => movie.File.ToLowerInvariant().Contains(f.ToLowerInvariant()))) { TraktLogger.Info("Stopped My Films movie playback: '{0}'", movie.Title); CurrentMovie = null; StopScrobble(); // send cancelled watching state Thread cancelWatching = new Thread(delegate() { TraktMovieScrobble scrobbleData = new TraktMovieScrobble { UserName = TraktSettings.Username, Password = TraktSettings.Password }; TraktResponse response = TraktAPI.TraktAPI.ScrobbleMovieState(scrobbleData, TraktScrobbleStates.cancelwatching); TraktAPI.TraktAPI.LogTraktResponse(response); }) { IsBackground = true, Name = "CancelWatching" }; cancelWatching.Start(); } }
/// <summary> /// Saves any movies that return as 'already_exists' from library sync calls /// </summary> /// <param name="response">Trakt Sync Movie Response</param> public static void InsertAlreadyExistMovies(TraktSyncResponse response) { if (response == null || response.AlreadyExistMovies == null) { return; } foreach (var movie in response.AlreadyExistMovies) { if (TraktSettings.AlreadyExistMovies == null) { TraktSettings.AlreadyExistMovies = new SyncMovieCheck(); } TraktLogger.Info("Inserting movie into already-exist list: Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID); if (TraktSettings.AlreadyExistMovies.Movies != null) { if (!TraktSettings.AlreadyExistMovies.Movies.Contains(movie)) { TraktSettings.AlreadyExistMovies.Movies.Add(movie); } } else { TraktSettings.AlreadyExistMovies.Movies = new List <TraktMovieSync.Movie>(); TraktSettings.AlreadyExistMovies.Movies.Add(movie); } } }
public static void loadCache() { if (!File.Exists(cacheFile)) { StreamWriter fs = new StreamWriter(cacheFile); fs.WriteLine("#LocalizedTitle|#JSONOriginalRecord"); fs.Close(); } TraktLogger.Info("Loading EPG cache"); StreamReader showsEPGCacheFile = new StreamReader(cacheFile); //showsEPGCacheFile.ReadLine(); //the first line is the header, skip. EPGCacheDictionary = new Dictionary <string, string>(StringComparer.CurrentCultureIgnoreCase); TraktLogger.Info("reading first line {0}", showsEPGCacheFile.ReadLine()); string line; char separator = '|'; int count = 0; while ((line = showsEPGCacheFile.ReadLine()) != null) { string[] substrings = line.Split(separator); EPGCacheDictionary.Add(substrings[0], substrings[1]); count++; } TraktLogger.Info("Loaded '{0}' items", count); showsEPGCacheFile.Close(); }
private void DeleteList(TraktUserList list) { if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.ConfirmDeleteList, false)) { return; } GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() => { TraktLogger.Info("Deleting list '{0}'", list.Name); TraktList deleteList = new TraktList { UserName = TraktSettings.Username, Password = TraktSettings.Password, Slug = list.Slug }; return(TraktAPI.TraktAPI.ListDelete(deleteList)); }, delegate(bool success, object result) { if (success) { TraktResponse response = result as TraktResponse; TraktLogger.LogTraktResponse <TraktResponse>(response); if (response.Status == "success") { // reload with new list TraktLists.ClearCache(TraktSettings.Username); LoadLists(); } else { GUIUtils.ShowNotifyDialog(Translation.Lists, response.Error); } } }, Translation.DeletingList, true); }
/// <summary> /// Gets the current program /// </summary> /// <returns></returns> private VideoInfo GetCurrentProgram() { VideoInfo videoInfo = new VideoInfo(); // get current program details GuideProgram program = ForTheRecordMain.GetProgramAt(DateTime.Now); if (program == null || string.IsNullOrEmpty(program.Title)) { TraktLogger.Info("Unable to get current program from database."); return(null); } else { string title = null; string year = null; GetTitleAndYear(program, out title, out year); videoInfo = new VideoInfo { Type = program.EpisodeNumber != null || program.SeriesNumber != null ? VideoType.Series : VideoType.Movie, Title = title, Year = year, SeasonIdx = program.SeriesNumber == null ? null : program.SeriesNumber.ToString(), EpisodeIdx = program.EpisodeNumber == null ? null : program.EpisodeNumber.ToString(), StartTime = program.StartTime, Runtime = GetRuntime(program) }; } return(videoInfo); }
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); }
private void StartScrobble() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); if (string.IsNullOrEmpty(settings.TraktOAuthToken)) { TraktLogger.Info("0Auth Token not available"); return; } if (!Login(settings.TraktOAuthToken)) { return; } if (_dataMovie.Movie != null && IsMovie(currentPlayingMediaItem)) { _dataMovie.Progress = 0; var response = TraktAPI.StartMovieScrobble(_dataMovie); TraktLogger.LogTraktResponse(response); return; } if (_dataEpisode != null && IsSeries(currentPlayingMediaItem)) { _dataEpisode.Progress = 0; var response = TraktAPI.StartEpisodeScrobble(_dataEpisode); TraktLogger.LogTraktResponse(response); return; } TraktLogger.Info("Can't start scrobble, scrobbledata not available"); }
public void StopScrobble() { if (CurrentRecording == null) { return; } // get current progress of player bool watched = false; double progress = 0.0; if (g_Player.Duration > 0.0) { progress = Math.Round((g_Player.CurrentPosition / g_Player.Duration) * 100.0, 2); } TraktLogger.Info("Video recording has stopped, checking progress. Title = '{0}', Current Position = '{1}', Duration = '{2}', Progress = '{3}%'", CurrentRecording.Title, g_Player.CurrentPosition.ToString(), g_Player.Duration.ToString(), progress > 100.0 ? "100" : progress.ToString()); // 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) { watched = true; // Show rate dialog BasicHandler.ShowRateDialog(CurrentRecording); } BasicHandler.StopScrobble(CurrentRecording, watched); CurrentRecording = null; }
static void GetTrailerUrl(string htmlPage) { // get playback url from stream TraktLogger.Debug("Getting playback url from page '{0}'", htmlPage); GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() => { var ovHosterProxy = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(OnlineVideosHosterProxy).Assembly.FullName, typeof(OnlineVideosHosterProxy).FullName) as OnlineVideosHosterProxy; var url = ovHosterProxy.GetVideoUrls(htmlPage); return(url); }, delegate(bool success, object result) { string url = result as string; if (success) { if (!string.IsNullOrEmpty(url)) { BufferTrailer(url); } else { TraktLogger.Info("Unable to get url for trailer playback.", url); GUIUtils.ShowNotifyDialog(GUI.Translation.Error, GUI.Translation.UnableToPlayTrailer); } } }, GUI.Translation.GettingTrailerUrls, false); }
private void OnToggleWatched(List <AnimeEpisode> episodes, bool state) { if (TraktSettings.AccountStatus != ConnectionState.Connected) { return; } TraktLogger.Info("Received togglewatched event from my anime"); Thread toggleWatched = new Thread(delegate() { foreach (var series in episodes.Select(e => e.Series.TvDB_ID).Distinct().ToList()) { if (series == null) { continue; } TraktEpisodeSync episodeSyncData = CreateSyncData(AnimeSeries.GetSeriesWithSpecificTvDB((int)series).First(), episodes); if (episodeSyncData == null) { return; } TraktResponse response = TraktAPI.TraktAPI.SyncEpisodeLibrary(episodeSyncData, state ? TraktSyncModes.seen : TraktSyncModes.unseen); TraktAPI.TraktAPI.LogTraktResponse(response); } }) { IsBackground = true, Name = "ToggleWatched" }; toggleWatched.Start(); }
private void OnRateSeries(AnimeSeries series, string rateValue) { if (TraktSettings.AccountStatus != ConnectionState.Connected) { return; } TraktLogger.Info("Received rating event for series from my anime"); Thread rateThread = new Thread(delegate() { TraktRateSeries seriesRateData = CreateSeriesRateData(series, rateValue); if (seriesRateData == null) { return; } TraktRateResponse response = TraktAPI.TraktAPI.RateSeries(seriesRateData); // check for any error and notify TraktAPI.TraktAPI.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(); }
public static TmdbSeasonImages GetSeasonImages(int?id, int season, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it TmdbSeasonImages seasonImages; if (Seasons.TryGetValue(Tuple.Create(id, season), out seasonImages)) { if (forceUpdate) { return(seasonImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbSeasonImageMaxCacheAge, 0, 0, 0, 0)) < seasonImages.RequestAge.ToDateTime()) { return(seasonImages); } TraktLogger.Info("Season image cache expired. TMDb ID = '{0}', Season = '{1}', Request Age = '{2}'", id, seasonImages.Season, seasonImages.RequestAge); RemoveSeasonImagesFromCache(seasonImages); } // get movie images from tmdb and add to the cache seasonImages = TmdbAPI.TmdbAPI.GetSeasonImages(id.ToString(), season); AddSeasonImagesToCache(seasonImages); return(seasonImages); }
public static TmdbPeopleImages GetPersonImages(int?id, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it TmdbPeopleImages personImages; if (People.TryGetValue(id, out personImages)) { if (forceUpdate) { return(personImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbPersonImageMaxCacheAge, 0, 0, 0, 0)) < personImages.RequestAge.ToDateTime()) { return(personImages); } TraktLogger.Info("People image cache expired. TMDb ID = '{0}', Request Age = '{1}'", id, personImages.RequestAge); RemovePeopleImagesFromCache(personImages); } // get movie images from tmdb and add to the cache personImages = TmdbAPI.TmdbAPI.GetPeopleImages(id.ToString()); AddPeopleImagesToCache(personImages); return(personImages); }
public static void Init() { TraktLogger.Info("Loading TMDb request cache"); // load cached images from files and convert them to a thread-safe dictionary keyed by ID (and season/episode) var movies = LoadFileCache(MovieCacheFile, "[]").FromJSONArray <TmdbMovieImages>().ToList(); Movies = new ConcurrentDictionary <int?, TmdbMovieImages>(movies.Distinct().ToDictionary(m => m.Id)); var shows = LoadFileCache(ShowCacheFile, "[]").FromJSONArray <TmdbShowImages>().ToList(); Shows = new ConcurrentDictionary <int?, TmdbShowImages>(shows.Distinct().ToDictionary(s => s.Id)); var seasons = LoadFileCache(SeasonCacheFile, "[]").FromJSONArray <TmdbSeasonImages>().ToList(); Seasons = new ConcurrentDictionary <Tuple <int?, int>, TmdbSeasonImages>(seasons.Distinct().ToDictionary(s => Tuple.Create(s.Id, s.Season))); var episodes = LoadFileCache(EpisodeCacheFile, "[]").FromJSONArray <TmdbEpisodeImages>().ToList(); Episodes = new ConcurrentDictionary <Tuple <int?, int, int>, TmdbEpisodeImages>(episodes.Distinct().ToDictionary(e => Tuple.Create(e.Id, e.Season, e.Episode))); var people = LoadFileCache(PersonCacheFile, "[]").FromJSONArray <TmdbPeopleImages>().ToList(); People = new ConcurrentDictionary <int?, TmdbPeopleImages>(people.Distinct().ToDictionary(p => p.Id)); // get updated configuration from TMDb GetTmdbConfiguration(); }
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); }
/// <summary> /// Populates GUIListControl with titles from the search. the searchLevel defines if it's the first search, thus the manual search button is needed /// or a subsequent search, inserting the back button instead. /// </summary> /// <param name="search"></param> /// <param name="searchLevel"></param> private void PopulateListControl(IEnumerable <TraktSearchResult> search, int searchLevel = 0) { resultListControl.Clear(); GUIListItem item; if (searchlevel < 1) { //manualSearch button, it's first search item = new GUIListItem("Manual Search"); item.TVTag = "FirstButton"; resultListControl.Add(item); } else { item = new GUIListItem("Back"); item.TVTag = "FirstButton"; resultListControl.Add(item); } //Now populating items IEnumerator <TraktSearchResult> p = search.GetEnumerator(); while (p.MoveNext()) { if (p.Current.Type == "show") { item = new GUIListItem(p.Current.Show.Title); item.TVTag = p.Current.Show; #if DEBUG TraktLogger.Info("Adding '{0}' to item '{1}'. Type detected: '{2}'", p.Current.Show.Title, item.Label, p.Current.Type); #endif resultListControl.Add(item); } if (p.Current.Type == "season") { item = new GUIListItem(string.Format("Season {0}", p.Current.Season.Number)); item.TVTag = p.Current.Season; #if DEBUG TraktLogger.Info("adding Season '{0}' to the list as {1}. Object type: {2}", p.Current.Season.Number, p.Current.Type, p.Current.Season.ToString()); #endif resultListControl.Add(item); } if (p.Current.Type == "episode") { item = new GUIListItem(string.Format("Episode {0}: {1} ", p.Current.Episode.Number, p.Current.Episode.Title)); item.TVTag = p.Current.Episode; #if DEBUG TraktLogger.Info("adding Episode '{0}' to the list", p.Current.Episode.Number); #endif resultListControl.Add(item); } if (p.Current.Type == "movie") { item = new GUIListItem(p.Current.Movie.Title); item.TVTag = p.Current.Movie; resultListControl.Add(item); } } currentSearch = search; }
public void StopScrobble() { if (CurrentMovie == null) { return; } var scrobbleData = CreateScrobbleData(CurrentMovie); // check if movie is considered 'watched' if (scrobbleData.Progress >= WatchedPercent) { ShowRateDialog(CurrentMovie); } var scrobbleMovie = new Thread((objScrobble) => { var tScrobbleData = objScrobble as TraktScrobbleMovie; if (tScrobbleData == null) { return; } TraktScrobbleResponse response = null; if (tScrobbleData.Progress >= WatchedPercent) { TraktLogger.Info("Sending 'stop' scrobble of movie to trakt.tv. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", tScrobbleData.Movie.Title, tScrobbleData.Movie.Year, tScrobbleData.Movie.Ids.Imdb ?? "<empty>"); response = TraktAPI.TraktAPI.StopMovieScrobble(tScrobbleData); if (response != null && response.Movie != null && response.Action == "scrobble") { // add to cache TraktCache.AddMovieToWatchHistory(response.Movie); } } else { TraktLogger.Info("Sending 'pause' scrobble of movie to trakt.tv. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", tScrobbleData.Movie.Title, tScrobbleData.Movie.Year, tScrobbleData.Movie.Ids.Imdb ?? "<empty>"); response = TraktAPI.TraktAPI.PauseMovieScrobble(tScrobbleData); if (response != null && response.Movie != null && response.Action == "pause") { // add to cache TraktCache.AddMovieToPausedData(response.Movie, response.Progress); } } TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Scrobble" }; scrobbleMovie.Start(scrobbleData); CurrentMovie = null; }
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; }
public static void DeInit() { TraktLogger.Info("Saving TMDb request cache"); SaveFileCache(MovieCacheFile, Movies.Values.ToList().ToJSON()); SaveFileCache(ShowCacheFile, Shows.Values.ToList().ToJSON()); SaveFileCache(SeasonCacheFile, Seasons.Values.ToList().ToJSON()); SaveFileCache(EpisodeCacheFile, Episodes.Values.ToList().ToJSON()); SaveFileCache(PersonCacheFile, People.Values.ToList().ToJSON()); }