Skip to content

Commit

Permalink
Added support to remove custom lists from trakt.tv in maintenance mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
damienhaynes committed Apr 19, 2019
1 parent 3305419 commit 1cd1b27
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
34 changes: 34 additions & 0 deletions Maintenance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,39 @@ public static void RemoveMoviePausedState()
Thread.Sleep(2000);
}
}

public static void RemoveCustomLists()
{
if (Cancel) return;

// get paused info for episodes
UIUtils.UpdateStatus("Getting custom lists from trakt.tv");
var customLists = TraktAPI.TraktAPI.GetCustomLists();
if (customLists != null)
{
int i = 0;
int count = customLists.Count();
UIUtils.UpdateStatus($"Found {count} custom lists on trakt.tv");

foreach (var item in customLists)
{
if (Cancel) return;

UIUtils.UpdateStatus($"[{++i}/{count}] Removing custom list '{item.Name}' from trakt.tv.");
bool syncResponse = TraktAPI.TraktAPI.DeleteCustomList(item.Ids.Trakt.ToString());
if (syncResponse == false)
{
UIUtils.UpdateStatus($"Failed to remove custom list '{item.Name}' from trakt.tv", true);
Thread.Sleep(2000);
continue;
}
}
}
else
{
UIUtils.UpdateStatus("Failed to get current custom lists from trakt.tv", true);
Thread.Sleep(2000);
}
}
}
}
1 change: 1 addition & 0 deletions Settings/MaintenanceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public class MaintenanceSettings
public bool WatchlistMovies { get; set; }
public bool PausedEpisodes { get; set; }
public bool PausedMovies { get; set; }
public bool CustomLists { get; set; }
}
}
4 changes: 4 additions & 0 deletions TraktRater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@ private void StartMaintenance(MaintenanceSettings settings)
{
Maintenance.RemoveMoviePausedState();
}
if (settings.CustomLists)
{
Maintenance.RemoveCustomLists();
}

// finished
SetControlState(true);
Expand Down
34 changes: 24 additions & 10 deletions UI/MaintenanceDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions UI/MaintenanceDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ private void chkMovieResumeTimes_Click(object sender, EventArgs e)
{
Settings.PausedMovies = chkMoviePausedStates.Checked;
}

private void chkCustomLists_Click(object sender, EventArgs e)
{
Settings.CustomLists = chkCustomLists.Checked;
}
#endregion

}
}

0 comments on commit 1cd1b27

Please sign in to comment.