def run(self): xbmc.log( '[ script.module.myaccounts ] Addon checking available updates', LOGNOTICE) try: import re import requests repo_xml = requests.get( 'https://raw.githubusercontent.com/a4k-openproject/repository.myaccounts/master/zips/addons.xml' ) if repo_xml.status_code != 200: return xbmc.log( '[ script.module.myaccounts ] Could not connect to remote repo XML: status code = %s' % repo_xml.status_code, LOGNOTICE) repo_version = re.findall( r'<addon id=\"script.module.myaccounts\".*version=\"(\d*.\d*.\d*.\d*)\"', repo_xml.text)[0] local_version = control.addonVersion() if control.check_version_numbers(local_version, repo_version): while control.condVisibility('Library.IsScanningVideo'): control.sleep(10000) xbmc.log( '[ script.module.myaccounts ] A newer version is available. Installed Version: v%s, Repo Version: v%s' % (local_version, repo_version), LOGNOTICE) control.notification( title='default', message= 'A new verison of My Accounts is available from the repository. Please consider updating to v%s' % repo_version, icon='default', time=5000, sound=False) except: import traceback traceback.print_exc()
def get(): myaccounts_path = addonPath() myaccounts_version = addonVersion() changelogfile = joinPath(myaccounts_path, 'changelog.txt') r = open(changelogfile, 'r', encoding='utf-8', errors='ignore') text = r.read() r.close() heading = '[B]My Accounts - v%s - ChangeLog[/B]' % myaccounts_version windows = TextViewerXML('textviewer.xml', myaccounts_path, heading=heading, text=text) windows.run() del windows
def get(file): myaccounts_path = addonPath() myaccounts_version = addonVersion() helpFile = joinPath(myaccounts_path, 'lib', 'myaccounts', 'help', file + '.txt') r = open(helpFile, 'r', encoding='utf-8', errors='ignore') text = r.read() r.close() heading = '[B]My Accounts - v%s - %s[/B]' % (myaccounts_version, file) windows = TextViewerXML('textviewer.xml', myaccounts_path, heading=heading, text=text) windows.run() del windows
def upload_LogFile(): from myaccounts.modules.control import notification url = 'https://paste.kodi.tv/' log_file = joinPath(LOGPATH, 'myaccounts.log') if not existsPath(log_file): return notification( message='Log File not found, likely logging is not enabled.') try: import requests from myaccounts.modules.control import addonVersion, selectDialog f = open(log_file, 'r', encoding='utf-8', errors='ignore') text = f.read() f.close() UserAgent = 'MyAccounts %s' % addonVersion() response = requests.post(url + 'documents', data=text.encode('utf-8', errors='ignore'), headers={'User-Agent': UserAgent}) # log('log_response: ' + str(response)) if 'key' in response.json(): result = url + response.json()['key'] log('My Accounts log file uploaded to: %s' % result) from sys import platform as sys_platform supported_platform = any(value in sys_platform for value in ['win32', 'linux2']) highlight_color = 'gold' list = [ ('[COLOR %s]url:[/COLOR] %s' % (highlight_color, str(result)), str(result)) ] if supported_platform: list += [('[COLOR %s] -- Copy url To Clipboard[/COLOR]' % highlight_color, ' ')] select = selectDialog([i[0] for i in list], lang(32349)) if 'Copy url To Clipboard' in list[select][0]: copy2clip(list[select - 1][1]) elif 'message' in response.json(): notification(message='myaccounts Log upload failed: %s' % str(response.json()['message'])) log('My Accounts Log upload failed: %s' % str(response.json()['message']), level=LOGERROR) else: notification(message='myaccounts Log upload failed') log('My Accounts Log upload failed: %s' % response.text, level=LOGERROR) except: error('My Accounts log upload failed') notification(message='pastebin post failed: See log for more info')
# -*- coding: utf-8 -*- """ My Accounts """ from myaccounts.modules import control myaccounts_path = control.addonPath() myaccounts_version = control.addonVersion() changelogfile = control.joinPath(myaccounts_path, 'changelog.txt') def get(): r = open(changelogfile) text = r.read() r.close() control.dialog.textviewer( '[COLOR red]My Accounts[/COLOR] - v%s - ChangeLog' % myaccounts_version, text)