Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions script.xbmcbackup/addon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmcbackup"
name="Backup" version="1.7.2" provider-name="robweber">
name="Backup" version="1.7.3" provider-name="robweber">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.dateutil" version="2.8.0" />
Expand All @@ -24,9 +24,8 @@
<screenshot>resources/images/screenshot3.jpg</screenshot>
<screenshot>resources/images/screenshot4.jpg</screenshot>
</assets>
<news>Version 1.7.2
Fix bug with gui settings restore
strptime Python bugfix
<news>Version 1.7.3
additional strptime modifications to fix scheduler behavior
</news>
<summary lang="ar_SA">إنسخ إحتياطياً قاعده بيانات إكس بى إم سى وملفات اﻹعدادات فى حاله وقوع إنهيار مع إمكانيه اﻹسترجاع</summary>
<summary lang="bg_BG">Добавката може да създава резервни копия и възстановява базата данни и настройките на Kodi, в случай на срив или повреда на файловете.</summary>
Expand Down
23 changes: 8 additions & 15 deletions script.xbmcbackup/resources/lib/authorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
pass

# fix for datetime.strptime bug https://kodi.wiki/view/Python_Problems#datetime.strptime
class proxydt(datetime.datetime):
def patch_strptime(date_string, format):
return datetime.datetime(*(time.strptime(date_string, format)[:6]))

@classmethod
def strptime(cls, date_string, format):
return datetime.datetime(*(time.strptime(date_string, format)[:6]))

datetime.datetime = proxydt

class QRCode(xbmcgui.WindowXMLDialog):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -139,24 +135,21 @@ def getClient(self):

def _setToken(self, token):
# write the token files
token_file = open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'w')

token_file.write(json.dumps({"access_token": token.access_token, "refresh_token": token.refresh_token, "expiration": str(token.expires_at)}))
token_file.close()
with open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'w') as token_file:
token_file.write(json.dumps({"access_token": token.access_token, "refresh_token": token.refresh_token, "expiration": str(token.expires_at)}))

def _getToken(self):
result = {}
# get token, if it exists
if(xbmcvfs.exists(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE))):
token_file = open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE))
token = token_file.read()
token = ""
with open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'r') as token_file:
token = token_file.read()

if(token.strip() != ""):
result = json.loads(token)
# convert expiration back to a datetime object
result['expiration'] = datetime.datetime.strptime(result['expiration'], "%Y-%m-%d %H:%M:%S.%f")

token_file.close()
result['expiration'] = patch_strptime(result['expiration'], "%Y-%m-%d %H:%M:%S.%f")

return result

Expand Down
Loading