diff --git a/README.md b/README.md index 9596e21..b639307 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,8 @@ The test suite is run via `tox`, and you can install it from PyPi. - Add group of `remote_` API calls to remote control another session - Configurable item refreshes allowing custom refresh logic (can also iterate through a list of items) - Add support for authenticating via an API key - - Add support for the optional 'date played' parameter in the `item_played` API method + - Add support for the optional 'date played' parameter in the `item_played` API method + - Add API calls `get_userdata_for_item` and `update_userdata_for_item` ## Contributing diff --git a/jellyfin_apiclient_python/api.py b/jellyfin_apiclient_python/api.py index 1328b56..3c7832a 100644 --- a/jellyfin_apiclient_python/api.py +++ b/jellyfin_apiclient_python/api.py @@ -508,6 +508,29 @@ def get_userdata_date_modified(self, date, parent_id, media=None): 'Fields': info() }) + def get_userdata_for_item(self, item_id): + return self._get( + f"UserItems/{item_id}/UserData", params={"UserId": "{UserId}"} + ) + + def update_userdata_for_item(self, item_id, data): + """ + Updates the userdata for an item. + + Args: + item_id (str): item uuid to update userdata for + + data (dict): the information to add to the current user's + userdata for the item. Any fields in data overwrite the + equivalent fields in UserData, other UserData fields are + left untouched. + + References: + .. [UpdateItemUserData] https://api.jellyfin.org/#tag/Items/operation/UpdateItemUserData + """ + return self._post(f"UserItems/{item_id}/UserData", params={"UserId": "{UserId}"}, json=data) + + def refresh_item(self, item_id, recursive=True, image_refresh='FullRefresh', metadata_refresh='FullRefresh', replace_images=False, replace_metadata=True, preset=None): """ Description: