示例#1
0
    def run(self):
        xbmc.log(
            '[ script.module.fenomscrapers ]  Addon checking available updates',
            LOGNOTICE)
        try:
            import re
            import requests
            repo_xml = requests.get(
                'https://raw.githubusercontent.com/mr-kodi/repository.fenomscrapers/master/zips/addons.xml'
            )
            if not repo_xml.status_code == 200:
                return xbmc.log(
                    '[ script.module.fenomscrapers ]  Could not connect to remote repo XML: status code = %s'
                    % repo_xml.status_code, LOGNOTICE)
            repo_version = re.search(
                r'<addon id=\"script.module.fenomscrapers\".*version=\"(\d*.\d*.\d*)\"',
                repo_xml.text, re.I).group(1)
            local_version = control.addonVersion(
            )[:
              5]  # 5 char max so pre-releases do try to compare more chars than github version

            def check_version_numbers(
                current, new
            ):  # Compares version numbers and return True if github version is newer
                current = current.split('.')
                new = new.split('.')
                step = 0
                for i in current:
                    if int(new[step]) > int(i): return True
                    if int(i) > int(new[step]): return False
                    if int(i) == int(new[step]):
                        step += 1
                        continue
                return False

            if check_version_numbers(local_version, repo_version):
                while control.condVisibility('Library.IsScanningVideo'):
                    control.sleep(10000)
                xbmc.log(
                    '[ script.module.fenomscrapers ]  A newer version is available. Installed Version: v%s, Repo Version: v%s'
                    % (local_version, repo_version), LOGNOTICE)
                control.notification(message=control.lang(32037) %
                                     repo_version,
                                     time=5000)
            return xbmc.log(
                '[ script.module.fenomscrapers ]  Addon update check complete',
                LOGNOTICE)
        except:
            import traceback
            traceback.print_exc()
示例#2
0
def upload_LogFile():
    from fenomscrapers.modules.control import notification
    url = 'https://paste.kodi.tv/'
    log_file = joinPath(LOGPATH, 'fenomscrapers.log')
    if not existsPath(log_file):
        return notification(
            message='Log File not found, likely logging is not enabled.')
    try:
        import requests
        from fenomscrapers.modules.control import addonVersion, selectDialog
        f = open(log_file, 'r', encoding='utf-8', errors='ignore')
        text = f.read()
        f.close()
        UserAgent = 'FenomScrpaers %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('FenomScrapers 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(32059))
            if 'Copy url To Clipboard' in list[select][0]:
                from fenomscrapers.modules.source_utils import copy2clip
                copy2clip(list[select - 1][1])
        elif 'message' in response.json():
            notification(message='FenomScrapers Log upload failed: %s' %
                         str(response.json()['message']))
            log('FenomScrapers Log upload failed: %s' %
                str(response.json()['message']),
                level=LOGERROR)
        else:
            notification(message='FenomScrapers Log upload failed')
            log('FenomScrapers Log upload failed: %s' % response.text,
                level=LOGERROR)
    except:
        error('FenomScrapers log upload failed')
        notification(message='pastebin post failed: See log for more info')
示例#3
0
def view_LogFile(name):
    try:
        from fenomscrapers.windows.textviewer import TextViewerXML
        from fenomscrapers.modules.control import addonPath
        log_file = joinPath(LOGPATH, '%s.log' % name.lower())
        if not existsPath(log_file):
            from fenomscrapers.modules.control import notification
            return notification(
                message='Log File not found, likely logging is not enabled.')
        f = open(log_file, 'r', encoding='utf-8', errors='ignore')
        text = f.read()
        f.close()
        heading = '[B]%s -  LogFile[/B]' % name
        windows = TextViewerXML('textviewer.xml',
                                addonPath(),
                                heading=heading,
                                text=text)
        windows.run()
        del windows
    except:
        error()
示例#4
0
	control.syncMyAccounts()
	control.sleep(100)
	if params.get('opensettings') == 'true':
		control.openSettings(query, 'script.module.fenomscrapers')

elif action == 'syncMyAccount':
	control.syncMyAccounts()
	if params.get('opensettings') == 'true':
		control.openSettings(query, 'script.module.fenomscrapers')

elif action == 'cleanSettings':
	control.clean_settings()

elif action == 'undesirablesSelect':
	from fenomscrapers.modules import source_utils
	source_utils.undesirablesSelect()

elif action == 'tools_clearLogFile':
	from fenomscrapers.modules import log_utils
	cleared = log_utils.clear_logFile()
	if cleared == 'canceled': pass
	elif cleared: control.notification(message='FenomScrapers Log File Successfully Cleared')
	else: control.notification(message='Error clearing FenomScrapers Log File, see kodi.log for more info')

elif action == 'tools_viewLogFile':
	from fenomscrapers.modules import log_utils
	log_utils.view_LogFile(name)

elif action == 'tools_uploadLogFile':
	from fenomscrapers.modules import log_utils
	log_utils.upload_LogFile()