Skip to content

Commit

Permalink
Added get and update API calls for an item's UserData
Browse files Browse the repository at this point in the history
  • Loading branch information
Touchstone64 committed Oct 22, 2024
1 parent fe8c16c commit cca5431
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions jellyfin_apiclient_python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cca5431

Please sign in to comment.