JohnMason1 2 Posted April 14 Posted April 14 I use the Homepage dashboard. One of its widgets uses Emby's API to display counts for Movies, TV shows etc. It appears that Emby's API reports the number of movie files as the number of movies. This is incorrect; it should report the movie count as shown on the web/app UI. If one has multiple versions for a lot of movies (most common reason is having a 4K and an HD version as separate files), Emby's API reports each one of these as two movies instead of one, making the movie/TV show/episode count the API reports completely wrong. Could there be a fix for this please?
Luke 40131 Posted April 14 Posted April 14 HI there, can you please provide a specific example? How to Report a Problem Thanks !
JohnMason1 2 Posted April 14 Author Posted April 14 Hi @Luke, yes I should have provided more details. Here is my movie count: And here is what the API reports to Homepage: Similarly for TV shows, and the total episode count. Every time I add two movie files that are different versions of the same movie, the movie count inside Emby goes up by one (as it should), but the API movie count goes up by two. Here is what I believe is the relevant Homepage code showing they are just getting the movie etc count numbers from the Emby API without any further processing (indicating that the counts are wrong from Emby).
Luke 40131 Posted April 15 Posted April 15 The total that you see next to the play button is just for one library. What homepage is getting is for all libraries.
JohnMason1 2 Posted April 15 Author Posted April 15 Yes you are right, I have more movie libraries. However, the count is still wrong, as it does count multiple versions as separate movies.
Luke 40131 Posted April 15 Posted April 15 15 hours ago, JohnMason1 said: Yes you are right, I have more movie libraries. However, the count is still wrong, as it does count multiple versions as separate movies. I don't believe this is true. I think it does accurately handle multiple versions. Can you please provide an example of why you think this isn't the case?
JohnMason1 2 Posted April 21 Author Posted April 21 On 16/04/2025 at 00:11, Luke said: Can you please provide an example of why you think this isn't the case? The first reason is because when I add up all the movies from all the 'movie'-type libraries I have the total is less than what the API reports to Homepage. The second reason is that I can see it happening live: if I add a new movie that has two versions (HD and 4K, adding both files to the directory before rescanning the library), the movie count reported to Homepage by the API goes up by two.
adminExitium 295 Posted April 22 Posted April 22 You need an example. I suggest creating a new library with just a single multi-version movie and provide the screenshots or API responses of the different counts.
JohnMason1 2 Posted April 23 Author Posted April 23 Is there an 'easy' way to query the API for specific libraries? Homepage only displays the total count of movies. I have added a new movie library actually, and the counter keeps going up by two for every multi version movie I add. If someone could point out a way I could query the API specifically for the new library, I will do that, however for the developers it should be an equally, if not easier, task to check the relevant parts of the code to see if it reports it the way I describe (i.e. to try and reproduce the problem which is standard practice when a bug is reported, right?).
JohnMason1 2 Posted April 23 Author Posted April 23 I found out how to query the API, so here is a test. This is a test library I have created with some movies in it: I ran this query: curl -X GET "https://emby-domain.com/emby/Items?IncludeItemTypes=Movie&Recursive=true" -H "X-Emby-Token: api-token" I got this result: Homepage reports the same: I then added a movie ("The Greatest Showman") that has two versions (HD and 4K) in two separate files. Here is the library after adding the movie: Here is the API count after adding that movie (same query as before): Homepage reports the same: If there is any relevant log content I can provide, please do let me know.
bakes82 160 Posted April 24 Posted April 24 You just posted screen shots of correct numbers.. whats the issue. number before 1628, added 2 files, 1630.
seanbuff 1150 Posted April 24 Posted April 24 12 minutes ago, bakes82 said: You just posted screen shots of correct numbers.. whats the issue. number before 1628, added 2 files, 1630. The argument being that OP only added "1" movie (2 versions of a single movie) The Emby movie library UI shows this incrementing by only one, which is correct: > Yet the underlying API is returning the number of "records" or "files", therefore it is incrementing by "2" Homepage is using this endpoint to report the count of "Movies" which is somewhat misleading. 1
JohnMason1 2 Posted April 24 Author Posted April 24 (edited) 3 hours ago, bakes82 said: number before 1628, added 2 files, 1630 As @seanbuffsaid, the API is meant (I believe) to count "movies" not "movie vesions" or "files". So, if I add one movie that has two versions (hence two files), the count should go up by one, not two. Quote Homepage is using this endpoint to report the count of "Movies" which is somewhat misleading. Is there another endpoint that reports the movie count as opposed to the 'record' count? Edited April 24 by JohnMason1
bakes82 160 Posted April 25 Posted April 25 Youre calling the "Items" endpoint why would that only show top level aggregates? Whos to say that number also isnt being dynamically calculated based of the items payload and just grouped via the UI code? Did you look at the GroupItemsIntoCollections option?
seanbuff 1150 Posted April 25 Posted April 25 36 minutes ago, bakes82 said: Did you look at the GroupItemsIntoCollections option? This has no bearing on 'versions' as that is for boxsets only. Since the current beta server now has a filter for 'Duplicates' which when toggled, includes only movies that contain multiple "versions" (and of course legit dupes) An appropriate API filter like 'IsDuplicate' or 'ExcludeDuplicates' should in theory return the correct result that OP is looking for, but would require an update on the Homepage side for that widget to adopt.
Solution Luke 40131 Posted April 25 Solution Posted April 25 Quote curl -X GET "https://emby-domain.com/emby/Items?IncludeItemTypes=Movie&Recursive=true" -H "X-Emby-Token: api-token" There's a couple things going on. This is a user-less query. Based on the way the api currently works, you should use /emby/users/userid/items/xxx This means that wherever you configure your api_key for this app, they should also have a user selection box so that all queries of this nature will be based on a user library. I realize that is inconvenient as this will require development, but that's just how the api was built way back when. It was designed so that queries could be made with and without a user id depending on context. Usually things that display will be based on a user library, and things that are background operations will not. So why are the results so different when querying with and without a user id? This is an Emby issue however I can't give you a timeline for changing this behavior. The majority of things that use user-less queries are things that operate on files, and they don't care about things like multi-version, so this is why the results come back ungrouped. We should change this, however it will be highly disruptive for a little while due to all of the places that have written code based on the current behavior. So therefore, the easiest short term solution is to have Homepage use user queries. 2
JohnMason1 2 Posted April 25 Author Posted April 25 (edited) 4 hours ago, Luke said: you should use /emby/users/userid/items/xxx Thank you! This works as expected (gives me a total count of 1408, which sounds about right). Hopefully the Homepage devs can fix it on their end. Is there an API endpoint or way to obtain the GUID needed for this endpoint (as it's not the actual user id it needs)? Edited April 25 by JohnMason1
Luke 40131 Posted April 25 Posted April 25 8 hours ago, JohnMason1 said: Thank you! This works as expected (gives me a total count of 1408, which sounds about right). Hopefully the Homepage devs can fix it on their end. Is there an API endpoint or way to obtain the GUID needed for this endpoint (as it's not the actual user id it needs)? In their config UI they should pull down the list of users. Then you select one and they can store the user id from that.
seanbuff 1150 Posted April 25 Posted April 25 3 hours ago, Luke said: In their config UI they should pull down the list of users. Then you select one and they can store the user id from that. they don't have a config UI, it's all done via YAML, so the user will need to enter this manually.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now