Jump to content

Emby for Kodi addon problem with updating Libraries


Bambu Utila

Recommended Posts

Bambu Utila

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:

        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:

        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:

if  temp_obj['RatingId'] > 0:

and

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? @Angelblue05

Link to comment
Share on other sites

Bambu Utila

I think i found the solution :)

            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'] < 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))

If the function of the 2nd line doesn't find a rating_id it returns the rating_id for the first empty record in the rating_table.

So if you have 140 records in the rating_table it would return 141.

If we then just check if the returned number is smaller then the new id we can either update or add

Link to comment
Share on other sites

Hi, this is interesting, thanks for the info. How do you still feel about this now, several days later?

Link to comment
Share on other sites

Bambu Utila
1 hour ago, Luke said:

Hi, this is interesting, thanks for the info. How do you still feel about this now, several days later?

It seems to work fine.

I've ran the update for my libraries a few times, added Critics ratings in Emby for movies that were missing them, they got updated in the Kodi DB without a problem.

Sadly enough it doesn't solve my problem. Turns out most Kodi skins don't read the RottenTomato rating out of your Kodi DB anyway, they use the SHS script to retrieve it. So even when i add them to the DB, they don't show up in the skin :(

Also found out today that the Embuary Helper script does allow this, but i'm not good enough at skinning yet to incorporate it into the one i'm using. But that would solve it all i guess.

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