gboudreau / XBMCnfoMoviesImporter.bundle

688 stars 158 forks source link

Can't scan Rating form .nfo #70

Closed F4RHaD closed 7 years ago

F4RHaD commented 8 years ago

Hi, After Krypton update Kodi has done some changes to .nfo configuration. This is the old Rating tag that works with XBMCnfoMoviesImporter:

<rating>8.100000</rating>

and this is new format:

<ratings>
    <rating name="default" default="true">
        <value>8.100000</value>
        <votes>377143</votes>
    </rating>
</ratings>

So Ratings can't be scanned anymore.

SlrG commented 8 years ago

Thanks for the info. I'll see what I can do about it.

F4RHaD commented 8 years ago

hi SlrG, I noticed that when i tick "enable additional ratings support" under XBMCnfoMoviesImporter setting, it just can't import movie posters!! I have no idea why :))))

Edit: that's because of this Critical Error:

CRITICAL (core:574) - Exception in the update function of agent named 'XBMCnfoMoviesImporter', called with guid 'com.plexapp.agents.xbmcnfo://tt1065073?lang=xn' (most recent call last):
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-a17e99e\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py", line 1065, in _update
    agent.update(obj, media, lang, **kwargs)
  File "C:\Users\Farhad\AppData\Local\Plex Media Server\Plug-ins\XBMCnfoMoviesImporter.bundle\Contents\Code\__init__.py", line 484, in update
    ratingprovider = str(addrating.attrib['moviedb'])
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-a17e99e\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\code\sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
  File "lxml.etree.pyx", line 2184, in lxml.etree._Attrib.__getitem__ (..\src\lxml\lxml.etree.c:47381)
KeyError: 'moviedb'

I even tried:

rating = nfoXML.xpath("ratings")[0]
nforating=float(rating.xpath("value").text)

I'm really new to lxml :)))

EDIT2: I'm not developer but i found a temporary solution: just replace nforating = round(float(nfoXML.xpath("rating")[0].text.replace(',', '.')),1) with: nforating=float(nfoXML.xpath("ratings")[0][0][0].text)

But now another problem is "preserverating" option not working. it just ignores it.

Edit 3: now working perfectly :))) "preserverating" was not worked because it was part of Additional Rating's "If" I hope that the developers update it soon to work with new kodi, It's a really useful agent ;)

SlrG commented 8 years ago

Please give the newest version of the agent a try. It should fix this problem.

F4RHaD commented 8 years ago

Thanks SIrG for replay, It's works now with ratings,

2016-07-30 11:29:49,101 (2260) :  CRITICAL (core:574) - Exception in the update function of agent named 'XBMCnfoMoviesImporter', called with guid 'com.plexapp.agents.xbmcnfo://tt1126590?lang=xn' (most recent call last):
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-7caf41d\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py", line 1065, in _update
    agent.update(obj, media, lang, **kwargs)
  File "C:\Users\Farhad\AppData\Local\Plex Media Server\Plug-ins\XBMCnfoMoviesImporter.bundle\Contents\Code\__init__.py", line 491, in update
    ratingprovider = str(addrating.attrib['moviedb'])
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-7caf41d\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\code\sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
  File "lxml.etree.pyx", line 2184, in lxml.etree._Attrib.__getitem__ (..\src\lxml\lxml.etree.c:47381)
KeyError: 'moviedb'

(I think, with Krypton update, Additional Ratings option isn't usable anymore, cause it uses <ratings></ratings> tag that Krypton uses as regular rating. )

and sorry for my terrible english :)))

SlrG commented 8 years ago

I'll check again. :) Thanks for the thorough information.

SlrG commented 8 years ago

Still working on it. :)

F4RHaD commented 8 years ago

Thank you SIrG, for your hard work. I'm wating. :)))

SlrG commented 7 years ago

Sigh... Sorry for taking so long. Can you check the newest version, if it fixes your problems?

F4RHaD commented 7 years ago

Hi SIrG, Glad to see you back! i'll check it tommorow.

F4RHaD commented 7 years ago

Did you tested it with the .nfo file generated by latest version of Kodi? i'm using Kodi v17 alpha 2 and the nfo file structure is something like this:

<ratings>
        <rating name="default" default="true">
            <value>8.200000</value>
            <votes>604220</votes>
        </rating>
</ratings>

at first it doesn't seems to work correctly, because all movie ratings was 0.0 so I've added changed the code like this:

except:
    pass
if not nforating:
    self.DLog("Reading old rating style failed. Trying new Krypton style.")
    for ratings in nfoXML.xpath('ratings'):
        try:
            rating=ratings.xpath("rating")[0]
            nforating = round(float(rating.xpath("value")[0].text.replace(',', '.')),1)
            self.DLog("Krypton style series rating found: " + str(nforating))
        except:
            self.DLog("Can't read rating from tvshow.nfo.")
            nforating = 0.0
            pass

and now everything is working great, i think you just forgot to add the <rating> tag as well as <ratings> :)

SlrG commented 7 years ago

Thank you very much. I integrated your fix in the newest version of the XBMCnfoMovies Importer. Did the ratings for the TVShows change in the same way? If yes, the same patch will have to go into the tv agent.

cheers

SlrG

F4RHaD commented 7 years ago

Your welcome, Yes i think they both work in the same way. I'll check it again. Thanks SIrG for supporting. Good luck. ;)