Don't normalize moviename for playback report

- Instead, use string (not unicode) for window
This commit is contained in:
tomkat83 2016-04-11 19:18:55 +02:00
parent 4ca321faea
commit 543cec93b4
2 changed files with 9 additions and 20 deletions

View file

@ -3,7 +3,6 @@
############################################################################### ###############################################################################
import json import json
from unicodedata import normalize
import xbmc import xbmc
import xbmcgui import xbmcgui
@ -179,7 +178,7 @@ class KodiMonitor(xbmc.Monitor):
return return
log("Found Plex id %s for Kodi id %s" % (plexid, kodiid), 1) log("Found Plex id %s for Kodi id %s" % (plexid, kodiid), 1)
# Get currently playing file - can take a while # Get currently playing file - can take a while. Will be utf-8!
try: try:
currentFile = self.xbmcplayer.getPlayingFile() currentFile = self.xbmcplayer.getPlayingFile()
xbmc.sleep(300) xbmc.sleep(300)
@ -197,12 +196,7 @@ class KodiMonitor(xbmc.Monitor):
return return
else: else:
count += 1 count += 1
currentFile = currentFile.decode('utf-8')
log("Currently playing file is: %s" % currentFile, 1) log("Currently playing file is: %s" % currentFile, 1)
# Normalize to string, because we need to use this in WINDOW(key),
# where key can only be string
currentFile = normalize('NFKD', currentFile).encode('ascii', 'ignore')
log('Normalized filename: %s' % currentFile, 1)
# Set some stuff if Kodi initiated playback # Set some stuff if Kodi initiated playback
if ((utils.settings('useDirectPaths') == "1" and not type == "song") or if ((utils.settings('useDirectPaths') == "1" and not type == "song") or
@ -212,7 +206,7 @@ class KodiMonitor(xbmc.Monitor):
return return
# Save currentFile for cleanup later and to be able to access refs # Save currentFile for cleanup later and to be able to access refs
window('plex_lastPlayedFiled', value=currentFile) window('plex_lastPlayedFiled', value=currentFile.decode('utf-8'))
window('Plex_currently_playing_itemid', value=plexid) window('Plex_currently_playing_itemid', value=plexid)
window("emby_%s.itemid" % currentFile, value=plexid) window("emby_%s.itemid" % currentFile, value=plexid)
log('Finish playback startup', 1) log('Finish playback startup', 1)

View file

@ -3,7 +3,6 @@
############################################################################### ###############################################################################
import json import json
from unicodedata import normalize
import xbmc import xbmc
import xbmcgui import xbmcgui
@ -58,7 +57,7 @@ class Player(xbmc.Player):
xbmcplayer = self.xbmcplayer xbmcplayer = self.xbmcplayer
self.stopAll() self.stopAll()
# Get current file # Get current file (in utf-8!)
try: try:
currentFile = xbmcplayer.getPlayingFile() currentFile = xbmcplayer.getPlayingFile()
xbmc.sleep(300) xbmc.sleep(300)
@ -79,15 +78,10 @@ class Player(xbmc.Player):
if not currentFile: if not currentFile:
log('Error getting a currently playing file; abort reporting', -1) log('Error getting a currently playing file; abort reporting', -1)
return return
currentFile = currentFile.decode('utf-8')
# Normalize to string, because we need to use this in WINDOW(key),
# where key can only be string
currentFile = normalize('NFKD', currentFile).encode('ascii', 'ignore')
log('Normalized filename: %s' % currentFile, 1)
# Save currentFile for cleanup later and for references # Save currentFile for cleanup later and for references
self.currentFile = currentFile self.currentFile = currentFile
window('plex_lastPlayedFiled', value=currentFile) window('plex_lastPlayedFiled', value=currentFile.decode('utf-8'))
# We may need to wait for info to be set in kodi monitor # We may need to wait for info to be set in kodi monitor
itemId = window("emby_%s.itemid" % currentFile) itemId = window("emby_%s.itemid" % currentFile)
count = 0 count = 0
@ -100,7 +94,8 @@ class Player(xbmc.Player):
return return
count += 1 count += 1
log("ONPLAYBACK_STARTED: %s itemid: %s" % (currentFile, itemId), 0) log("ONPLAYBACK_STARTED: %s itemid: %s"
% (currentFile.decode('utf-8'), itemId), 0)
embyitem = "emby_%s" % currentFile embyitem = "emby_%s" % currentFile
runtime = window("%s.runtime" % embyitem) runtime = window("%s.runtime" % embyitem)
@ -414,7 +409,7 @@ class Player(xbmc.Player):
def onPlayBackPaused(self): def onPlayBackPaused(self):
currentFile = self.currentFile currentFile = self.currentFile
self.logMsg("PLAYBACK_PAUSED: %s" % currentFile, 2) self.logMsg("PLAYBACK_PAUSED: %s" % currentFile.decode('utf-8'), 2)
if self.played_info.get(currentFile): if self.played_info.get(currentFile):
self.played_info[currentFile]['paused'] = True self.played_info[currentFile]['paused'] = True
@ -424,7 +419,7 @@ class Player(xbmc.Player):
def onPlayBackResumed(self): def onPlayBackResumed(self):
currentFile = self.currentFile currentFile = self.currentFile
self.logMsg("PLAYBACK_RESUMED: %s" % currentFile, 2) self.logMsg("PLAYBACK_RESUMED: %s" % currentFile.decode('utf-8'), 2)
if self.played_info.get(currentFile): if self.played_info.get(currentFile):
self.played_info[currentFile]['paused'] = False self.played_info[currentFile]['paused'] = False
@ -434,7 +429,7 @@ class Player(xbmc.Player):
def onPlayBackSeek(self, time, seekOffset): def onPlayBackSeek(self, time, seekOffset):
# Make position when seeking a bit more accurate # Make position when seeking a bit more accurate
currentFile = self.currentFile currentFile = self.currentFile
self.logMsg("PLAYBACK_SEEK: %s" % currentFile, 2) self.logMsg("PLAYBACK_SEEK: %s" % currentFile.decode('utf-8'), 2)
if self.played_info.get(currentFile): if self.played_info.get(currentFile):
position = self.xbmcplayer.getTime() position = self.xbmcplayer.getTime()