Add get/update item metadata methods #42
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #40 I spent way to much time figuring out how to use the API to update item metadata. Relevant discussion is on #jellyfin-dev:matrix.org on 2024-Jan-02. (If there is a way to link to a matrix conversation, let me know).
There is a jellyfin architecture quirk that makes this implementation less than ideal. It turns out that when you call the UpdateItem endpoint, any data you don't provide is overwritten with null, so we are stuck with one of two bad options:
For ease of use, I opted for the second option, but raised another issue: there isn't a an easy API call to get metadata for a single item. There is a
get_item
, but it doesn't return all of the fields required by the update method. Theget_items
call does do this, but you have to call it with a list of 1 and then unpack it, which is kinda awkward. I made this problem worse by adding a 3rd methodget_item_metadata
as a stopgap, but I don't want to merge it and add to API bloat.Fortunately, this problem can likely be solved by updating the
get_item
call to pass"Fields": info()
in its params dictionary, but I wanted to discuss it first before I did it. Similarly, I'd also like to discuss the nameupdate_item_metadata
, which I chose just to let me move forward and modify my library, but it's name doesn't agree with the rest of the API.My current thoughts are to take the following actions:
Remove
get_item_metadata
and changeget_item
to either:Or let the user pass in Fields if necessary:
Then rename
update_item_metadata
toupdate_item
and keep the same signature.But there are other directions I could go, so I'd like to discuss before I move further. In the meantime this stop-gap API works well enough for me.