added lastplayed field to sync
This commit is contained in:
parent
7a905d4ec2
commit
95a3e76671
5 changed files with 35 additions and 13 deletions
|
@ -139,6 +139,14 @@ class API():
|
|||
UnplayedItemCount = userData.get('UnplayedItemCount')
|
||||
else:
|
||||
UnplayedItemCount = "0"
|
||||
if userData.get('LastPlayedDate') != None:
|
||||
#TODO--> is there some other way to do this ?
|
||||
datestring = userData.get('LastPlayedDate').split('T')[0]
|
||||
timestring = userData.get('LastPlayedDate').split('T')[1]
|
||||
timestring = timestring.split('.')[0]
|
||||
LastPlayedDate = datestring + " " + timestring
|
||||
else:
|
||||
LastPlayedDate = None
|
||||
if userData.get('PlaybackPositionTicks') != None:
|
||||
PlaybackPositionTicks = userData.get('PlaybackPositionTicks')
|
||||
else:
|
||||
|
@ -146,6 +154,7 @@ class API():
|
|||
return {'Watched' : watched,
|
||||
'Favorite' : favorite,
|
||||
'PlayCount': playcount,
|
||||
'LastPlayedDate': LastPlayedDate,
|
||||
'UnplayedItemCount' : UnplayedItemCount,
|
||||
'PlaybackPositionTicks' : str(PlaybackPositionTicks)
|
||||
}
|
||||
|
|
|
@ -136,6 +136,11 @@ class CreateFiles():
|
|||
SubElement(root, "originaltitle").text = utils.convertEncoding(item["Name"])
|
||||
SubElement(root, "sorttitle").text = utils.convertEncoding(item["SortName"])
|
||||
|
||||
if userData.get("LastPlayedDate") != None:
|
||||
SubElement(root, "lastplayed").text = userData.get("LastPlayedDate")
|
||||
else:
|
||||
SubElement(root, "lastplayed").text = ""
|
||||
|
||||
if item.has_key("Album"):
|
||||
SubElement(root, "album").text = item["Album"]
|
||||
|
||||
|
|
|
@ -817,6 +817,7 @@ class LibrarySync():
|
|||
|
||||
if kodiItem != None:
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
||||
if(updated):
|
||||
totalCountsUpdated += 1
|
||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||
|
@ -880,6 +881,7 @@ class LibrarySync():
|
|||
WINDOW.setProperty("episodeid" + str(kodiItem['episodeid']), episode.get('Name') + ";;" + episode.get('Id'))
|
||||
if kodiItem['playcount'] != int(userData.get("PlayCount")):
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
||||
updated = WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
||||
if(updated):
|
||||
totalCountsUpdated += 1
|
||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||
|
@ -957,6 +959,7 @@ class LibrarySync():
|
|||
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||
#write property forced will refresh the item in the list so playcount change is immediately visible
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"movie",True)
|
||||
WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
||||
if(self.ShouldStop(None)):
|
||||
return True
|
||||
|
||||
|
@ -977,7 +980,8 @@ class LibrarySync():
|
|||
if kodiresume != resume:
|
||||
WriteKodiDB().setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
||||
#write property forced will refresh the item in the list so playcount change is immediately visible
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode",True)
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode",True)
|
||||
WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
||||
if(self.ShouldStop(None)):
|
||||
return True
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class ReadKodiDB():
|
|||
def getKodiMovie(self, id):
|
||||
#returns a single movie from Kodi db selected on MB item ID
|
||||
xbmc.sleep(sleepVal)
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "writer", "playcount", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "lastplayed", "writer", "playcount", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
movie = None
|
||||
|
||||
|
@ -39,9 +39,9 @@ class ReadKodiDB():
|
|||
#returns all movies in Kodi db inserted by MB
|
||||
xbmc.sleep(sleepVal)
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "writer", "playcount", "tag", "file"] }, "id": "libMovies"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["art", "rating", "thumbnail", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "lastplayed", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "writer", "playcount", "tag", "file"] }, "id": "libMovies"}')
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["resume", "playcount", "file"] }, "id": "libMovies"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["resume", "playcount", "lastplayed", "file"] }, "id": "libMovies"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
movies = None
|
||||
|
||||
|
@ -99,9 +99,9 @@ class ReadKodiDB():
|
|||
#returns all tvshows in Kodi db inserted by MB
|
||||
xbmc.sleep(sleepVal)
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "file", "fanart"], "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": "plugin.video.mb3sync"}, "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "lastplayed", "file", "fanart"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties": ["sorttitle", "title", "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": "plugin.video.mb3sync"}, "properties": ["sorttitle", "title", "playcount", "lastplayed", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
tvshows = None
|
||||
|
||||
|
@ -125,7 +125,7 @@ class ReadKodiDB():
|
|||
|
||||
def getKodiTVShow(self, id):
|
||||
xbmc.sleep(sleepVal)
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "file", "fanart"], "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": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "lastplayed", "premiered", "rating", "thumbnail", "playcount", "file", "fanart"], "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')):
|
||||
|
@ -173,7 +173,7 @@ class ReadKodiDB():
|
|||
tvshow = self.getKodiTVShow(tvshowid)
|
||||
|
||||
if tvshow != None:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": ' + str(tvshow['tvshowid']) + ', "properties": ["playcount","season", "resume", "episode", "uniqueid", "file"], "sort": {"method": "episode"}}, "id": 1}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": ' + str(tvshow['tvshowid']) + ', "properties": ["playcount","season", "resume", "episode", "lastplayed", "uniqueid", "file"], "sort": {"method": "episode"}}, "id": 1}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
|
@ -189,7 +189,7 @@ class ReadKodiDB():
|
|||
def getKodiMusicVideo(self, id):
|
||||
#returns a single musicvideo from Kodi db selected on MB item ID
|
||||
xbmc.sleep(sleepVal)
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track","plot", "director", "playcount", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMusicVideos"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "' + id + '"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track","plot", "director", "playcount", "lastplayed", "tag", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMusicVideos"}')
|
||||
print json_response
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
musicvideo = None
|
||||
|
@ -206,9 +206,9 @@ class ReadKodiDB():
|
|||
#returns all musicvideos in Kodi db inserted by MB
|
||||
xbmc.sleep(sleepVal)
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track","plot", "director", "playcount", "tag", "file"] }, "id": "libMusicVideos"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["art", "thumbnail", "resume", "runtime", "year", "genre", "studio", "artist", "album", "track", "lastplayed", "plot", "director", "playcount", "tag", "file"] }, "id": "libMusicVideos"}')
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["resume", "playcount", "file"] }, "id": "libMusicVideos"}')
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": { "filter": {"operator": "contains", "field": "path", "value": "plugin.video.mb3sync"}, "properties" : ["resume", "playcount", "lastplayed", "file"] }, "id": "libMusicVideos"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
musicvideos = None
|
||||
if(jsonobject.has_key('result')):
|
||||
|
|
|
@ -101,6 +101,7 @@ class WriteKodiDB():
|
|||
self.getPropertyParam_Batched(KodiItem, "runtime", duration, params)
|
||||
self.getPropertyParam_Batched(KodiItem, "year", MBitem.get("ProductionYear"), params)
|
||||
self.getPropertyParam_Batched(KodiItem, "mpaa", MBitem.get("OfficialRating"), params)
|
||||
self.getPropertyParam_Batched(KodiItem, "lastplayed", userData.get("LastPlayedDate"), params)
|
||||
|
||||
self.getPropertyParamArray_Batched(KodiItem, "tag", MBitem.get("Tag"), params)
|
||||
|
||||
|
@ -201,6 +202,7 @@ class WriteKodiDB():
|
|||
self.getPropertyParamArray_Batched(KodiItem, "genre", MBitem.get("Genres"), params)
|
||||
self.getPropertyParamArray_Batched(KodiItem, "artist", MBitem.get("Artist"), params)
|
||||
self.getPropertyParamArray_Batched(KodiItem, "album", MBitem.get("Album"), params)
|
||||
self.getPropertyParam_Batched(KodiItem, "lastplayed", userData.get("LastPlayedDate"), params)
|
||||
|
||||
if(studios != None):
|
||||
for x in range(0, len(studios)):
|
||||
|
@ -259,7 +261,7 @@ class WriteKodiDB():
|
|||
changes |= self.updateProperty(KodiItem,"runtime",duration,"movie")
|
||||
changes |= self.updateProperty(KodiItem,"year",MBitem.get("ProductionYear"),"movie")
|
||||
changes |= self.updateProperty(KodiItem,"mpaa",MBitem.get("OfficialRating"),"movie")
|
||||
|
||||
changes |= self.updateProperty(KodiItem,"lastplayed",MBitem.get("LastPlayedDate"),"movie")
|
||||
changes |= self.updatePropertyArray(KodiItem,"tag",MBitem.get("Tag"),"movie")
|
||||
|
||||
if MBitem.get("CriticRating") != None:
|
||||
|
@ -337,6 +339,7 @@ class WriteKodiDB():
|
|||
changes |= self.updateProperty(KodiItem,"premiered",premieredate,"tvshow")
|
||||
|
||||
changes |= self.updateProperty(KodiItem,"mpaa",MBitem.get("OfficialRating"),"tvshow")
|
||||
changes |= self.updateProperty(KodiItem,"lastplayed",MBitem.get("LastPlayedDate"),"tvshow")
|
||||
|
||||
if MBitem.get("CriticRating") != None:
|
||||
changes |= self.updateProperty(KodiItem,"rating",int(MBitem.get("CriticRating"))/10,"tvshow")
|
||||
|
@ -397,7 +400,8 @@ class WriteKodiDB():
|
|||
#update common properties
|
||||
duration = (int(timeInfo.get('Duration'))*60)
|
||||
changes |= self.updateProperty(KodiItem,"runtime",duration,"episode")
|
||||
|
||||
changes |= self.updateProperty(KodiItem,"lastplayed",userData.get("LastPlayedDate"),"episode")
|
||||
|
||||
if MBitem.get("PremiereDate") != None:
|
||||
premieredatelist = (MBitem.get("PremiereDate")).split("T")
|
||||
premieredate = premieredatelist[0]
|
||||
|
|
Loading…
Reference in a new issue