Kodi Community Forum
[RELEASE] - Rating Update v1.4.3 - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: [RELEASE] - Rating Update v1.4.3 (/showthread.php?tid=107331)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-28

(2013-05-28, 09:41)m4x1m Wrote:
(2013-05-27, 21:52)Jandalf Wrote: hey m4x1m, thank you for this nice and helpful plugin.

But now i got a problem:

I have 1143 movies but RatingUpdate tried to update only 784 of them.
I have no clue why there are missing some. They all have a IMDB ID.

Should I upload a Debug Log or the MyMovie.db ?

Perhaps those movies are already updated? Checks the xbmc.log and compares the movie with the IMDb site. You can try also to update the single movie (if you use the Transparency skin)!
log (German):
10:11:52 T:7148 NOTICE: [Rating Update] - Filmbewertungen Übersicht: 728 von 784 wurde aktualisiert!
10:12:12 T:4492 ERROR: CLocalizeStrings::ClearBlock: Trying to clear non existent block C:\...\XBMC\addons\script.ratingupdate
10:12:14 T:4492 ERROR: Previous line repeats 1 times.

don't know if the Errors are relevant.

many of the 350 missing movies are not up to date with the imdb rating. Shouldn't the log say:
728 of 1143 updated?


RE: [RELEASE] - Rating Update - m4x1m - 2013-05-28

(2013-05-28, 10:17)Jandalf Wrote: log (German):
10:11:52 T:7148 NOTICE: [Rating Update] - Filmbewertungen Übersicht: 728 von 784 wurde aktualisiert!
10:12:12 T:4492 ERROR: CLocalizeStrings::ClearBlock: Trying to clear non existent block C:\...\XBMC\addons\script.ratingupdate
10:12:14 T:4492 ERROR: Previous line repeats 1 times.

don't know if the Errors are relevant.

many of the 350 missing movies are not up to date with the imdb rating. Shouldn't the log say:
728 of 1143 updated?

This means that the IMDb ID is not present in your database for those movies!
The script gets the all the movies with an ID memorized in the c09 field of the database.


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-28

(2013-05-28, 11:17)m4x1m Wrote:
(2013-05-28, 10:17)Jandalf Wrote: log (German):
10:11:52 T:7148 NOTICE: [Rating Update] - Filmbewertungen Übersicht: 728 von 784 wurde aktualisiert!
10:12:12 T:4492 ERROR: CLocalizeStrings::ClearBlock: Trying to clear non existent block C:\...\XBMC\addons\script.ratingupdate
10:12:14 T:4492 ERROR: Previous line repeats 1 times.

don't know if the Errors are relevant.

many of the 350 missing movies are not up to date with the imdb rating. Shouldn't the log say:
728 of 1143 updated?

This means that the IMDb ID is not present in your database for those movies!
The script gets the all the movies with an ID memorized in the c09 field of the database.

SELECT c00, c09 FROM movie WHERE c09='';
gives me only 1 movie.

the movies where i'm missing correct votes have the IMDB ID.

could there be a problem with your LIMIT statement in your SQL query?


RE: [RELEASE] - Rating Update - m4x1m - 2013-05-28

(2013-05-28, 11:34)Jandalf Wrote: SELECT c00, c09 FROM movie WHERE c09='';
gives me only 1 movie.

the movies where i'm missing correct votes have the IMDB ID.

could there be a problem with your LIMIT statement in your SQL query?

Code:
def listing( self ):
          Movies = []
          match = RawXbmcDb.query( 'SELECT idMovie FROM movie' )
          total = len( match )
          match = RawXbmcDb.query( 'SELECT c00, c09, c04, c05 FROM movie WHERE c09!="" ORDER BY c00 ASC LIMIT %s, %s' % ( str( self.Resume ), str( total ) ) )
          for base in match: Movies.append( ( base[0], base[1], base[2], base[3] ) )
          return Movies

Checks in the script folder under userdata/addon_data/
The resume_movies file contain the value of self.Resume, also you can delete the file to restore the initial settings.

The script should ask you if you want resume when the resume_movies file is present and at the end it sum the temporary total value with the resume value to get the total of the movies. Huh


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-28

ok after hours of searching and testing I think found the main problem:

for some reason RawXbmcDb.execute() runs only on the main profile.
cause i have all my problems only on the second profile and know i see that all ratings of my main profile are up to date and in my second profile nothing changed and that's the reason why the script updates always only 785 (main profile movie count) out of 1140 (second profile movie count) movies.

so am I wrong, am I doing something wrong or has RawXbmcDb.execute() problems with multiple profiles?


RE: [RELEASE] - Rating Update - ShadowTek - 2013-05-28

(2013-05-28, 09:41)m4x1m Wrote:
(2013-05-28, 00:46)ShadowTek Wrote: I was wondering if you could add the ability to add/update a MPAA description? For example: Rated R for language, drinking, etc...

I don't think Sad the mpaa rating, from my experience, is not updated very often (perhaps never), and the recent universal scraper gets only the rating without the description, I use also Plex Media Server and the descriptions are not recognized, I removed all descriptions from my database.

Ahh ok, yes I dont think there ever actually updated once added on IMDB, I have almost 900 movies and wanted to add the MPAA description (Aeon Nox uses them)

I'll try and see if I can modify the code to see if I can get it to add them, I only need to do it and run it once (as once there there, they are there lol)

Thanks again Smile

EDIT: Yikes, thats one complicated script... scratch that on trying to modify it, I might blow up my computer lol


RE: [RELEASE] - Rating Update - m4x1m - 2013-05-29

(2013-05-28, 20:56)Jandalf Wrote: so am I wrong, am I doing something wrong or has RawXbmcDb.execute() problems with multiple profiles?

Probably is a problem with multiple profiles. I tested it and I notice that the new profiles have a new database with a different path Sad
But don't worry, now I'm busy with my job, but I'm working also for migrate to json rpc (more slow but more secure)

Please be patient!

(2013-05-28, 23:34)ShadowTek Wrote: EDIT: Yikes, thats one complicated script... scratch that on trying to modify it, I might blow up my computer lol

Big Grin You must edit the file ratings.php (to manage mpaa request) and the ratings_all.py (to manage the new field from database), if you have a good knowledge of python and php is not complicated!


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-29

(2013-05-29, 10:02)m4x1m Wrote:
(2013-05-28, 20:56)Jandalf Wrote: so am I wrong, am I doing something wrong or has RawXbmcDb.execute() problems with multiple profiles?

Probably is a problem with multiple profiles. I tested it and I notice that the new profiles have a new database with a different path Sad
But don't worry, now I'm busy with my job, but I'm working also for migrate to json rpc (more slow but more secure)

Please be patient!

Ok thank you. I will look at it, cause i want to learn xbmc add-on programming, if i got JSON-RPC working I will give you the code.


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-29

Here is a one line fix for more then one profile:

dbutils.py

def findXbmcDb():
if type == 'sqlite3':
if host is None:
path = xbmc.translatePath( "special://userdata/Database" )

change to:
path = xbmc.translatePath( "special://database" )

now python uses the database of the current profile.

and for MySQL Libraries:
replace "special://userdata/advancedsettings.xml"
with "special://profile/advancedsettings.xml"


RE: [RELEASE] - Rating Update - m4x1m - 2013-05-29

(2013-05-29, 14:12)Jandalf Wrote: Here is a one line fix for more then one profile:

dbutils.py

def findXbmcDb():
if type == 'sqlite3':
if host is None:
path = xbmc.translatePath( "special://userdata/Database" )

change to:
path = xbmc.translatePath( "special://database" )

now python uses the database of the current profile.

and for MySQL Libraries:
replace "special://userdata/advancedsettings.xml"
with "special://profile/advancedsettings.xml"

Thanks! This is a good workaround for now (I suspected that the problem was there). When I have rewritten the code for json, all these problems will disappear like magic


RE: [RELEASE] - Rating Update - ShadowTek - 2013-05-29

(2013-05-29, 10:02)m4x1m Wrote:
(2013-05-28, 23:34)ShadowTek Wrote: EDIT: Yikes, thats one complicated script... scratch that on trying to modify it, I might blow up my computer lol

Big Grin You must edit the file ratings.php (to manage mpaa request) and the ratings_all.py (to manage the new field from database), if you have a good knowledge of python and php is not complicated!

Thanks for the help, well, Ive finally managed to get the script to run without errors (with the mpaa modifications) Im still working on having it actually work and add them. Confused

Note I "used" to have a fair knowledge of PHP, but none of python, Im kinda doing a find and replace type of thing lol


RE: [RELEASE] - Rating Update - ShadowTek - 2013-05-31

I cant seem to get it Confused
Don't suppose someone with some free time would mind making a quick dirty hack that adds the mpaa description Angel


RE: [RELEASE] - Rating Update - Jandalf - 2013-05-31

(2013-05-31, 03:51)ShadowTek Wrote: I cant seem to get it Confused
Don't suppose someone with some free time would mind making a quick dirty hack that adds the mpaa description Angel

first step: ratings.php
Code:
if ($movie) echo '{"Rating":"'.$movie->rating().'","Votes":"'.$movie->votes().'","MPAA":"'.$movie->mpaa()['Germany'].'","Response":"True"}'; else echo '{"Response":"False"}';
change the country to yours.

check if it works with the console:
Code:
\path\to\php-cgi\php-cgi.exe -q \path\to\ratings.php -d mid=tt0499549

now ratings_all.py:
Code:
if self.movie[2] != votes or self.movie[3] != rating:
    RawXbmcDb.execute( 'UPDATE movie SET c04="%s", c05="%s" WHERE c09="%s"' % (votes, rating, self.movie[1] ) )
    xbmc.log( "[%s] - %s: %s %s %s %s %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30120) ), str( rating_for_log ), normalize( __language__(30121) ), str( votes ), normalize( __language__(30122) ) ) )
    self.updated = self.updated + 1
else: xbmc.log( "[%s] - %s: %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30116).lower() ) ) )
change to:
Code:
mpaa = decode[u'MPAA']
RawXbmcDb.execute( 'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"' % (votes, rating, mpaa, self.movie[1] ) )
xbmc.log( "[%s] - %s: %s %s %s %s %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30120) ), str( rating_for_log ), normalize( __language__(30121) ), str( votes ), normalize( __language__(30122) ) ) )
self.updated = self.updated + 1

WARNING: I didn't test this, but it should work
WARNING: removing the surrounding "if" will update ALL entries in the database not matter if there is a need (quick and dirtyWink


RE: [RELEASE] - Rating Update - ShadowTek - 2013-06-01

Wow thanks man!! I'll try it now Smile

EDIT:
Ok I get this error:
Code:
18:57:42 T:5052  NOTICE: -->Python Interpreter Initialized<--
18:57:42 T:5052  NOTICE: [Rating Update] - Starting Rating Update v1.2.9
18:57:42 T:3980  NOTICE: Thread XBPyThread start, auto delete: false
18:57:42 T:3980  NOTICE: -->Python Interpreter Initialized<--
18:57:42 T:3980   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.IndentationError'>
                                            Error Contents: ('unexpected indent', ('C:\\Users\\ShadowTek\\AppData\\Roaming\\XBMC\\addons\\script.ratingupdate\\resources\\lib\\ratings_all.py', 306, 9, '\t\t\t      RawXbmcDb.execute( \'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"\' % (votes, rating, mpaa, self.movie[1] ) )\n'))
                                            IndentationError: ('unexpected indent', ('C:\\Users\\ShadowTek\\AppData\\Roaming\\XBMC\\addons\\script.ratingupdate\\resources\\lib\\ratings_all.py', 306, 9, '\t\t\t      RawXbmcDb.execute( \'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"\' % (votes, rating, mpaa, self.movie[1] ) )\n'))
                                            -->End of Python script error report<--

My PHP file looks like this:
Code:
<?php

/*-------------------------*/
/* Rating Update           */
/* by Max (m4x1m) Headroom */
/*-------------------------*/

require("../imdb/imdb.class.php");

if (isset ($_GET["mid"])) {
     if (eregi("tt", $_GET["mid"])) $mid = eregi_replace("tt", "", $_GET["mid"]); else $mid = $_GET["mid"];
     $movie = new imdb($mid);
if ($movie) echo '{"Rating":"'.$movie->rating().'","Votes":"'.$movie->votes().'","MPAA":"'.$movie->mpaa()['USA'].'","Response":"True"}'; else echo '{"Response":"False"}';
}

?>

and that one section of my ratings_all.py looks like this:
Code:
      if get_data != "":
           try:
            decode = json.loads( get_data )
            response = decode[u'Response']
           except: response = "False"
           if response == "True":
            votes = decode[u'Votes']
            if votes != "0":
             rating_for_log = decode[u'Rating']
             rating = decode[u'Rating'] + "00000"
             mpaa = decode[u'MPAA']
                  RawXbmcDb.execute( 'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"' % (votes, rating, mpaa, self.movie[1] ) )
                  xbmc.log( "[%s] - %s: %s %s %s %s %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30120) ), str( rating_for_log ), normalize( __language__(30121) ), str( votes ), normalize( __language__(30122) ) ) )
                  self.updated = self.updated + 1
                 else: xbmc.log( "[%s] - %s: %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30117).lower() ) ) )
           else: xbmc.log( "[%s] - %s: %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30118).lower() ) ) )
      else: xbmc.log( "[%s] - %s: %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30118).lower() ) ) )

Thanks again for the help Smile


RE: [RELEASE] - Rating Update - Jandalf - 2013-06-01

(2013-06-01, 00:17)ShadowTek Wrote: Wow thanks man!! I'll try it now Smile

EDIT:
Ok I get this error:
Code:
18:57:42 T:5052  NOTICE: -->Python Interpreter Initialized<--
18:57:42 T:5052  NOTICE: [Rating Update] - Starting Rating Update v1.2.9
18:57:42 T:3980  NOTICE: Thread XBPyThread start, auto delete: false
18:57:42 T:3980  NOTICE: -->Python Interpreter Initialized<--
18:57:42 T:3980   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.IndentationError'>
                                            Error Contents: ('unexpected indent', ('C:\\Users\\ShadowTek\\AppData\\Roaming\\XBMC\\addons\\script.ratingupdate\\resources\\lib\\ratings_all.py', 306, 9, '\t\t\t      RawXbmcDb.execute( \'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"\' % (votes, rating, mpaa, self.movie[1] ) )\n'))
                                            IndentationError: ('unexpected indent', ('C:\\Users\\ShadowTek\\AppData\\Roaming\\XBMC\\addons\\script.ratingupdate\\resources\\lib\\ratings_all.py', 306, 9, '\t\t\t      RawXbmcDb.execute( \'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"\' % (votes, rating, mpaa, self.movie[1] ) )\n'))
                                            -->End of Python script error report<--

python is a indent sensitive language.
delete 4 spaces in front of each of this rows:
Code:
RawXbmcDb.execute( 'UPDATE movie SET c04="%s", c05="%s" c12="%s" WHERE c09="%s"' % (votes, rating, mpaa, self.movie[1] ) )
                  xbmc.log( "[%s] - %s: %s %s %s %s %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30120) ), str( rating_for_log ), normalize( __language__(30121) ), str( votes ), normalize( __language__(30122) ) ) )
                  self.updated = self.updated + 1
                 else: xbmc.log( "[%s] - %s: %s" % ( __addonname__, normalize( self.movie[0] ), normalize( __language__(30117).lower() ) ) )