Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete collection and delete item from collection does not seem to work. #91

Open
Rickrat opened this issue Oct 21, 2022 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@Rickrat
Copy link

Rickrat commented Oct 21, 2022

Describe the bug
Deleting collections does not work for me.

To Reproduce

  1. Get a list of collections
  2. foreach one, loop through the items and remove them from the collection
  3. finally delete the collection

Expected behavior
I expected the collections to be deleted. However, after it runs without exceptions, the collections are there, still intact.

Side Note: There is a TODO throw in ApiService line 145 which I had to comment out to get this to function at all.

Here's my code:

var server = factory.CreateServer();
string url = server.Uri.ToString();

try
{
	var libs = await server.Libraries();
	var movies = libs.Single(c => c.Title == "Movies");

	var collections = await factory.PlexLibraryClient.GetCollectionsAsync(server.AccessToken, url, movies.Key, string.Empty);
	foreach (var col in collections.Collections)
	{
		var items = await factory.PlexLibraryClient.GetCollectionItemsAsync(server.AccessToken, url, col.RatingKey);
		foreach (var item in items.Media)
		{
			await factory.PlexLibraryClient.DeleteCollectionFromLibraryItemAsync(server.AccessToken, url, movies.Key, item.RatingKey, col.Title);
		}

		await factory.PlexLibraryClient.DeleteCollectionFromLibraryItemAsync(server.AccessToken, url, movies.Key, col.RatingKey, col.Title);
	}
	
}
catch (Exception ex)
{
	string msg = ex.Message;
}

@jensenkd
Copy link
Owner

I'll take a look. I'll also add a better unit test around Collections

@jensenkd jensenkd self-assigned this Oct 21, 2022
@jensenkd jensenkd added the bug Something isn't working label Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants