Jump to content

Beta Server - Tags and TagItems


Recommended Posts

ginjaninja
Posted

so when you get tags - [tagitems] is populated, [tags] is blank.

when you post, you need to ensure [tags] is populated

is that the conclusion?

so the solution is to copy [tagitems] to [tags] prior to posting?.....am interested cos i am looking at a script to manipulate tags

PenkethBoy
Posted

tags only needs the names not the ids!

whole thing is stupid

 

AND you need to do it for all items you edit (as you pull back the whole record) - its not just tags

Posted (edited)
On 11/23/2020 at 7:42 AM, Luke said:

No that's not getting changed because that would be a breaking API change that would require app updates.

If you have no plans to truly deprecate the deprecated field, could you at least put in some logic that checks if the new tags field has values before wiping out the existing tags because the half deprecated field (now) never has values?

Edited by roaku
  • Like 1
  • 2 years later...
hthgihwaymonk
Posted (edited)

To add a TAG to a Series through the API, as a solution found ?
I can see using the web UI and devtools that  it seems to be using the following (for example)
 

"TagItems": [{Name: "hindi"}],
"Tags": ["hindi"],
"LockedFields": ["Tags"],
"LockData": true


But adding that to the payload that comes from `GET /Items` and then using `POST /items` returns an error.
I've tried removing the `TagItems` line, and that will allow it to return a 204 code, but no tag is added to the series

Does anyone have sample of the correct JSON format that works ?

Note: I can't use TagServices as I have some existing tags that were added previously and I want those gone when I add the new tag

Edited by hthgihwaymonk
Posted
Quote

But adding that to the payload that comes from `GET /Items` and then using `POST /items` returns an error.

This is the right starting point. What's the error?

hthgihwaymonk
Posted
1 hour ago, Luke said:

This is the right starting point. What's the error?

Here's what I've tried - 
 

curl -X 'GET' \
  'http://localhost:8096/emby/Items?Recursive=true&Fields=ProviderIds%2C%20Tags&Ids=15092563&api_key={api_key}' \
  -H 'accept: application/json'

which returns the following JSON
 

{
"Items": [
    {
    "Name": "13 Commandments",
    "ServerId": "9826b2ded108....",
    "Id": "15092563",
    "RunTimeTicks": 27600000000,
    "ProviderIds": {
        "Tvdb": "326005",
        "Imdb": "tt5203748",
        "Tmdb": "75680"
    },
    "IsFolder": true,
    "Type": "Series",
    "AirDays": [],
    "ImageTags": {
        "Primary": "d3761dca2535fac2687ec28e6b2ee23c",
        "Banner": "e58a386bfd08054cae9494d9d33d7050",
        "Logo": "44d9b4c0bb1a15d922167baadf3b9c5a",
        "Thumb": "8fe56fe965cb2a23f388d8564869a077"
    },
    "BackdropImageTags": [
        "4bd21fab418d17b3836e7ea6af0118d2"
    ],
    "EndDate": "2018-12-02T23:00:00.0000000Z"
    }
],
"TotalRecordCount": 1
}


Now I take the inner part of that output and create  -
 

curl -X 'POST' \
  'http://localhost:8096/emby/Items/15092563?api_key={api_key}' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
"Name": "13 Commandments",
"ServerId": "9826b2ded108....",
"Id": "15092563",
"RunTimeTicks": 27600000000,
"ProviderIds": {
    "Tvdb": "326005",
    "Imdb": "tt5203748",
    "Tmdb": "75680"
},
"IsFolder": true,
"Type": "Series",
"AirDays": [],
"ImageTags": {
    "Primary": "d3761dca2535fac2687ec28e6b2ee23c",
    "Banner": "e58a386bfd08054cae9494d9d33d7050",
    "Logo": "44d9b4c0bb1a15d922167baadf3b9c5a",
    "Thumb": "8fe56fe965cb2a23f388d8564869a077"
},
"BackdropImageTags": [
    "4bd21fab418d17b3836e7ea6af0118d2"
],
"EndDate": "2018-12-02T23:00:00.0000000Z"
},
"TagItems": [{"Name": "dutch"}],
"Tags": ["dutch"],
"LockedFields": ["Tags"],
"LockData": true
}'

and that returns "204 Undocumented" but nothing is updated in the metadata.
I can remove the ""TagItems": [{"Name": "dutch"}]," line and that also returns "204 Undocumented" but no metadata changes happen.

If I remove the ProviderIds section then it will throw an error 
 

400	
Error: Bad Request

Response body
Value cannot be null. (Parameter 'source')

Response headers
 content-length: 50 
 content-type: text/html

 

Posted

Use the single item request /items/id so that you’re getting the full object back. The multi item endpoints are not going to return the full thing.

hthgihwaymonk
Posted
6 minutes ago, Luke said:

Use the single item request /items/id so that you’re getting the full object back. The multi item endpoints are not going to return the full thing.

So use the following ?
 

GET emby/Items/{itemId}?api_key={api_key}

 

hthgihwaymonk
Posted
6 minutes ago, Luke said:

Yes.

That just returns Unable to find the specified file, using - 
 

curl -X GET "http://192.168.30.46:8096/emby/Items/15092563?api_key=< api_key >" -H "accept: application/json"


Am I supposed to be using `/emby/Users/{user_id}/Items/{item_id}` instead ?

Posted
2 minutes ago, hthgihwaymonk said:

That just returns Unable to find the specified file, using - 
 

curl -X GET "http://192.168.30.46:8096/emby/Items/15092563?api_key=< api_key >" -H "accept: application/json"


Am I supposed to be using `/emby/Users/{user_id}/Items/{item_id}` instead ?

Yes try that.

hthgihwaymonk
Posted
Just now, Luke said:

Yes try that.

"/emby/Users/{user_id}/Items/{item_id}" 

 

5 minutes ago, Luke said:

Yes try that.

That worked, GET /emby/Users/{user_id}/Items/{item_id} is the solution.
THANKS

  • Thanks 1
adminExitium
Posted

Working on something similar and have a few questions:

 

On 07/09/2023 at 05:01, Luke said:

Use the single item request /items/id so that you’re getting the full object back. The multi item endpoints are not going to return the full thing.

Is this true even if we request the missing Fields in the API response? If not, is there any easier way to get multiple full objects (something like Fields=All) at once rather than finding out all the missing fields one by one and specifying them in the API request?

 

Is there any way to update tags for multiple objects at once? In my case, the round-trip latency of a request to the server is significantly larger than the time taken to process the request so I would like to process multiple objects in a single request, which would significantly reduce the total execution time of the script.

Posted
14 minutes ago, adminExitium said:

Working on something similar and have a few questions:

 

Is this true even if we request the missing Fields in the API response? If not, is there any easier way to get multiple full objects (something like Fields=All) at once rather than finding out all the missing fields one by one and specifying them in the API request?

 

Is there any way to update tags for multiple objects at once? In my case, the round-trip latency of a request to the server is significantly larger than the time taken to process the request so I would like to process multiple objects in a single request, which would significantly reduce the total execution time of the script.

Off the top of my head I would guess that it's possible there could be some things missing, but full is a question more for you and not the server. What does full mean to you, in other words, what data do you need. That determines the fields you'll request.

adminExitium
Posted
12 minutes ago, Luke said:

What does full mean to you, in other words, what data do you need.

Here, I mean the exact object returned by the Users/<UserId>/Items/<ItemId> (minus the UserData obviously).

Just for context, I am using the Items?Ids=<comma-separated ids> API.

But if I am understanding you correctly, it should be possible to replicate the same response by simply requesting the missing fields in the API request then? Or are there some fields that simply can't be fetched this way (apart from UserData) and need the Users/<UserId>/Items/<ItemId> API?

adminExitium
Posted

Any ideas on the batch updates too? If it doesn't exist right now, is it possible to add it in the future?

Posted
17 hours ago, adminExitium said:

Here, I mean the exact object returned by the Users/<UserId>/Items/<ItemId> (minus the UserData obviously).

Just for context, I am using the Items?Ids=<comma-separated ids> API.

But if I am understanding you correctly, it should be possible to replicate the same response by simply requesting the missing fields in the API request then? Or are there some fields that simply can't be fetched this way (apart from UserData) and need the Users/<UserId>/Items/<ItemId> API?

I think so, yes. But the singular request may have some special things in it needed by Emby apps. Have you identified what data you need?

adminExitium
Posted

Not really. I am trying to update the Tags (both addition & removal), which doesn't work with the object returned from /Items?Ids endpoint but works with the Users/<UserId>/Items/<Id> endpoint so I will probably need to try fields one by one to see which gets that working, unless you have a better idea?

Posted

At this point the Tags property is legacy and you should just switch to using TagItems instead. 

But yes the field name to be requested is still Tags, a little quirky I realize.

hthgihwaymonk
Posted
8 hours ago, adminExitium said:

Not really. I am trying to update the Tags (both addition & removal), which doesn't work with the object returned from /Items?Ids endpoint but works with the Users/<UserId>/Items/<Id> endpoint so I will probably need to try fields one by one to see which gets that working, unless you have a better idea?

are you trying to avoid looping through a set of items and making a POST for each one, and instead, just making a single POST for all items to updated/remove tags ?

adminExitium
Posted
5 hours ago, hthgihwaymonk said:

are you trying to avoid looping through a set of items and making a POST for each one, and instead, just making a single POST for all items to updated/remove tags ?

For the batch updates request above, yes. I haven't gotten a reply from @Lukeyet on it so I don't think it's possible right now.

adminExitium
Posted
7 hours ago, Luke said:

But yes the field name to be requested is still Tags, a little quirky I realize.

Yeah, just requesting that in the Fields didn't help with the request.

Pretty much the same behaviour as here: 

I guess I will need to try the other Fields one by one and see which one gets it working.

adminExitium
Posted

I completely forgot that Emby doesn't support patch updates right now so it will need to be a full update to avoid blanking out any unsent fields. So both batching for GET or POST won't be possible, unfortunately 🙁

adminExitium
Posted

That being said, is there any kind of timeline for supporting partial updates for items or is the plan to provide individual API endpoints for each field that needs modifications?

Posted
On 9/16/2023 at 6:06 AM, adminExitium said:

That being said, is there any kind of timeline for supporting partial updates for items or is the plan to provide individual API endpoints for each field that needs modifications?

No timeline, but planned for future updates.

  • Thanks 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...