Jump to content

Delete items using the emby API


amateurgod

Recommended Posts

amateurgod

i keep getting this error while trying to delete items using the emby API
 

Quote

Failed to delete item {Item_ID} from Emby: 400, Value cannot be null. (Parameter 'user')


however, the API docs don't say that this API endpoint requires a user parameter

Here is my code for this section

def delete_item(item_id):

    url = f"{EMBY_URL}/Items"

    params = {

        'Ids': item_id,

        'api_key': EMBY_API_KEY

    }

    response = requests.delete(url, params=params)

    if response.status_code == 200:

        print(f"Item {item_id} deleted successfully from Emby.")

    else:

        print(f"Failed to delete item {item_id} from Emby: {response.status_code}, {response.text}")

 

Edited by amateurgod
fix code block
Link to comment
Share on other sites

amateurgod

i fixed it, the solution was to not pass them as params and just put them in the URL like so 

 

def delete_item(item_id):
    url = f"{EMBY_URL}/Items?{item_id}&api_key={EMBY_API_KEY}"
    response = requests.delete(url)
    if response.status_code == 204:
        print(f"Item {item_id} deleted successfully from Emby.")
    else:
        print(f"Failed to delete item {item_id} from Emby: {response.status_code}, {response.text}")

 

Link to comment
Share on other sites

amateurgod

oh actually nevermind, i thought i fixed it however its marking items as deleted in emby but not deleting them from the local filesystem

the logs arent showing any errors either 

 

2024-02-10 14:25:43.614 Info Server: http/1.1 DELETE http://host3/emby/Items?=95688&api_key=x_secret5_x. UserAgent: python-requests/2.25.1 2024-02-10 14:25:43.615 Info Server: http/1.1 Response 204 to host4. Time: 0ms. DELETE http://host3/emby/Items?=95688&api_key=x_secret5_x 2024-02-10 14:25:44.035 Info Server: http/1.1 DELETE http://host3/emby/Items?=95684&api_key=x_secret5_x. UserAgent: python-requests/2.25.1 2024-02-10 14:25:44.035 Info Server: http/1.1 Response 204 to host4. Time: 1ms. DELETE http://host3/emby/Items?=95684&api_key=x_secret5_x 2024-02-10 14:25:44.532 Info Server: http/1.1 DELETE http://host3/emby/Items?=94845&api_key=x_secret5_x. UserAgent: python-requests/2.25.1 2024-02-10 14:25:44.533 Info Server: http/1.1 Response 204 to host4. Time: 1ms. DELETE http://host3/emby/Items?=94845&api_key=x_secret5_x 2024-02-10 14:25:45.080 Info Server: http/1.1 DELETE http://host3/emby/Items?=94833&api_key=x_secret5_x. UserAgent: python-requests/2.25.1

 

Link to comment
Share on other sites

adminExitium

AFAIK, you need to use the User Items endpoint like /Users/<UserID/Items/<ItemID> for deleting an item.

Link to comment
Share on other sites

amateurgod
4 minutes ago, adminExitium said:

AFAIK, you need to use the User Items endpoint like /Users/<UserID/Items/<ItemID> for deleting an item.

oh the api docs says you can use the item endpoint
image.thumb.png.a00f1afdebf82b0af30c11c08179f883.png

Link to comment
Share on other sites

adminExitium

That may still work but it needs to be done as a user like /Users/<UserID/Items?Ids=<ItemID>

Link to comment
Share on other sites

amateurgod
27 minutes ago, adminExitium said:

That may still work but it needs to be done as a user like /Users/<UserID/Items?Ids=<ItemID>

i tried that endpoint and i get an error 404 where as my original endpoint worked, it deleted the files in emby from the library just wasnt deleting them from the file system too 

Link to comment
Share on other sites

Try posting to Items/Delete. This is the newest one because it accepts multiple.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...