Amything 122 Posted October 12, 2024 Posted October 12, 2024 (edited) I'm getting a successful response but the collection remains. Not sure what is going on here. import requests url = "http://example.com:123/Items?6721789&api_key=123abc" response = requests.delete(url) if response.status_code == 204: print(f"Successfully deleted item {item_id}") else: print(f"Error deleting item {item_id}, response: {response}") Outputting "Successfully deleted item 6721789" as an example. However the collection was not actually deleted. Emby log: Quote 2024-10-12 13:54:53.712 Info Server: http/1.1 DELETE http://emby_remote_ip:42430/Items?=6721789&api_key=x_secret2_x. UserAgent: python-requests/2.31.0 2024-10-12 13:54:53.713 Info Server: http/1.1 Response 204 to host1. Time: 0ms. DELETE http://emby_remote_ip:42430/Items?=6721789&api_key=x_secret2_x 2024 Edited October 12, 2024 by Amything
Amything 122 Posted October 12, 2024 Author Posted October 12, 2024 I tested removing every item from the collection. That seems to do the trick.
hthgihwaymonk 34 Posted October 13, 2024 Posted October 13, 2024 delete_url = f'{emby_server_url}/Items/{collection_id}' headers = {'X-Emby-Token': emby_api_key, 'accept': '*/*'} response = requests.delete(delete_url, headers=headers) if response.status_code == 204: print(f'Successfully deleted collection with ID "{collection_id}"') else: print(f'Error deleting collection with ID "{collection_id}": {response.text}') I use the above and it works.
Amything 122 Posted October 13, 2024 Author Posted October 13, 2024 @hthgihwaymonk Thanks for the reply! I've tried that and got "Value cannot be null. (Parameter 'user')". I've tried a few things, adding user to the url, as a url param and header value without success.
hthgihwaymonk 34 Posted October 13, 2024 Posted October 13, 2024 hmm, when I use the above snippet - $ python3.8 embyTools.py delete_all_collections Successfully deleted collection with ID "3571866" Successfully deleted collection with ID "3571867" Successfully deleted collection with ID "3571868" Successfully deleted collection with ID "3571869" Successfully deleted collection with ID "3571870" Successfully deleted collection with ID "3571871" Successfully deleted collection with ID "3571872" Successfully deleted collection with ID "3571873" Successfully deleted collection with ID "3571874" Successfully deleted collection with ID "3571875" Successfully deleted collection with ID "3571876" Successfully deleted collection with ID "3571877" Successfully deleted collection with ID "3571878" Successfully deleted collection with ID "3571879" and after running it, I have no collections:
Neminem 1518 Posted October 13, 2024 Posted October 13, 2024 Guess OP forgot headers = {'X-Emby-Token': emby_api_key, 'accept': '*/*'}
hthgihwaymonk 34 Posted October 14, 2024 Posted October 14, 2024 and for deleting a single collection, if it helps def delete_collection(collection_id): delete_url = f'{emby_server_url}/Items/{collection_id}' headers = {'X-Emby-Token': emby_api_key, 'accept': '*/*'} response = requests.delete(delete_url, headers=headers) if response.status_code == 204: print(f'Successfully deleted collection with ID "{collection_id}"') else: print(f'Error deleting collection with ID "{collection_id}": {response.text}')
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now