Kodi Community Forum

Full Version: Emby for Kodi does not update CriticsRating properly
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've posted the same thread on the Emby forums, but i though why not post it here too and double my chances Smile

Hi I'm using the latest version of Emby Server 4.4.3.0 and Emby for Kodi 4.1.19 with Kodi 18.7 on Windows 10.
If a movie gets added to Emby server and on initial scraping it pics up a rating and a Critic Rating adding and updating of the movie goes fine.
If a movie doesn't have a Critic rating on initial scraping the adding to Kodi and updating also works fine, but if you add a critics rating in Emby afterwards, this rating does not get added during an update of the Kodi library.
I've been looking around in the files of the Emby for Kodi addon and i think i found where the problem lies. I just don't know how to solve it.
 
I think the problem lies in the file Userfolder\.....\Kodi\userdata\addon_data\plugin.video.emby\emby\objects\core\movies.py
In the movie_update section it shows the following code:
python:

obj['RatingType'] = "imdb"
obj['RatingId'] = self.get_rating_id(*values(obj, QU.get_rating_movie_obj))
self.update_ratings(*values(obj, QU.update_rating_movie_obj))

     if obj['CriticRating'] is not None:

          temp_obj = dict(obj, RatingType="tomatometerallcritics", Rating=float(obj['CriticRating']/10.0))
          temp_obj['RatingId'] = self.get_rating_id(*values(temp_obj, QU.get_rating_movie_obj)) self.update_ratings(*values(temp_obj, QU.update_rating_movie_obj))
first part just updates the imdb rating.
it's the second part where it seems to go wrong if i understand it correct:
It checks to see if there is a CriticRating available (which it should be, we added it in Emby)
then it gets all the tomatometerallcritics ratings and stores them in temp_obj, then it looks in that list to find a rating with the correct movie id
then it updates the rating with that movie id.
Problem seems to be that if originally there was no critings rating stored in the Kodi DB it will not return a rating id to update
I don't know exactly how to change the code but it looks like it should be something like this:
python:

obj['RatingType'] = "imdb"
obj['RatingId'] = self.get_rating_id(*values(obj, QU.get_rating_movie_obj))
self.update_ratings(*values(obj, QU.update_rating_movie_obj))

if obj['CriticRating'] is not None:

     temp_obj = dict(obj, RatingType="tomatometerallcritics", Rating=float(obj['CriticRating']/10.0))
     temp_obj['RatingId'] = self.get_rating_id(*values(temp_obj, QU.get_rating_movie_obj))

     if temp_obj['RatingId'] has a value do:

          self.update_ratings(*values(temp_obj, QU.update_rating_movie_obj))
     else:
          self.add_ratings(*values(dict(obj, RatingId=self.create_entry_rating(), RatingType="tomatometerallcritics", Rating=float(obj['CriticRating']/10.0)), QU.add_rating_movie_obj))
the last line of code i just took from the movie_add section.
I have tried:
python:
if temp_obj['RatingId'] > 0:
and
python:
if temp_obj['RatingId'] is not None:
but both have no effect at all on the result.
 
Is there anybody that can point me in the right direction with this?
python:
 
if  temp_obj['RatingId'] < self.create_entry_rating():

     self.update_ratings(*values(temp_obj, QU.update_rating_movie_obj))            
else:
     self.add_ratings(*values(dict(obj, RatingId=self.create_entry_rating(), RatingType="tomatometerallcritics", Rating=float(obj['CriticRating']/10.0)), QU.add_rating_movie_obj))

This piece of code seems to fix it.
On line 8 in the code block above, if the function there doesn't find a Rating_Id it returns the id for the first empty line in the rating table

So when we compare temp_obj['Rating_Id'] to the function that gives us the a new entry_Id

If temp_obj < the new entry_Id then we can conclude there is already a rating stored and we update
If not then we know there is no rating stored and we add one
@CK77

Do you know who the addon developer is as I have no idea who it is? Maybe you can ping the developer on Github if you know where the addon is hosted, so the addon can be updated. Its not in our repo.
(2020-06-16, 09:05)Karellen Wrote: [ -> ]@CK77

Do you know who the addon developer is as I have no idea who it is? Maybe you can ping the developer on Github if you know where the addon is hosted, so the addon can be updated. Its not in our repo.

I've been asking for help on this on all the suggested places by the developers, but i never got any reply.
It doesn't seem like they are still actively working on this addon.
But I will try again to contact them now that i have a solution.
Yep I saw your other post, but I never use Emby so it was nothing I could help with. I would have only added noise to the thread.

The last post in the Emby for Kodi thread is from 2017, so it does seem like it is not being maintained anymore.
(2020-06-16, 09:10)Karellen Wrote: [ -> ]Yep I saw your other post, but I never use Emby so it was nothing I could help with. I would have only added noise to the thread.

The last post in the Emby for Kodi thread is from 2017, so it does seem like it is not being maintained anymore.

The last stable release was released on Dec 14, 2019

https://emby.media/community/index.php?/.../#comments

The developers are angelblue05 and sualfred.

Just looked at the github page, but it doesn't really have any options to reach out to the developers, to be fair i'm not really familiar with github
Oh, right. I was looking at the wrong thread then. I was looking at this... https://forum.kodi.tv/showthread.php?tid=229038

Both @sualfred and @angelblue05 are on the forum here. I have just pinged them for you.
(2020-06-16, 09:55)Karellen Wrote: [ -> ]Oh, right. I was looking at the wrong thread then. I was looking at this... https://forum.kodi.tv/showthread.php?tid=229038

Both @sualfred and @angelblue05 are on the forum here. I have just pinged them for you.

It took me a while too to find the proper forum/thread. Smile

ok, thanks!
Nice find. Feel free to create a PR.
(2020-06-16, 13:04)sualfred Wrote: [ -> ]Nice find. Feel free to create a PR.

Hi @sualfred,

I'm not 100% sure on how to do all that.
Also when i look on github i can't find the relevant files to edit.
My changes are only 3 lines in total.
The edits i made are in the files that get downloaded after the install.

Any chance you can point me in the right direction?
E4K has a internal patching system based on the used Kodi build.
I assume you will find the correct ones here:
https://github.com/MediaBrowser/plugin.v...by.objects

There is a branch for leia + krypton
(2020-06-16, 20:35)sualfred Wrote: [ -> ]E4K has a internal patching system based on the used Kodi build.
I assume you will find the correct ones here:
https://github.com/MediaBrowser/plugin.v...by.objects

There is a branch for leia + krypton

I think i've done it, but i'm not really sure.
I am completely new to github. I know how to download from it, but all the other stuff is very new for me.

I created a new branch and then created a new pull request from there. Is that the correct way?