2019-11-25 22:48:42 +01:00
|
|
|
import xbmc
|
|
|
|
import xbmcgui
|
|
|
|
import xbmcaddon
|
2020-11-18 21:07:06 +01:00
|
|
|
import xbmcvfs
|
2012-09-05 21:28:43 +02:00
|
|
|
|
2019-11-26 17:43:38 +01:00
|
|
|
__addon_id__ = 'script.xbmcbackup'
|
2012-09-05 21:28:43 +02:00
|
|
|
__Addon = xbmcaddon.Addon(__addon_id__)
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2012-09-13 16:52:17 +02:00
|
|
|
def data_dir():
|
|
|
|
return __Addon.getAddonInfo('profile')
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2012-10-26 16:17:21 +02:00
|
|
|
def addon_dir():
|
|
|
|
return __Addon.getAddonInfo('path')
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2013-12-05 21:26:35 +01:00
|
|
|
def openSettings():
|
|
|
|
__Addon.openSettings()
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2019-11-25 22:45:41 +01:00
|
|
|
def log(message, loglevel=xbmc.LOGDEBUG):
|
2019-11-25 22:56:59 +01:00
|
|
|
xbmc.log(__addon_id__ + "-" + __Addon.getAddonInfo('version') + ": " + message, level=loglevel)
|
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
|
2012-09-06 22:28:41 +02:00
|
|
|
def showNotification(message):
|
2020-11-18 21:07:06 +01:00
|
|
|
xbmcgui.Dialog().notification(getString(30010), message, time=4000, icon=xbmcvfs.translatePath(__Addon.getAddonInfo('path') + "/resources/images/icon.png"))
|
2012-09-06 22:28:41 +02:00
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
def getSetting(name):
|
|
|
|
return __Addon.getSetting(name)
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2019-11-27 21:19:25 +01:00
|
|
|
def getSettingBool(name):
|
|
|
|
return bool(__Addon.getSettingBool(name))
|
|
|
|
|
|
|
|
|
|
|
|
def getSettingInt(name):
|
|
|
|
return __Addon.getSettingInt(name)
|
|
|
|
|
|
|
|
|
2019-11-25 22:45:41 +01:00
|
|
|
def setSetting(name, value):
|
|
|
|
__Addon.setSetting(name, value)
|
2019-11-25 22:56:59 +01:00
|
|
|
|
|
|
|
|
2012-09-05 21:28:43 +02:00
|
|
|
def getString(string_id):
|
|
|
|
return __Addon.getLocalizedString(string_id)
|
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2019-11-25 22:45:41 +01:00
|
|
|
def getRegionalTimestamp(date_time, dateformat=['dateshort']):
|
2019-08-26 22:40:15 +02:00
|
|
|
result = ''
|
2019-11-25 22:33:34 +01:00
|
|
|
|
2019-08-26 22:40:15 +02:00
|
|
|
for aFormat in dateformat:
|
|
|
|
result = result + ("%s " % date_time.strftime(xbmc.getRegion(aFormat)))
|
2019-11-25 22:33:34 +01:00
|
|
|
|
2019-08-26 22:40:15 +02:00
|
|
|
return result.strip()
|
2019-12-10 22:16:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
def diskString(fSize):
|
|
|
|
# convert a size in kilobytes to the best possible match and return as a string
|
|
|
|
fSize = float(fSize)
|
|
|
|
i = 0
|
|
|
|
sizeNames = ['KB', 'MB', 'GB', 'TB']
|
|
|
|
|
|
|
|
while(fSize > 1024):
|
|
|
|
fSize = fSize / 1024
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
return "%0.2f%s" % (fSize, sizeNames[i])
|