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

Add get and update API calls for an item's UserData #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading