small fixes for episodes

This commit is contained in:
Marcel van der Veldt 2015-03-17 00:54:30 +01:00
parent 976a51057d
commit c4c32521d0
1 changed files with 11 additions and 5 deletions

View File

@ -30,7 +30,7 @@ dataPath = os.path.join(addondir,"library")
movieLibrary = os.path.join(dataPath,'movies') movieLibrary = os.path.join(dataPath,'movies')
tvLibrary = os.path.join(dataPath,'tvshows') tvLibrary = os.path.join(dataPath,'tvshows')
sleepVal = 25 sleepVal = 10
showProgress = True showProgress = True
processMovies = True processMovies = True
@ -75,6 +75,7 @@ class LibrarySync():
count = 1 count = 1
for item in movieData: for item in movieData:
xbmc.sleep(sleepVal)
if not item.get('IsFolder'): if not item.get('IsFolder'):
kodiItem = self.getKodiMovie(item["Id"]) kodiItem = self.getKodiMovie(item["Id"])
allMovies.append(item["Id"]) allMovies.append(item["Id"])
@ -116,6 +117,7 @@ class LibrarySync():
count = 0 count = 0
for item in tvShowData: for item in tvShowData:
xbmc.sleep(sleepVal)
if item.get('IsFolder'): if item.get('IsFolder'):
kodiItem = self.getKodiTVShow(item["Id"]) kodiItem = self.getKodiTVShow(item["Id"])
allTVShows.append(item["Id"]) allTVShows.append(item["Id"])
@ -157,6 +159,7 @@ class LibrarySync():
#we have to compare the lists somehow #we have to compare the lists somehow
for item in episodeData: for item in episodeData:
xbmc.sleep(sleepVal)
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber")) comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False matchFound = False
progMessage = "Processing" progMessage = "Processing"
@ -544,7 +547,7 @@ class LibrarySync():
self.updateArtWork(KodiItem,"fanart", API().getArtwork(MBitem, "Backdrop"),"tvshow") self.updateArtWork(KodiItem,"fanart", API().getArtwork(MBitem, "Backdrop"),"tvshow")
#update common properties #update common properties
self.updateProperty(KodiItem,"year",MBitem.get("ProductionYear"),"tvshow") self.updateProperty(KodiItem,"year",str(MBitem.get("ProductionYear")),"tvshow")
self.updateProperty(KodiItem,"mpaa",MBitem.get("OfficialRating"),"tvshow") self.updateProperty(KodiItem,"mpaa",MBitem.get("OfficialRating"),"tvshow")
@ -602,7 +605,7 @@ class LibrarySync():
#update common properties #update common properties
duration = (int(timeInfo.get('Duration'))*60) duration = (int(timeInfo.get('Duration'))*60)
self.updateProperty(KodiItem,"runtime",duration,"episode") self.updateProperty(KodiItem,"runtime",duration,"episode")
self.updateProperty(KodiItem,"firstaired",MBitem.get("ProductionYear"),"episode") self.updateProperty(KodiItem,"firstaired",str(MBitem.get("ProductionYear")),"episode")
if MBitem.get("CriticRating") != None: if MBitem.get("CriticRating") != None:
self.updateProperty(KodiItem,"rating",int(MBitem.get("CriticRating"))/10,"episode") self.updateProperty(KodiItem,"rating",int(MBitem.get("CriticRating"))/10,"episode")
@ -665,12 +668,12 @@ class LibrarySync():
if propertyValue != None: if propertyValue != None:
if type(propertyValue) is int: if type(propertyValue) is int:
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
utils.logMsg("MB3 Sync","updating property..." + str(propertyName) utils.logMsg("MB3 Sync","updating property..." + str(propertyName))
utils.logMsg("MB3 Sync","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue)) utils.logMsg("MB3 Sync","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue))
xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue)) xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
else: else:
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
utils.logMsg("MB3 Sync","updating property..." + str(propertyName) + ": " + propertyValue) utils.logMsg("MB3 Sync","updating property..." + str(propertyName))
utils.logMsg("MB3 Sync","kodi value:" + KodiItem[propertyName] + " MB value: " + propertyValue) utils.logMsg("MB3 Sync","kodi value:" + KodiItem[propertyName] + " MB value: " + propertyValue)
xbmc.executeJSONRPC(jsoncommand_s %(id, propertyName, propertyValue.encode('utf-8'))) xbmc.executeJSONRPC(jsoncommand_s %(id, propertyName, propertyValue.encode('utf-8')))
@ -940,6 +943,9 @@ class LibrarySync():
def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType): def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType):
#use sqlite to set the resume point while json api doesn't support this yet #use sqlite to set the resume point while json api doesn't support this yet
#todo --> submit PR to kodi team to get this added to the jsonrpc api #todo --> submit PR to kodi team to get this added to the jsonrpc api
utils.logMsg("MB3 Sync","setting resume point in kodi db..." + fileType + ": " + str(id))
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos90.db") dbPath = xbmc.translatePath("special://userdata/Database/MyVideos90.db")
connection = sqlite3.connect(dbPath) connection = sqlite3.connect(dbPath)
cursor = connection.cursor( ) cursor = connection.cursor( )