2018-12-17, 23:47
I am trying to log a filename on movie start. Here is my first attempt:
I have the following questions:
1) I am getting UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 32: ordinal not in range(128) when trying to xbmc.log. How to fix it? (NFS source is used, file path contains Russian symbols)
2) Do I need to sleep to get movie filename?
3) Do I really need to do while(1)?
4) What should I do to activate my addon at kodi start?
python:# -*- coding: utf-8 -*-
import xbmcaddon
import xbmc, xbmcgui
__addon__ = xbmcaddon.Addon()
__addon_id__ = __addon__.getAddonInfo('id')
__addonname__ = __addon__.getAddonInfo('name')
__icon__ = __addon__.getAddonInfo('icon')
__addonpath__ = xbmc.translatePath(__addon__.getAddonInfo('path'))
__lang__ = __addon__.getLocalizedString
class MyPlayer( xbmc.Player ) :
def __init__ ( self ):
xbmc.Player.__init__( self )
xbmc.log('>>>> ' + __addonname__ + ' <<<< ' + 'init')
def onPlayBackStarted(self):
xbmc.log('>>>> ' + __addonname__ + ' <<<< ' + 'onPlayBackStarted')
if xbmc.Player().isPlayingVideo()==1:
xbmc.sleep(2000) # do I need it to get file name?
tag = xbmc.Player().getVideoInfoTag()
path = tag.getFile() # getPath()
xbmc.log(path.encode('utf-8'))
#xbmc.executebuiltin('Notification(' + __addonname__ + ', ' + path.decode('utf-8') + ', 8000, ' + __icon__ + ')')
p=MyPlayer()
while(1):
xbmc.sleep(500)
I have the following questions:
1) I am getting UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 32: ordinal not in range(128) when trying to xbmc.log. How to fix it? (NFS source is used, file path contains Russian symbols)
2) Do I need to sleep to get movie filename?
3) Do I really need to do while(1)?
4) What should I do to activate my addon at kodi start?