2016-03-22, 07:12
I wrote a simple python script. The script is intended to take a screenshot and save it to the appropriate "extrafanart" folder (determined by the path of the now-playing video item). The script works (running it in windows/win32, anyway), but when I run it on a video in a path with unicode, my Kodi log shows an error even though the screen shot is created. So far this is pretty much a "go path" script I realize. So any ideas of how to improve this script would be greatly appreciated. The script is simply:
I have a log here:
http://xbmclogs.com/pujgq2ahu
Of interest is at line 1325 where I set the screenshot path to a windows file path with unicode and get the error at 1339 and then again at line 1832 where the path is just ascii. But again, the screenshot is properly saved in both instances.
TIA
scott s.
.
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#
import xbmc
import os
current_folder = xbmc.getInfoLabel('Player.Folderpath')
current_folder = unicode(current_folder,'utf-8').replace('\\', '/')
current_content = xbmc.getCondVisibility('VideoPlayer.Content(episodes)')
if current_content :
shot_folder = current_folder + '../extrafanart/'
else: shot_folder = current_folder + 'extrafanart/'
if not os.path.exists(shot_folder):
os.mkdir(shot_folder)
shot_folder = '\"' + shot_folder.encode('utf-8') + '\"'
xbmc.log(shot_folder)
response = xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params": {"setting": "debug.screenshotpath", "value": %s}, "id":1}' %shot_folder)
# if (response['result']) xbmc.executebuiltin(TakeScreenshot)
xbmc.executebuiltin('TakeScreenshot')
I have a log here:
http://xbmclogs.com/pujgq2ahu
Of interest is at line 1325 where I set the screenshot path to a windows file path with unicode and get the error at 1339 and then again at line 1832 where the path is just ascii. But again, the screenshot is properly saved in both instances.
TIA
scott s.
.