Fix direct play monitoring

This commit is contained in:
tomkat83 2016-03-16 12:49:55 +01:00
parent 32ddb6cb78
commit 769b741060
2 changed files with 5 additions and 19 deletions

View file

@ -68,7 +68,6 @@ class KodiMonitor(xbmc.Monitor):
if data: if data:
data = json.loads(data,'utf-8') data = json.loads(data,'utf-8')
if method == "Player.OnPlay": if method == "Player.OnPlay":
# Set up report progress for emby playback # Set up report progress for emby playback
item = data.get('item') item = data.get('item')
@ -81,19 +80,15 @@ class KodiMonitor(xbmc.Monitor):
if ((utils.settings('useDirectPaths') == "1" and not type == "song") or if ((utils.settings('useDirectPaths') == "1" and not type == "song") or
(type == "song" and utils.settings('enableMusic') == "true")): (type == "song" and utils.settings('enableMusic') == "true")):
# Set up properties for player # Set up properties for player
embyconn = utils.kodiSQL('emby') with embydb.GetEmbyDB() as emby_db:
embycursor = embyconn.cursor()
emby_db = embydb.Embydb_Functions(embycursor)
emby_dbitem = emby_db.getItem_byKodiId(kodiid, type) emby_dbitem = emby_db.getItem_byKodiId(kodiid, type)
try: try:
itemid = emby_dbitem[0] itemid = emby_dbitem[0]
except TypeError: except TypeError:
self.logMsg("No kodiid returned.", 1) self.logMsg("No kodiid returned.", 1)
else: else:
url = "{server}/emby/Users/{UserId}/Items/%s?format=json" % itemid url = "{server}/library/metadata/%s" % itemid
result = doUtils.downloadUrl(url) result = doUtils.downloadUrl(url)
self.logMsg("Item: %s" % result, 2)
playurl = None playurl = None
count = 0 count = 0
while not playurl and count < 2: while not playurl and count < 2:
@ -114,8 +109,6 @@ class KodiMonitor(xbmc.Monitor):
value="DirectPlay") value="DirectPlay")
# Set properties for player.py # Set properties for player.py
playback.setProperties(playurl, listItem) playback.setProperties(playurl, listItem)
finally:
embycursor.close()
elif method == "VideoLibrary.OnUpdate": elif method == "VideoLibrary.OnUpdate":
# Manually marking as watched/unwatched # Manually marking as watched/unwatched
@ -128,9 +121,7 @@ class KodiMonitor(xbmc.Monitor):
self.logMsg("Item is invalid for playstate update.", 1) self.logMsg("Item is invalid for playstate update.", 1)
else: else:
# Send notification to the server. # Send notification to the server.
embyconn = utils.kodiSQL('emby') with embydb.GetEmbyDB() as emby_db:
embycursor = embyconn.cursor()
emby_db = embydb.Embydb_Functions(embycursor)
emby_dbitem = emby_db.getItem_byKodiId(kodiid, type) emby_dbitem = emby_db.getItem_byKodiId(kodiid, type)
try: try:
itemid = emby_dbitem[0] itemid = emby_dbitem[0]
@ -148,10 +139,6 @@ class KodiMonitor(xbmc.Monitor):
else: else:
scrobble(itemid, 'unwatched') scrobble(itemid, 'unwatched')
finally:
embycursor.close()
elif method == "VideoLibrary.OnRemove": elif method == "VideoLibrary.OnRemove":
# Removed function, because with plugin paths + clean library, it will wipe # Removed function, because with plugin paths + clean library, it will wipe
# entire library if user has permissions. Instead, use the emby context menu available # entire library if user has permissions. Instead, use the emby context menu available

View file

@ -251,7 +251,6 @@ class PlaybackUtils():
return True return True
def setProperties(self, playurl, listitem): def setProperties(self, playurl, listitem):
window = utils.window window = utils.window
# Set all properties necessary for plugin path playback # Set all properties necessary for plugin path playback
itemid = self.API.getRatingKey() itemid = self.API.getRatingKey()