Jump to content

Beta Server - Tags and TagItems


PenkethBoy

Recommended Posts

ginjaninja

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

Link to comment
Share on other sites

PenkethBoy

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 2 years later...
hthgihwaymonk

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

hthgihwaymonk
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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

hthgihwaymonk
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}

 

Link to comment
Share on other sites

hthgihwaymonk
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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

hthgihwaymonk
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
Link to comment
Share on other sites

adminExitium

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

adminExitium
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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

adminExitium

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

hthgihwaymonk
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 ?

Link to comment
Share on other sites

adminExitium
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.

Link to comment
Share on other sites

adminExitium
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.

Link to comment
Share on other sites

adminExitium

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 🙁

Link to comment
Share on other sites

adminExitium

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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