Plex rounding down user ratings when set via api

Using a script like this

plex = get_plex()
plogger("connection success", 'info', 'a')

new_rating = round(random.random() * 10, 1)

the_lib = plex.library.section('Test-Movies')
the_type = the_lib.type

print(f"getting first item from the {the_type} library [{the_lib.title}]...")
items = get_all_from_library(the_lib, the_type)

item = items[1][0]

item_title = item.title
print(f"Working with: {item_title}")
print(f"Random rating: {new_rating}")

user_rating = item.userRating
audience_rating = item.audienceRating
critic_rating = item.rating

print(f"current audience rating on: {item_title}: {audience_rating}")
print(f"current critic rating on: {item_title}: {critic_rating}")
print(f"current user rating on: {item_title}: {user_rating}")

print(f"setting audience rating on: {item_title} to {new_rating}")
item.editField("audienceRating", new_rating)

print(f"setting critic rating on: {item_title} to {new_rating}")
item.editField("rating", new_rating)

print(f"setting user rating on: {item_title} to {new_rating}")
item.editUserRating(new_rating, locked=False)

print(f"reloading: {item_title}")
item.reload()

print(f"retrieving ratings for: {item_title}")
user_rating = item.userRating
audience_rating = item.audienceRating
critic_rating = item.rating

print(f"current audience rating on: {item_title}: {audience_rating}")
print(f"current critic rating on: {item_title}: {critic_rating}")
print(f"current user rating on: {item_title}: {user_rating}")

to set ratings and then check the ratings shows that for some reason plex is rounding down the user rating

output

Starting set-user-rating 0.0.1 at 2024-04-22 22:53:22
connecting to REDACTED
connection success
getting first item from the movie library [Test-Movies]...
Working with: 3 1/2 Hours
Random rating: 8.6
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: 6.4
current user rating on: 3 1/2 Hours: 4.0
setting audience rating on: 3 1/2 Hours to 8.6
setting critic rating on: 3 1/2 Hours to 8.6
setting user rating on: 3 1/2 Hours to 8.6
reloading: 3 1/2 Hours
retrieving ratings for: 3 1/2 Hours
current audience rating on: 3 1/2 Hours: 8.6
current critic rating on: 3 1/2 Hours: 8.6
current user rating on: 3 1/2 Hours: 8.0

This is a recent change with what seems to be something between 1.40.0.7998 and above. The above was ran on the latest version of plex being 1.40.2.8395 currently. 1.40.0.7998 the user ratings are not rounded down and show correctly. Is this intended behavior and an undocumented change or is it some bug that happened recently?

checking the database, user rating is stored as a float but it is being cast as an integer before before saved to the database. Is this a bug of some sort or is this actual intended behavior? Season user ratings do not follow this and are saved and shown correctly without being rounded down

User ratings are zero to five stars. With the possibility to enable half stars on some client types.
Internally these are treated as integers from 0 to 10, with 10 meaning 5 stars. There is no finer granularity than that, hence the rounding.

I understand that but is this some new thing? In past versions in the past few months or so it wasnt like this. They were stored without the rounding down

Ill get output from a recent plex version that shows these werent stored rounded down. I think the version after 1.40.0.7998 starts the rounding down

Here’s that same code running on four different versions of Plex server:

No rounding on Plex version 1.31.0.6654-02189b09f

Starting set-user-rating 0.0.1 at 2024-04-23 22:13:54
connecting to https://plex-31.whatver.whatever...
connection success
Plex version 1.31.0.6654-02189b09f
getting first item from the movie library [Test-Movies]...
Working with: 3 1/2 Hours
Random rating: 7.7
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: None
current user rating on: 3 1/2 Hours: 6.0
setting audience rating on: 3 1/2 Hours to 7.7
setting critic rating on: 3 1/2 Hours to 7.7
setting user rating on: 3 1/2 Hours to 7.7
reloading: 3 1/2 Hours
retrieving ratings for: 3 1/2 Hours
current audience rating on: 3 1/2 Hours: 7.7
current critic rating on: 3 1/2 Hours: 7.7
current user rating on: 3 1/2 Hours: 7.7

No rounding on Plex version 1.32.0.6918-6f393eda1

Starting set-user-rating 0.0.1 at 2024-04-23 22:15:51
connecting to https://plex-32.whatever.whatever...
connection success
Plex version 1.32.0.6918-6f393eda1
getting first item from the movie library [Test-Movies]...
Working with: 3 1/2 Hours
Random rating: 6.4
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: None
current user rating on: 3 1/2 Hours: 6.0
setting audience rating on: 3 1/2 Hours to 6.4
setting critic rating on: 3 1/2 Hours to 6.4
setting user rating on: 3 1/2 Hours to 6.4
reloading: 3 1/2 Hours
retrieving ratings for: 3 1/2 Hours
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: 6.4
current user rating on: 3 1/2 Hours: 6.4

No rounding on Plex version 1.40.0.7998-c29d4c0c8

Starting set-user-rating 0.0.1 at 2024-04-23 22:17:03
connecting to https://plex-40.whatever.whatever...
connection success
Plex version 1.40.0.7998-c29d4c0c8
getting first item from the movie library [Test-Movies]...
Working with: 3 1/2 Hours
Random rating: 6.7
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: None
current user rating on: 3 1/2 Hours: 6.0
setting audience rating on: 3 1/2 Hours to 6.7
setting critic rating on: 3 1/2 Hours to 6.7
setting user rating on: 3 1/2 Hours to 6.7
reloading: 3 1/2 Hours
retrieving ratings for: 3 1/2 Hours
current audience rating on: 3 1/2 Hours: 6.7
current critic rating on: 3 1/2 Hours: 6.7
current user rating on: 3 1/2 Hours: 6.7

Rounding occurs on Plex version 1.40.2.8395-c67dce28e

Starting set-user-rating 0.0.1 at 2024-04-23 22:17:33
connecting to https://test-plex.whatever.whatever...
connection success
Plex version 1.40.2.8395-c67dce28e
getting first item from the movie library [Test-Movies]...
Working with: 3 1/2 Hours
Random rating: 6.4
current audience rating on: 3 1/2 Hours: 8.5
current critic rating on: 3 1/2 Hours: 8.5
current user rating on: 3 1/2 Hours: 8.0
setting audience rating on: 3 1/2 Hours to 6.4
setting critic rating on: 3 1/2 Hours to 6.4
setting user rating on: 3 1/2 Hours to 6.4
reloading: 3 1/2 Hours
retrieving ratings for: 3 1/2 Hours
current audience rating on: 3 1/2 Hours: 6.4
current critic rating on: 3 1/2 Hours: 6.4
current user rating on: 3 1/2 Hours: 6.0

Im still having this issue as well, would be great if it could be fixed.

Wanted to echo that I would love to see this fixed.

I won’t upgrade to any versions past 1.40.0.7998 until so; this is really important functionality to a lot of Kometa users.

I went back to 1.40.0.7998 as well

I will be dropping back to the version that does not round anymore. Please consider fixing this Plex Staff.

Hello, the same problem; please give us the fix for this rounding. Thanks.

I am also having the same problem, I would really like to store user ratings at a finer granularity than just 0 to 10.
Please can this be addressed?

Please fix!

bumpp

please fix

Any ETA on when this will be fixed again?

It would be nice if somebody at Plex would acknowledge whether they plan on fixing this or forcing the new whole integer rating. If they’re going to force the rounding, then they could at least round properly and not automatically round down everything. 8.9 should NOT show as 8.0…

The code change, which was responsible for the change in behavior has been found and has been reverted.
The fix will be in one of the coming server releases. (Unfortunately I cannot tell which exact release it will be in.)

4 Likes

Awesome! thank you so much!

Can confirm this issue has been resolved in the latest plex beta 1.40.3.8502

1 Like