speed boost playcount sync

This commit is contained in:
Marcel van der Veldt 2015-03-19 10:52:21 +01:00
parent 5ec6afaf99
commit 593d969669
2 changed files with 22 additions and 10 deletions

View file

@ -558,9 +558,8 @@ class LibrarySync():
count = 1
for item in allMB3Movies:
xbmc.sleep(sleepVal)
if not item.get('IsFolder'):
kodiItem = None
for kodimovie in allKodiMovies:
if item["Id"] in kodimovie["file"]:
@ -571,11 +570,11 @@ class LibrarySync():
timeInfo = API().getTimeInfo(item)
if kodiItem != None:
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"movie")
kodiresume = int(round(kodiItem['resume'].get("position")))
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
total = int(round(float(timeInfo.get("TotalTime"))))*60
if kodiresume != resume:
xbmc.sleep(sleepVal)
print "updating resumepoint for movie " + str(kodiItem['movieid'])
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
@ -604,8 +603,9 @@ class LibrarySync():
showCurrent = 1
for item in tvshowData:
xbmc.sleep(sleepVal)
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
kodiEpisodes = ReadKodiDB().getKodiEpisodes(item["Id"],False)
if (episodeData != None):
if(pDialog != None):
@ -614,8 +614,17 @@ class LibrarySync():
count = 1
for episode in episodeData:
xbmc.sleep(sleepVal)
kodiItem = ReadKodiDB().getKodiEpisodeByMbItem(episode)
kodiItem = None
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
matchFound = False
if kodiEpisodes != None:
for KodiEpisode in kodiEpisodes:
comparestring2 = str(KodiEpisode["season"]) + "-" + str(KodiEpisode["episode"])
if comparestring1 == comparestring2:
kodiItem = KodiEpisode
break
userData=API().getUserData(episode)
timeInfo = API().getTimeInfo(episode)
if kodiItem != None:
@ -625,6 +634,7 @@ class LibrarySync():
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
total = int(round(float(timeInfo.get("TotalTime"))))*60
if kodiresume != resume:
xbmc.sleep(sleepVal)
WriteKodiDB().setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
if(self.ShouldStop()):

View file

@ -113,9 +113,9 @@ class ReadKodiDB():
tvshow = tvshows[0]
return tvshow
def getKodiEpisodes(self, id):
def getKodiEpisodes(self, id,fullInfo = True):
episodes = None
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties": ["sorttitle", "title", "originaltitle", "playcount", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties": ["title", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
jsonobject = json.loads(json_response.decode('utf-8','replace'))
tvshow = None
if(jsonobject.has_key('result')):
@ -123,8 +123,10 @@ class ReadKodiDB():
if(result.has_key('tvshows')):
tvshows = result['tvshows']
tvshow = tvshows[0]
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "file", "lastplayed", "rating", "resume", "art", "streamdetails", "firstaired", "runtime", "writer", "cast", "dateadded"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
if fullInfo:
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "file", "lastplayed", "rating", "resume", "art", "streamdetails", "firstaired", "runtime", "writer", "cast", "dateadded"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
else:
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "season", "episode", "lastplayed", "resume"], "sort": {"method": "episode"}}, "id": 1}' %tvshow['tvshowid'])
jsonobject = json.loads(json_response.decode('utf-8','replace'))
episodes = None
if(jsonobject.has_key('result')):