Jump to content

Recommended Posts

Posted (edited)

Is it possible to update an item using the API

POST /emby/Items/<item_id>

and only supply the info you want updated?

i.e. in the POST request, just have the item details you want changed
{"CommunityRating":"5.0"}

It looks like you need to supply the full details, and they get overridden with blank if you don't include everything.

If it is not possible with the above API is there some other endpoint that does this?

 

Edited by TeamB
hthgihwaymonk
Posted (edited)

you have to include the complete payload

Edited by hthgihwaymonk
  • Thanks 1
Posted

hmmmm grumble grumble

ok so I need to write a plugin to handle my updates cos I dont want to anciently nuke my items details cos I did not add ALL the fields that were expected.

Posted

Some of the config endpoints now support updates via partial objects, so we will eventually get to the point where that can be done everywhere.

  • Like 1
  • 4 months later...
Posted
On 2/5/2024 at 1:27 PM, hthgihwaymonk said:

you have to include the complete payload

how to get the complete payload?

Posted
2 hours ago, tobox said:

how to get the complete payload?

Fetch it first with a get request, then update the properties you need.

  • 2 months later...
Posted

@Lukewhat is the bar minimum you need to end in the update to not override some fields with null values, i.e. you lose data.

The issue I am having is the endpoint (none user specific one)

GET /emby/Items

only returns a small subset unless I specify a bunch of fields, it does not return the full playload, if I don't include the full payload to

POST /emby/Items/<emby_id>

I either get an error or some of the not supplied fields get nulled out and overwritten.

Is there a way of calling GET /emby/Items that just returns ALL fields needed for an update.

Posted
19 hours ago, TeamB said:

@Lukewhat is the bar minimum you need to end in the update to not override some fields with null values, i.e. you lose data.

The issue I am having is the endpoint (none user specific one)

GET /emby/Items

only returns a small subset unless I specify a bunch of fields, it does not return the full playload, if I don't include the full payload to

POST /emby/Items/<emby_id>

I either get an error or some of the not supplied fields get nulled out and overwritten.

Is there a way of calling GET /emby/Items that just returns ALL fields needed for an update.

HI, What you should do is pull back the full record using the single item api. Then update the fields you need, and then send your request to save it.

Posted
4 hours ago, Luke said:

HI, What you should do is pull back the full record using the single item api. Then update the fields you need, and then send your request to save it.

which endpoint is that, the only one I can find is the user specific one

/emby/Users/<user_id>/Items/<emby_id>

But I am using an API key, I dont have a user ID

Posted
1 hour ago, TeamB said:

which endpoint is that, the only one I can find is the user specific one

/emby/Users/<user_id>/Items/<emby_id>

But I am using an API key, I dont have a user ID

That's the one, yes. Sorry, you were right to begin with. You don't need to request any special fields to then turn around and use the object with the update api.

What are you seeing getting nulled out?

Posted
2 hours ago, Luke said:

That's the one, yes. Sorry, you were right to begin with. You don't need to request any special fields to then turn around and use the object with the update api.

What are you seeing getting nulled out?

if I just call

    url = emby_url
    url += "/emby/Items"
    url += "?Ids=2107"
    url += "&api_key=" + api_key

Get the first one returnd in the Items and POST this item to

    url = emby_url
    url += "/emby/Items/2107"
    url += "?api_key=" + api_key

I get an error

Value cannot be null. (Parameter "source")

I worked out source in this case is the ProviderIds so adding that field in the request

    url = emby_url
    url += "/emby/Items"
    url += "?Ids=2107"
    url += "&fields=ProviderIds"
    url += "&api_key=" + api_key

now gives the following

{'Name': 'Episode #2.1 HELLO', 'ServerId': '26c908c0828c49f9ad4cf6754e42ffcb', 'Id': '2107', 'RunTimeTicks': 26054720000, 'IndexNumber': 1, 'ParentIndexNumber': 2, 'ProviderIds': {'Imdb': 'tt15906800', 'Tvdb': '9941451'}, 'IsFolder': False, 'Type': 'Episode', 'ParentLogoItemId': '17', 'ParentBackdropItemId': '17', 'ParentBackdropImageTags': ['4ea7c77d8512da65830614bcaafc16df'], 'SeriesName': 'Star Trek: Prodigy', 'SeriesId': '17', 'SeasonId': '2106', 'SeriesPrimaryImageTag': 'daa8e57724c937a6006064348c489edd', 'SeasonName': 'Season 2', 'ImageTags': {'Primary': '2097159fa160f6e1b8e475b8128b33ff'}, 'BackdropImageTags': [], 'ParentLogoImageTag': 'bb8af69254e26e5389854b7802cf66cb', 'ParentThumbItemId': '17', 'ParentThumbImageTag': '61f1f52cf0618f0bd6cca9f89b268569', 'MediaType': 'Video'}

The update POST now works with the above data, BUT that does not contain synopsis, year, premiered date (and a bunch of other fields) and these are overwritten with blank/empty data.

 

Happy2Play
Posted (edited)

was getting the same thing over here.

But testing with providerids field it posted but other fields were cleared as you mentioned.

Plot, rating, year, mpaa, premiered. releasedate, and critical rating were lost with my update showing providerids and empty people.

It would appear you have to get all these fields before you can update and item.  I guess the question becomes what is the correct way to get the full payload for and update?

Providerids, People, Overview, CommunityRating, CriticRating, OfficialtRating, PremiereDate, ProductionYear

But these just the ones I notice in my test on a movie.

 

Edited by Happy2Play
Posted
3 hours ago, Happy2Play said:

But these just the ones I notice in my test on a movie.

are you sure about people? I dont have people in the update POST action and people are not effected, they are not wiped.

Happy2Play
Posted
1 minute ago, TeamB said:

are you sure about people? I dont have people in the update POST action and people are not effected, they are not wiped.

That is what i was trying to do per that linked topic as user wanted to nuke all per nfo but Emby will not allow it as the db repopulates the nfo.  But don't believe people were affected in a different test.

So affected would be if not provided from what I saw in my test.  

Overview, CommunityRating, CriticRating, OfficialtRating, PremiereDate, ProductionYear

 

Posted
1 hour ago, Happy2Play said:

That is what i was trying to do per that linked topic as user wanted to nuke all per nfo but Emby will not allow it as the db repopulates the nfo.  But don't believe people were affected in a different test.

So affected would be if not provided from what I saw in my test.  

Overview, CommunityRating, CriticRating, OfficialtRating, PremiereDate, ProductionYear

 

There are other things like Video3DFormat and a few others.

I dont really want to guess, I just want a robust way of updating items. I dont think we have that at the moment.

Posted
16 hours ago, TeamB said:

if I just call

    url = emby_url
    url += "/emby/Items"
    url += "?Ids=2107"
    url += "&api_key=" + api_key

Get the first one returnd in the Items and POST this item to

    url = emby_url
    url += "/emby/Items/2107"
    url += "?api_key=" + api_key

I get an error

Value cannot be null. (Parameter "source")

I worked out source in this case is the ProviderIds so adding that field in the request

    url = emby_url
    url += "/emby/Items"
    url += "?Ids=2107"
    url += "&fields=ProviderIds"
    url += "&api_key=" + api_key

now gives the following

{'Name': 'Episode #2.1 HELLO', 'ServerId': '26c908c0828c49f9ad4cf6754e42ffcb', 'Id': '2107', 'RunTimeTicks': 26054720000, 'IndexNumber': 1, 'ParentIndexNumber': 2, 'ProviderIds': {'Imdb': 'tt15906800', 'Tvdb': '9941451'}, 'IsFolder': False, 'Type': 'Episode', 'ParentLogoItemId': '17', 'ParentBackdropItemId': '17', 'ParentBackdropImageTags': ['4ea7c77d8512da65830614bcaafc16df'], 'SeriesName': 'Star Trek: Prodigy', 'SeriesId': '17', 'SeasonId': '2106', 'SeriesPrimaryImageTag': 'daa8e57724c937a6006064348c489edd', 'SeasonName': 'Season 2', 'ImageTags': {'Primary': '2097159fa160f6e1b8e475b8128b33ff'}, 'BackdropImageTags': [], 'ParentLogoImageTag': 'bb8af69254e26e5389854b7802cf66cb', 'ParentThumbItemId': '17', 'ParentThumbImageTag': '61f1f52cf0618f0bd6cca9f89b268569', 'MediaType': 'Video'}

The update POST now works with the above data, BUT that does not contain synopsis, year, premiered date (and a bunch of other fields) and these are overwritten with blank/empty data.

 

Use /items/{id} rather than the Ids query string param. that is the single item api and you won't have to specify fields to get the full object.

Posted
3 hours ago, Luke said:

Use /items/{id} rather than the Ids query string param. that is the single item api and you won't have to specify fields to get the full object.

are you sure

/emby/Items/<emby_id>

Is a real endpoint?

If I call the following, I get a 404 (emby item 4516 does exist)

http://localhost:8096/emby/Items/4516?api_key=5dfb96dd59a743c4b5e60291a969cc1a
404
The file "/emby/Items/4516" could not be found.

 

Posted

OK maybe there isn't, only the user-specific one, sorry. That should be fine though for editing. It's what the metadata editor uses.

Posted
56 minutes ago, Luke said:

OK maybe there isn't, only the user-specific one, sorry. That should be fine though for editing. It's what the metadata editor uses.

the problem is I dont have a user id, I am using an API key from a script.

yes I can do a login and get a user ID but for this script I dont want to have to supply a username and password, the idea is keep it simple and just use an API_KEY

Posted

OK I can add an endpoint for that then.

  • Like 1
  • 5 months later...
Aquaquaman
Posted

Hey, sorry to revive this, but I'm running into an issue where this seems to be the fix, but it's unclear to me what API endpoint you added re: TeamB's issue.

My issue: Metadata fetcher plugins really don't reconcile anime well, as anime in their databases (MAL, AniDB, AniList) don't use explicit seasons. But the logical structure for Emby is seasons, and we just put the sequential properties that are items in those external databases (again: MAL, AniDB, AniList) as sequential seasons. Those metadata fetcher plugins seem to run the title of the series in Emby, not the title of the season, to fetch metadata, and various other quirks that result in just bad metadata for anything beyond season 1 of a multi-season property (Attack on Titan, K-On, literally anything).

The fix appears to be just editing metadata directly via external scripts and API endpoints. Instead of writing a fun Playwright macro in Python and navigating very painfully through a chromium instance, API endpoints are just cleaner.

So question: what API endpoint(s) would be most straightforward (easy auth, such as API key sans user auth like teamB described (I think)) for fetching the existing metadata and posting new/updated metadata through it? Specifically for shows/TV at Series, Season, Episode levels.

Posted
40 minutes ago, Aquaquaman said:

Hey, sorry to revive this, but I'm running into an issue where this seems to be the fix, but it's unclear to me what API endpoint you added re: TeamB's issue.

My issue: Metadata fetcher plugins really don't reconcile anime well, as anime in their databases (MAL, AniDB, AniList) don't use explicit seasons. But the logical structure for Emby is seasons, and we just put the sequential properties that are items in those external databases (again: MAL, AniDB, AniList) as sequential seasons. Those metadata fetcher plugins seem to run the title of the series in Emby, not the title of the season, to fetch metadata, and various other quirks that result in just bad metadata for anything beyond season 1 of a multi-season property (Attack on Titan, K-On, literally anything).

The fix appears to be just editing metadata directly via external scripts and API endpoints. Instead of writing a fun Playwright macro in Python and navigating very painfully through a chromium instance, API endpoints are just cleaner.

So question: what API endpoint(s) would be most straightforward (easy auth, such as API key sans user auth like teamB described (I think)) for fetching the existing metadata and posting new/updated metadata through it? Specifically for shows/TV at Series, Season, Episode levels.

HI, once you have a series, then there are /seasons and /episodes api's you can use with the series Id.

To update an item, all items use the same endpoint.

 

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...