rotten tomatoes removed

This commit is contained in:
im85288 2015-09-27 22:06:22 +01:00
parent dac614b284
commit 0c0832421b
4 changed files with 6 additions and 149 deletions

View file

@ -1,89 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from traceback import print_exc
import xbmc
import xbmcgui
import threading
import Utils as utils
from ReadKodiDB import ReadKodiDB
from ClientInformation import ClientInformation
class LibraryMonitor(threading.Thread):
event = None
exit = False
liPath = None
liPathLast = None
WINDOW = xbmcgui.Window(10000)
clientInfo = ClientInformation()
addonName = clientInfo.getAddonName()
def __init__(self, *args):
self.event = threading.Event()
threading.Thread.__init__(self, *args)
def logMsg(self, msg, lvl=1):
className = self.__class__.__name__
utils.logMsg("%s %s" % (self.addonName, className), msg, int(lvl))
def stop(self):
self.logMsg("LibraryMonitor - stop called",0)
self.exit = True
self.event.set()
def run(self):
self.logMsg("LIBRARY MONITOR running ")
WINDOW = self.WINDOW
lastListItemLabel = None
while (self.exit != True):
# monitor listitem props when videolibrary is active
if (xbmc.getCondVisibility("[Window.IsActive(videolibrary) | Window.IsActive(movieinformation)] + !Window.IsActive(fullscreenvideo)")):
self.liPath = xbmc.getInfoLabel("ListItem.Path")
liLabel = xbmc.getInfoLabel("ListItem.Label")
if ((liLabel != lastListItemLabel) and xbmc.getCondVisibility("!Container.Scrolling")):
self.liPathLast = self.liPath
lastListItemLabel = liLabel
# update the listitem stuff
try:
self.setRatingsInfo()
except Exception as e:
self.logMsg("ERROR in LibraryMonitor ! --> " + str(e), 0)
else:
#reset window props
WINDOW.clearProperty("EmbySkinHelper.ListItemRottenTomatoes")
WINDOW.clearProperty('EmbySkinHelper.ListItemRottenTomatoesSummary')
WINDOW.clearProperty('EmbySkinHelper.ListItemMetaScore')
xbmc.sleep(150)
def setRatingsInfo(self):
WINDOW = self.WINDOW
embyId = self.liPath.split("/")[-2]
criticrating = ReadKodiDB().getCriticRatingByEmbyId(embyId)
if criticrating:
WINDOW.setProperty('EmbySkinHelper.ListItemRottenTomatoes', criticrating)
else:
WINDOW.clearProperty('EmbySkinHelper.ListItemRottenTomatoes')
criticratingsummary = ReadKodiDB().getCriticRatingSummaryByEmbyId(embyId)
if criticratingsummary:
WINDOW.setProperty('EmbySkinHelper.ListItemRottenTomatoesSummary', criticratingsummary)
else:
WINDOW.clearProperty('EmbySkinHelper.ListItemRottenTomatoesSummary')
metascore = ReadKodiDB().getMetaScoreRatingByEmbyId(embyId)
if metascore:
WINDOW.setProperty('EmbySkinHelper.ListItemMetaScore', metascore)
else:
WINDOW.clearProperty('EmbySkinHelper.ListItemMetaScore')

View file

@ -137,12 +137,9 @@ class LibrarySync(threading.Thread):
cursor = connection.cursor() cursor = connection.cursor()
#Add the special emby table #Add the special emby table
cursor.execute("CREATE TABLE IF NOT EXISTS emby(emby_id TEXT, kodi_id INTEGER, media_type TEXT, checksum TEXT, parent_id INTEGER, kodi_file_id INTEGER, rotten_tomatoes TEXT, rotten_tomatoes_summary TEXT, metascore TEXT)") cursor.execute("CREATE TABLE IF NOT EXISTS emby(emby_id TEXT, kodi_id INTEGER, media_type TEXT, checksum TEXT, parent_id INTEGER, kodi_file_id INTEGER)")
try: try:
cursor.execute("ALTER TABLE emby ADD COLUMN kodi_file_id INTEGER") cursor.execute("ALTER TABLE emby ADD COLUMN kodi_file_id INTEGER")
cursor.execute("ALTER TABLE emby ADD COLUMN rotten_tomatoes TEXT")
cursor.execute("ALTER TABLE emby ADD COLUMN rotten_tomatoes_summary TEXT")
cursor.execute("ALTER TABLE emby ADD COLUMN metascore TEXT")
except: pass except: pass
connection.commit() connection.commit()

View file

@ -130,51 +130,3 @@ class ReadKodiDB():
allsongs = cursor.fetchall() allsongs = cursor.fetchall()
#this will return a list with tuples of all items returned from the database #this will return a list with tuples of all items returned from the database
return allsongs return allsongs
def getCriticRatingByEmbyId(self, id, connection=None, cursor=None):
if not connection:
connection = utils.KodiSQL()
cursor = connection.cursor()
closeCon = True
else:
closeCon = False
cursor.execute("SELECT rotten_tomatoes FROM emby WHERE emby_id=?",(id,))
result = cursor.fetchone()
if closeCon:
connection.close()
if result:
return result[0]
else:
return None
def getCriticRatingSummaryByEmbyId(self, id, connection=None, cursor=None):
if not connection:
connection = utils.KodiSQL()
cursor = connection.cursor()
closeCon = True
else:
closeCon = False
cursor.execute("SELECT rotten_tomatoes_summary FROM emby WHERE emby_id=?",(id,))
result = cursor.fetchone()
if closeCon:
connection.close()
if result:
return result[0]
else:
return None
def getMetaScoreRatingByEmbyId(self, id, connection=None, cursor=None):
if not connection:
connection = utils.KodiSQL()
cursor = connection.cursor()
closeCon = True
else:
closeCon = False
cursor.execute("SELECT metascore FROM emby WHERE emby_id=?",(id,))
result = cursor.fetchone()
if closeCon:
connection.close()
if result:
return result[0]
else:
return None

View file

@ -107,9 +107,6 @@ class WriteKodiVideoDB():
tagline = API().getTagline(MBitem) tagline = API().getTagline(MBitem)
votecount = MBitem.get('VoteCount') votecount = MBitem.get('VoteCount')
rating = MBitem.get('CommunityRating') rating = MBitem.get('CommunityRating')
criticrating = MBitem.get('CriticRating')
criticratingsummary = MBitem.get('CriticRatingSummary')
metascorerating = MBitem.get('Metascore')
writer = " / ".join(people.get('Writer')) writer = " / ".join(people.get('Writer'))
year = MBitem.get('ProductionYear') year = MBitem.get('ProductionYear')
imdb = API().getProvider(MBitem, "imdb") imdb = API().getProvider(MBitem, "imdb")
@ -181,8 +178,8 @@ class WriteKodiVideoDB():
cursor.execute(query, (title, plot, shortplot, tagline, votecount, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailerUrl, country, movieid)) cursor.execute(query, (title, plot, shortplot, tagline, votecount, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailerUrl, country, movieid))
# Update the checksum in emby table and critic ratings # Update the checksum in emby table and critic ratings
query = "UPDATE emby SET checksum = ?, rotten_tomatoes = ?, rotten_tomatoes_summary = ?, metascore = ? WHERE emby_id = ?" query = "UPDATE emby SET checksum = ? WHERE emby_id = ?"
cursor.execute(query, (checksum, criticrating, criticratingsummary, metascorerating, embyId)) cursor.execute(query, (checksum, embyId))
##### OR ADD THE MOVIE ##### ##### OR ADD THE MOVIE #####
else: else:
@ -223,8 +220,8 @@ class WriteKodiVideoDB():
self.AddTagToMedia(movieid, viewTag, "movie", cursor) self.AddTagToMedia(movieid, viewTag, "movie", cursor)
# Create the reference in emby table # Create the reference in emby table
query = "INSERT INTO emby(emby_id, kodi_id, kodi_file_id, media_type, checksum, rotten_tomatoes, rotten_tomatoes_summary, metascore) values(?, ?, ?, ?, ?, ?, ?, ?)" query = "INSERT INTO emby(emby_id, kodi_id, kodi_file_id, media_type, checksum) values(?, ?, ?, ?, ?)"
cursor.execute(query, (embyId, movieid, fileid, "movie", checksum, criticrating, criticratingsummary, metascorerating)) cursor.execute(query, (embyId, movieid, fileid, "movie", checksum))
# Update or insert actors # Update or insert actors