public static void RemoveMovieFromWatchList(string title, string year, string imdbid, bool updateMovingPicturesFilters) { if (!GUICommon.CheckLogin(false)) { return; } TraktMovieSync syncObject = BasicHandler.CreateMovieSyncData(title, year, imdbid); if (syncObject == null) { return; } Thread syncThread = new Thread(delegate(object obj) { TraktSyncResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(obj as TraktMovieSync, TraktSyncModes.unwatchlist); if (response == null || response.Status != "success") { return; } if (updateMovingPicturesFilters && IsMovingPicturesAvailableAndEnabled) { // Update Categories & Filters MovingPictures.ClearWatchListCache(); MovingPictures.UpdateCategoriesAndFilters(); } GUI.GUIWatchListMovies.ClearCache(TraktSettings.Username); }) { IsBackground = true, Name = "RemoveWatchList" }; syncThread.Start(syncObject); }
private void CopyList(TraktListDetail sourceList, TraktList newList) { var copyList = new CopyList { Username = CurrentUser, Source = sourceList, Destination = newList }; var copyThread = new Thread((obj) => { var copyParams = obj as CopyList; // first create new list TraktLogger.Info("Creating new list online. Privacy = '{0}', Name = '{1}'", copyParams.Destination.Privacy, copyParams.Destination.Name); var response = TraktAPI.TraktAPI.CreateCustomList(copyParams.Destination); if (response == null || response.Ids == null) { TraktLogger.Error("Failed to create user list. List Name = '{0}'", copyParams.Destination.Name); return; } // get items from other list var userListItems = TraktAPI.TraktAPI.GetUserListItems(copyParams.Source.User.Ids.Slug, copyParams.Source.Ids.Trakt.ToString(), "min"); if (userListItems == null) { TraktLogger.Error("Failed to get user list items. List Name = '{0}', ID = '{1}'", copyParams.Destination.Name, copyParams.Source.Ids.Trakt); return; } // copy items to new list var itemsToAdd = new TraktSyncAll(); foreach (var item in userListItems) { var listItem = new TraktListItem(); listItem.Type = item.Type; switch (item.Type) { case "movie": if (itemsToAdd.Movies == null) { itemsToAdd.Movies = new List <TraktMovie>(); } itemsToAdd.Movies.Add(new TraktMovie { Ids = item.Movie.Ids }); break; case "show": if (itemsToAdd.Shows == null) { itemsToAdd.Shows = new List <TraktShow>(); } itemsToAdd.Shows.Add(new TraktShow { Ids = item.Show.Ids }); break; case "season": if (itemsToAdd.Seasons == null) { itemsToAdd.Seasons = new List <TraktSeason>(); } itemsToAdd.Seasons.Add(new TraktSeason { Ids = item.Season.Ids }); break; case "episode": if (itemsToAdd.Episodes == null) { itemsToAdd.Episodes = new List <TraktEpisode>(); } itemsToAdd.Episodes.Add(new TraktEpisode { Ids = item.Episode.Ids }); break; case "person": if (itemsToAdd.People == null) { itemsToAdd.People = new List <TraktPerson>(); } itemsToAdd.People.Add(new TraktPerson { Ids = item.Person.Ids }); break; } } // add items to the list var ItemsAddedResponse = TraktAPI.TraktAPI.AddItemsToList("me", response.Ids.Trakt.ToString(), itemsToAdd); if (ItemsAddedResponse != null) { TraktLists.ClearListCache(TraktSettings.Username); TraktCache.ClearCustomListCache(); // updated MovingPictures categories and filters menu if (TraktHelper.IsMovingPicturesAvailableAndEnabled) { MovingPictures.UpdateCategoriesMenu(SyncListType.CustomList); MovingPictures.UpdateFiltersMenu(SyncListType.CustomList); } } }) { Name = "CopyList", IsBackground = true }; copyThread.Start(copyList); }
private void StartSync() { SetSyncControlProperties(true); var syncThread = new Thread(() => { if (TraktSettings.AccountStatus != ConnectionState.Connected) { // stop sync SetSyncControlProperties(false); TraktSettings.AccountStatus = ConnectionState.Pending; return; } TraktLogger.Info("Library and Playback Sync started for all enabled plugins"); // get data from online and store in cache so its readily available for plugin sync // data will also be used in user activity feed on the dashboard if (!TraktCache.RefreshData()) { return; } foreach (var item in clbPlugins.CheckedItems) { try { switch (item.ToString()) { case "Moving Pictures": var movingPictures = new MovingPictures(TraktSettings.MovingPictures); movingPictures.SyncLibrary(); movingPictures.SyncProgress(); break; case "MP-TVSeries": var tvSeries = new TVSeries(TraktSettings.TVSeries); tvSeries.SyncLibrary(); tvSeries.SyncProgress(); break; case "My Videos": var myVideos = new MyVideos(TraktSettings.MyVideos); myVideos.SyncLibrary(); myVideos.SyncProgress(); break; case "My Films": var myFilms = new MyFilmsHandler(TraktSettings.MyFilms); myFilms.SyncLibrary(); myFilms.SyncProgress(); break; } } catch (Exception ex) { TraktLogger.Error("Error synchronising library, Plugin = '{0}', Error = '{1}'", item.ToString(), ex.Message); continue; } } // save user activity cache TraktCache.Save(); TraktLogger.Info("Library and Playback Sync completed for all enabled plugins"); SetSyncControlProperties(false); if (SilentMode || AutoCloseAfterSync) { CloseConfig(); } }) { Name = "Sync", IsBackground = true }; syncThread.Start(); }