示例#1
0
def get_definitions():
    defs = ''
    log('Definition Locations:')
    default_defs = [setting('default_url')] if setting('default_url_t') == "true" else []
    # user_defs = 'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt'
    for numb in range(0, 6):
        user_def = xbmcaddon.Addon().getSetting('user_url' + str(numb))
        if user_def:
            default_defs.append(user_def)
    for def_list in default_defs:
        log('    ' + def_list)
        try:
            # definitons = open_url(def_list) if 'http' in def_list else str(open(def_list, 'rb'))
            definitons = kodi.read_file(def_list) if 'http' in def_list else str(open(def_list, 'rb'))
            for line in definitons.splitlines():
                if line and not line.startswith('#'):
                    for pattern in ('[^\/]*\/\/([^$]*)', '\s([^$]*)', '([\d+\.]+)\s'):
                        match = re.search(pattern, line)
                        if match:
                            match = match.group(1).replace('*', '')
                            if match not in defs and match != '0.0.0.0':
                                defs += str(match + '\n')  # default_defs.append(match)
            if 'http' not in def_list:
                definitons.close()
        except Exception as e:
            log(error=str(e))
    log(' ')
    return defs
示例#2
0
def text_view(t_path='', t_contents='', d_path=''):
    # path can be a url to an internet file
    if (not t_path) and (not t_contents):
        return
    if t_path and not t_contents:
        if t_path == 'kb_input':
            t_path = keyboard(default=d_path, heading='Please enter the Url/path to the file you wish to view')
            if not t_path:
                return
        if 'http' in t_path.lower():  # string.lower(t_path):
            try:
                t_contents = kodi.read_file(t_path)
            except Exception as e:
                print(str(e))
                t_contents = 'The web site seems to be having trouble or the file could not be read' \
                             '\nPlease try again later'
        else:
            if t_path == 'log':
                t_path = get_logpath()
            if not os.path.isfile(t_path):
                t_contents = 'Could not find path to file ' + t_path
                return t_path, t_contents
            # Open and read the file from path location
            try:
                with open(t_path, 'rb') as temp_file:
                    t_contents = temp_file.read()
            except IOError:
                t_contents = 'Could not read the file'
    if not t_contents:
        t_contents = 'The file was empty'
    # Set contents for text display function
    t_contents = t_contents.replace(' ERROR: ', ' [COLOR red]ERROR[/COLOR]: ') \
        .replace(' WARNING: ', ' [COLOR gold]WARNING[/COLOR]: ')
    return t_path, t_contents
def check_news2(message_type, override_service=False):
    # debob(["notifications-on-startup", settings.getSetting("notifications-on-startup"), "override_service ",
    #        override_service])
    if (settings.getSetting("notifications-on-startup") == 'false') or override_service:
        info_location = "http://indigo.tvaddons.co/notifications/news.txt"
        info_location2 = addon_path("test.txt")
        info_location3 = addon_path("url.txt")
        try:
            if os.path.isfile(info_location2):
                with open(info_location2, 'rb') as temp_file:
                    html = temp_file.read()
            elif os.path.isfile(info_location3):
                with open(info_location3, 'rb') as temp_file:
                    html = kodi.read_file(temp_file.read().strip()) if temp_file.read() else ''
            else:
                # html = open_url(info_location)
                html = kodi.read_file(info_location)
        except IOError:
            html = ''
        new_image = html.split('|||')[0].strip() if '|||' in html else ''
        new_message = html.split('|||')[1].strip() if '|||' in html else html
        old_note_image = settings.getSetting("noteImage")
        old_note_message = settings.getSetting("noteMessage")
        old_note_image = old_note_image.replace(artp('blank1'), '')
        new_note = ((len(new_image) > 0) or (len(new_message) > 0))
        old_note = (len(old_note_image) > 0 or len(old_note_message) > 0)
        if ((old_note and (not new_note or (old_note_image == new_image or old_note_message == new_message)))
                or (not old_note and not new_note)) and not override_service:
            return
        if new_note and (not old_note_image == new_image) or (not old_note_message == new_message):
            settings.setSetting("noteType", message_type)
            settings.setSetting("noteImage", new_image)
            settings.setSetting("noteMessage", new_message)
        win = PopupNote('note-skin.xml', Addon.getAddonInfo('path'), 'notification')
        win.doModal()
        del win
示例#4
0
def what_sports():
    # #######  AMERICAN  ###############
    kodi.addItem('[COLOR blue][B]US Sports[/COLOR][/B]', '', '', artwork + 'icon.png',
                 description='[COLOR gold]Sports from around the US[/COLOR]')
    link = kodi.read_file('https://www.tvguide.com/sports/live-today/')
    pattern = '(?s)program-link">([^<]*)<.+?info">([^\|]*)\| ([^<]*)<.+?description">([^<]*)'
    for m_name, m_time, m_channel, m_description in re.findall(pattern, link):
        kodi.addItem('[COLOR white][B]%s[/COLOR][/B] - [COLOR gold]%s[/COLOR][COLOR white][B] | %s[/COLOR][/B]'
                     % (m_time.lower(), name_cleaner(m_name), m_channel), '', '', artwork + 'icon.png',
                     description='[COLOR gold][B]%s - %s[/COLOR][/B][COLOR white] - %s | %s[/COLOR]'
                                 % (m_description, name_cleaner(m_name), m_time.lower(), m_channel))

    # #######  UK  ###############
    kodi.addItem('[COLOR blue][B]UK Sports[/COLOR][/B]', '', '', artwork + 'icon.png',
                 description='[COLOR gold]Sports from around the UK[/COLOR]')
    link = kodi.read_file('http://www.wheresthematch.com/').replace('\r', '').replace('\n', '').replace('\t', '')
    pattern = '(?s)fixture-details">(.+?)t-details">(.+?)-name">(.+?)l-details">(.+?).png'
    for m_game, m_time, m_league, m_channels in re.findall(pattern, link):
        g_time = re.search('<strong>([^<]*)', m_time)
        g_time = g_time.group(1).strip('0').replace(' ', '') if g_time else ''
        league = re.search('<span>([^<]*)', m_league)
        g_league = ' - ' + league.group(1) if league else ''
        g_name = ''
        for team1, team2 in re.findall('(?s).asp">[^>]*>([^<]+)<.+?asp.+?">([^<]*)', m_game):
            g_name = '- %s vs %s' % (team1, team2) if m_game else ''
        if '<strong class=' in m_game:
            game = re.search('<strong class="">([^<]*)', m_game)
            g_name = ' - ' + game.group(1) if game and league != game.group(1) else ''
        channels = ''
        for channel in re.findall('-name">([^<]*)', m_channels):
            channels += ' ' + channel if not channels else ', ' + channel
        kodi.addItem('[COLOR white][B]%s[/COLOR][/B][COLOR gold]%s %s[/COLOR][COLOR white][B] | %s[/COLOR][/B]'
                     % (g_time, g_league, g_name, channels), '', '', artwork + 'icon.png',
                     description='[COLOR gold][B]%s - %s[/COLOR][/B][COLOR white] - %s | %s[/COLOR]'
                                 % (g_time, g_name, g_league, channels))
    viewsetter.set_view("tvshows")
示例#5
0
def rtmp_lib():
    liblist = "http://indigo.tvaddons.co/librtmp/rtmplist.txt"
    try:
        # link = OPEN_URL(liblist).replace('\n', '').replace('\r', '')
        link = kodi.read_file(liblist).replace('\n', '').replace('\r', '')
    except Exception as e:
        kodi.log(str(e))
        kodi.addItem('[COLOR gold][B]This service is currently unavailable.[/COLOR][/B]', '', 100, '', '', '')
        return
    match = re.compile('name="(.+?)".+?rl="(.+?)".+?ersion="(.+?)"').findall(link)
    kodi.addItem('[COLOR gold][B]Files Will Be Donwloaded to the Kodi Home directory,'
                 'You Will Need To Manually Install From There.[/COLOR][/B]', '', 100, '', '', '')
    # kodi.addItem('[COLOR gold]---------------------------------------------------------[/COLOR]', '', 100, '',' ', '')
    for m_name, m_url, m_description in match:
        kodi.addDir(m_name, m_url, "lib_installer", artwork + 'icon.png')
    viewsetter.set_view("sets")
def rtmp_lib():
    liblist = "http://indigo.tvaddons.co/librtmp/rtmplist.txt"
    try:
        # link = OPEN_URL(liblist).replace('\n', '').replace('\r', '')
        link = kodi.read_file(liblist).replace('\n', '').replace('\r', '')
    except Exception as e:
        kodi.log(str(e))
        kodi.addItem('[COLOR gold][B]This service is currently unavailable.[/COLOR][/B]', '', 100, '', '', '')
        return
    match = re.compile('name="(.+?)".+?rl="(.+?)".+?ersion="(.+?)"').findall(link)
    kodi.addItem('[COLOR gold][B]Files Will Be Donwloaded to the Kodi Home directory,'
                 'You Will Need To Manually Install From There.[/COLOR][/B]', '', 100, '', '', '')
    # kodi.addItem('[COLOR gold]---------------------------------------------------------[/COLOR]', '', 100, '',' ', '')
    for m_name, m_url, m_description in match:
        kodi.addDir(m_name, m_url, "lib_installer", artwork + 'icon.png')
    viewsetter.set_view("sets")
示例#7
0
def fullspeedtest():
    # speed_test = base64.b64decode("aHR0cDovL2luZGlnby50dmFkZG9ucy5hZy9zcGVlZHRlc3Qvc3BlZWR0ZXN0ZmlsZS50eHQ=")
    speed_test = 'http://www.engineerhammad.com/2015/04/Download-Test-Files.html'
    try:
        # link = OPEN_URL(speed_test)
        link = kodi.read_file(speed_test)
        match = re.findall('href="([^"]*)".+src="([^"]*)"[^\d]*(\d+\s[^b]*b)', link)
        for m_url, m_iconimage, m_name in reversed(match):
            m_iconimage = artwork + str(m_name).replace(' ', '').lower() + '.png'
            if 'mb'in m_iconimage and not os.path.isfile(m_iconimage):
                m_iconimage = m_iconimage.replace('mb', '')
            if m_name not in '10 Gb':
                kodi.add_item('[COLOR ghostwhite]' + m_name + '[/COLOR]', m_url, "runtest", m_iconimage,
                              description='Test with a ' + m_name + ' file')
    except Exception as e:
        kodi.log(str(e))
        import traceback
        traceback.print_exc(file=sys.stdout)
        kodi.add_item('[COLOR ghostwhite]Speed Test is unavailable[/COLOR]', '', "", artwork + 'speed_test.png',
                      description='')
    viewsetter.set_view("sets")
示例#8
0
def fullspeedtest():
    # speed_test = base64.b64decode("aHR0cDovL2luZGlnby50dmFkZG9ucy5hZy9zcGVlZHRlc3Qvc3BlZWR0ZXN0ZmlsZS50eHQ=")
    speed_test = 'http://www.engineerhammad.com/2015/04/Download-Test-Files.html'
    try:
        # link = OPEN_URL(speed_test)
        link = kodi.read_file(speed_test)
        match = re.findall('href="([^"]*)".+src="([^"]*)".+\n.+?(\d+\s[^b]*b)', link)
        for m_url, m_iconimage, m_name in reversed(match):
            m_iconimage = artwork + str(m_name).replace(' ', '').lower() + '.png'
            if 'mb'in m_iconimage and not os.path.isfile(m_iconimage):
                m_iconimage = m_iconimage.replace('mb', '')

            kodi.addItem('[COLOR ghostwhite]' + m_name + '[/COLOR]', m_url, "runtest", m_iconimage,
                         description='Test with a ' + m_name + ' file')
    except Exception as e:
        kodi.log(str(e))
        import traceback
        traceback.print_exc(file=sys.stdout)
        kodi.addItem('[COLOR ghostwhite]Speed Test is unavailable[/COLOR]', '', "", artwork + 'speed_test.png',
                     description='')
    viewsetter.set_view("sets")
示例#9
0
def blocker(binit_time):
    blink = settings.getSetting("blockLink")
    time_match = re.findall('exp="([^"]*)"', blink) if blink else ''
    time_match = time_match if time_match else [48]
    if not blink or datetime.datetime.now() >= binit_time + datetime.timedelta(
            hours=int(time_match[0])):
        xbmc.log('Checking for Malicious scripts')
        blink = kodi.read_file(BlocksUrl).replace(' ', '').replace(
            '\r', '').replace('\n', '')
        settings.setSetting("blockLink", blink) if blink else ''
        binit_time = datetime.datetime.now() if blink else binit_time
    xbmc.log('Could not find blocked script list') if not blink else ''
    for blocked in re.findall('block="(.+?)"', blink):
        if blocked and (os.path.isdir(addonspath + blocked)
                        or xbmc.getCondVisibility(
                            "System.HasAddon(%s)" % blocked)):
            set_disabled(blocked)
            shutil.rmtree(addonspath +
                          blocked) if os.path.isdir(addonspath +
                                                    blocked) else ''
            shutil.rmtree(datapath + blocked) if os.path.isdir(datapath +
                                                               blocked) else ''
    return binit_time
def text_view(t_path='', t_contents='', d_path=''):
    # path can be a url to an internet file
    if (not t_path) and (not t_contents):
        return
    if t_path and not t_contents:
        if t_path == 'kb_input':
            t_path = keyboard(
                default=d_path,
                heading='Please enter the Url/path to the file you wish to view'
            )
            if not t_path:
                return
        if 'http' in t_path.lower():  # string.lower(t_path):
            try:
                t_contents = kodi.read_file(t_path)
            except Exception as e:
                print(str(e))
                t_contents = 'The web site seems to be having trouble or the file could not be read' \
                             '\nPlease try again later'
        else:
            if t_path == 'log':
                t_path = get_logpath()
            if not os.path.isfile(t_path):
                t_contents = 'Could not find path to file ' + t_path
                return t_path, t_contents
            # Open and read the file from path location
            try:
                with open(t_path, 'rb') as temp_file:
                    t_contents = temp_file.read()
            except IOError:
                t_contents = 'Could not read the file'
    if not t_contents:
        t_contents = 'The file was empty'
    # Set contents for text display function
    t_contents = t_contents.replace(' ERROR: ', ' [COLOR red]ERROR[/COLOR]: ') \
        .replace(' WARNING: ', ' [COLOR gold]WARNING[/COLOR]: ')
    return t_path, t_contents
示例#11
0
def system_info():
    systime = xbmc.getInfoLabel('System.Time ')
    dns1 = xbmc.getInfoLabel('Network.DNS1Address')
    gateway = xbmc.getInfoLabel('Network.GatewayAddress')
    ipaddy = xbmc.getInfoLabel('Network.IPAddress')
    linkstate = xbmc.getInfoLabel('Network.LinkState').replace("Link:", "")
    freespace, totalspace = maintool.get_free_space_mb(os.path.join(xbmc.translatePath('special://home')))
    freespace = maintool.convert_size(freespace)
    totalspace = maintool.convert_size(totalspace)
    screenres = xbmc.getInfoLabel('system.screenresolution')
    freemem = maintool.convert_size(maintool.revert_size(xbmc.getInfoLabel('System.FreeMemory')))
    
    # FIND WHAT VERSION OF KODI IS RUNNING
    # xbmc_version = xbmc.getInfoLabel("System.BuildVersion")
    # versioni = xbmc_version[:4]
    # codename = kodi.get_codename()

    # Get External IP Address
    try:
        # ext_ip = ("blue", OPEN_URL('https://api.ipify.org'))
        ext_ip = ("blue", kodi.read_file('https://api.ipify.org'))
    except Exception as e:
        kodi.log(str(e))
        try:
            # link = OPEN_URL('http://whatismyip.network/')
            link = kodi.read_file('http://whatismyip.network/')
            ext_ip = ("blue", re.search('>My IP Address[^=]*[^>]*>([^<]*)', link).group(1))
        except:
            ext_ip = ("red", "IP Check Not Available")

    # Get Python Version
    pv = sys.version_info
    
    # System Information Menu
    # kodi.addItem('[COLOR ghostwhite]Version: [/COLOR][COLOR lime] %s %s[/COLOR]' % (codename, versioni),
    #              '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Version: [/COLOR][COLOR lime] %s %s[/COLOR]' %
                 (kodi.get_codename(), xbmc.getInfoLabel("System.BuildVersion").split('Git')[0]),'',
                 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]System Time: [/COLOR][COLOR lime] %s[/COLOR]' % systime,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Gateway: [/COLOR][COLOR blue] %s[/COLOR]' % gateway,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Local IP: [/COLOR][COLOR blue] %s[/COLOR]' % ipaddy,
                 '', 100, artwork+'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]External IP: [/COLOR][COLOR %s] %s[/COLOR]' % ext_ip,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]DNS 1: [/COLOR][COLOR blue] %s[/COLOR]' % dns1,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Network: [/COLOR][COLOR gold] %s[/COLOR]' % linkstate,
                 '', 100, artwork + 'icon.png', "", description=" ")
    if str(totalspace) != '0 B':
        kodi.addItem('[COLOR ghostwhite]Total Disc Space: [/COLOR][COLOR gold] %s[/COLOR]' % totalspace,
                     '', 100, artwork + 'icon.png', "", description=" ")
    if str(freespace) != '0 B':
        kodi.addItem('[COLOR ghostwhite]Free Disc Space: [/COLOR][COLOR gold] %s[/COLOR]' % freespace,
                     '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Free Memory: [/COLOR][COLOR gold] %s[/COLOR]' % freemem,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Resolution: [/COLOR][COLOR gold] %s[/COLOR]' % screenres,
                 '', 100, artwork + 'icon.png', "", description=" ")
    kodi.addItem('[COLOR ghostwhite]Python Version: [/COLOR][COLOR lime] %d.%d.%d[/COLOR]' % (pv[0], pv[1], pv[2]),
                 '', 100, artwork + 'icon.png', "", description=" ")
    viewsetter.set_view("files")
def HELPCATEGORIES(filetype='main'):
    link = kodi.read_file(wizlink).replace('\n', '').replace('\r', '').replace('\a', '').strip()
    HELPWIZARD('configwiz', link, '', filetype, )
示例#13
0

if __name__ == '__main__':
    monitor = xbmc.Monitor()
    while not monitor.abortRequested():
        # Sleep/wait for abort for 10 seconds 12 hours is 43200   1 hours is 3600
        if monitor.waitForAbort(1800):
            # Abort was requested while waiting. We should exit
            kodi.log('CLOSING ' + AddonTitle.upper() + ' SERVICES')
            break
        if kodi.get_setting('scriptblock') == 'true':
            kodi.log('Checking for Malicious scripts')
            BlocksUrl = base64.b64decode('aHR0cDovL2luZGlnby50dmFkZG9ucy5jby9ibG9ja2VyL2Jsb2NrZXIudHh0')
            BlocksUrl = 'http://indigo.tvaddons.co/blocker/blocker.txt'
            try:
                link = kodi.read_file(BlocksUrl)
                # req = Request(BlocksUrl)
                # req.add_header('User-Agent', 'Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; AFTB Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30')
                # response = = urlopen(req)
                # link = response.read()
                # response.close()
            except:
                kodi.log('Could not perform blocked script. invalid URL')
                break
            #     continue
            link = link.replace('\n', '').replace('\r', '').replace('\a', '')

            match = re.compile('block="(.+?)"').findall(link)
            for blocked in match:
                    addonPath = xbmcaddon.Addon(id=addon_id).getAddonInfo('path')
                    addonPath = xbmc.translatePath(addonPath)
示例#14
0
def get_max_version(repo_name, repourl, tree_url):
    version = re.search(repo_name + '(-.+?).zip', repourl).group(1)
    version_max = max(re.findall(repo_name + '(-.+?).zip', kodi.read_file(tree_url + repo_name)))
    return repourl.replace(version, version_max)
示例#15
0
def main_menu():
    maintool.source_change()
    maintool.feed_change()
    # ########## TRY POP ########
    if len(kodi.get_setting('notify')) > 0:
        kodi.set_setting('notify', str(int(kodi.get_setting('notify')) + 1))
    else:
        kodi.set_setting('notify', "1")
    if int(kodi.get_setting('notify')) == 1:
        xbmcgui.Dialog().notification('Need Support?', 'www.tvaddons.co', artwork + 'icon.png', 3000, False)
    elif int(kodi.get_setting('notify')) == 5:
        kodi.set_setting('notify', "0")
    # ######## END POP ###########

    if kodi.get_setting('hasran') == 'false':
        kodi.set_setting('hasran', 'true')
        
    dp = xbmcgui.DialogProgress()
    try:
        if (not os.path.exists(ART)) or (not os.path.exists(ART2)) or (not os.path.exists(ART3)):
            dp.create(AddonTitle, 'Getting ' + AddonTitle + ' Ready......', 'Downloading ' + AddonTitle + ' Icons.....')
            dp.update(0)
            icons_zip = os.path.join(packagepath, AddonTitle + '_icons.zip')
            downloader.download(kodi.read_file('http://indigo.tvaddons.co/graphics/arts.txt'), icons_zip, dp)
            # downloader.download(OPEN_URL('http://indigo.tvaddons.co/graphics/arts.txt'), icons_zip, dp)
            dp.update(0, 'Getting %s Ready........' % AddonTitle, 'Extracting %s Icons......' % AddonTitle)
            extract.all(icons_zip, addon_path, dp)
            dp.close()
    except Exception as e:
        kodi.log(str(e))
    # Check for old version of hubrepo and remove it
    try:
        if os.path.exists(hubpath):
            with open(hubpath, 'r') as content:
                if 'AG' in content:
                    shutil.rmtree(hubpath)
    except Exception as e:
        kodi.log(str(e))
    # # Check for HUBRepo and install it
    try:
        if not os.path.exists(hubpath):
            installer.HUBINSTALL('repository.xbmchub', 'http://github.com/tvaddonsco/tva-release-repo/raw/master/'
                                                       'repository.xbmchub/', 'repository.xbmchub')
            # xbmc.executebuiltin("XBMC.InstallAddon(%s)" % 'repository.xbmchub')
            addon_able.set_enabled("repository.xbmchub")
            xbmc.executebuiltin("XBMC.UpdateAddonRepos()")
    except Exception as e:
        kodi.log(str(e))
        import traceback
        traceback.print_exc(file=sys.stdout)
        raise
    # Check for Log Uploader and install it
    try:
        if not os.path.exists(uploaderpath):
            installer.HUBINSTALL('script.tvaddons.debug.log',
                                 'http://github.com/tvaddonsco/tva-release-repo/raw/master'
                                 '/script.tvaddons.debug.log/', 'script.tvaddons.debug.log')
            addon_able.set_enabled('script.tvaddons.debug.log')
            # xbmc.executebuiltin("InstallAddon(%s)" % 'script.tvaddons.debug.log')
            xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
    except Exception as e:
        kodi.log(str(e))
        raise
   
    # Check for old maintenance tools and remove them
    old_maintenance = (oldinstaller, oldnotify, oldmain, oldwiz, oldfresh)
    for old_file in old_maintenance:
        if os.path.exists(old_file):
            shutil.rmtree(old_file)

    # Notification Status
    if kodi.get_setting("notifications-on-startup") == "false":
        note_status = '(Opt Out)'
        note_art = 'notification_optout.png'
        note_description = 'Unsubscribe'
    else:
        note_status = '(Opt In)'
        note_art = 'notification_in.png'
        note_description = 'Subscribe'

    if kodi.get_setting('wizardran') == 'false':
        kodi.addItem("Config Wizard", '', 'call_wizard', artwork+'config_wizard.png',
                     description="Automatically configure Kodi with the best addons and goodies in seconds!")
    kodi.addDir("Addon Installer", '', 'call_installer', artwork + 'addon_installer.png',
                description="It’s like an App Store for Kodi addons!")
    kodi.addDir("Maintenance Tools", '', 'call_maintool', artwork + 'maintool.png',
                description="Keep your Kodi setup running at optimum performance!")
    # kodi.addDir("Kodi Librtmp Files", '', 'get_libs', artwork +'librtmp_files.png')
    kodi.addItem("Rejuvenate Kodi", '', 'call_rejuv', artwork + 'rejuvinate.png',
                 description="Wipe and reconfigure Kodi with the latest Config Wizard setup!")
    kodi.addDir("Factory Restore", '', 'call_restore', artwork + 'factory_restore.png',
                description="Start off fresh, wipe your Kodi setup clean!")
    if os.path.exists(uploaderpath):
        kodi.addItem("Log Uploader", '', 'log_upload', artwork + 'log_uploader.png',
                     description="Easily upload your error logs for troubleshooting!")
    kodi.addDir("Network Speed Test", '', 'runspeedtest', artwork + 'speed_test.png',
                description="How fast is your internet?")
    kodi.addDir("System Information", '', 'system_info', artwork + 'system_info.png',
                description="Useful information about your Kodi setup!")
    kodi.addDir("Sports Listings", '', 'call_sports', artwork + 'sports_list.png',
                description="Who’s playing what today?")
    kodi.addDir('Backup / Restore', '', 'backup_restore', artwork + 'backup_restore.png',
                description="Backup or restore your Kodi configuration in minutes!")
    kodi.addItem("Log Viewer", '', 'log_view', artwork + 'log_viewer.png',
                 description="Easily view your error log without leaving Kodi!")
    kodi.addItem("No-Coin Scan", '', 'nocoin', artwork + 'no_coin.png',
                 description="Scan your Kodi directory for coin mining.")
    kodi.addItem("Notifications " + note_status, '', 'toggle_notify', artwork + note_art,
                 description="%s to important TV ADDONS notifications on startup!" % note_description)
    kodi.addItem("Show Notification", '', 'show_note', artwork + 'notification.png',
                 description="Show TVA Notification. To get Important News, Tips, and Giveaways from TV ADDONS")
    viewsetter.set_view("sets")
示例#16
0
def main_menu():
    maintool.source_change()
    maintool.feed_change()
    # ########## TRY POP ########
    if len(kodi.get_setting('notify')) > 0:
        kodi.set_setting('notify', str(int(kodi.get_setting('notify')) + 1))
    else:
        kodi.set_setting('notify', "1")
    if int(kodi.get_setting('notify')) == 1:
        xbmcgui.Dialog().notification('Need Support?', 'www.tvaddons.co', artwork + 'icon.png', 3000, False)
    elif int(kodi.get_setting('notify')) == 5:
        kodi.set_setting('notify', "0")
    # ######## END POP ###########

    if kodi.get_setting('hasran') == 'false':
        kodi.set_setting('hasran', 'true')
        
    dp = xbmcgui.DialogProgress()
    try:
        if (not os.path.exists(ART)) or (not os.path.exists(ART2)) or (not os.path.exists(ART3)):
            dp.create(AddonTitle, 'Getting ' + AddonTitle + ' Ready......\nDownloading ' + AddonTitle + ' Icons.....')
            dp.update(0)
            icons_zip = os.path.join(packagepath, AddonTitle + '_icons.zip')
            downloader.download(kodi.read_file('http://indigo.tvaddons.co/graphics/arts.txt'), icons_zip, dp)
            dp.update(0, 'Getting %s Ready........' % AddonTitle, 'Extracting %s Icons......' % AddonTitle)
            extract.extract_all(icons_zip, addon_path, dp)
            dp.close()
    except Exception as e:
        kodi.log(str(e))
    # Check for old version of hubrepo and remove it
    try:
        if os.path.exists(hubpath):
            with open(hubpath + '/addon.xml', 'r') as content:
                if 'AG' in content:
                    shutil.rmtree(hubpath)
    except Exception as e:
        kodi.log(str(e))
    # # Check for HUBRepo and install it
    try:
        if not os.path.exists(hubpath):
            installer.hub_install('repository.xbmchub', 'http://github.com/tvaddonsco/tva-release-repo/raw/master/'
                                                        'repository.xbmchub/')
            # xbmc.executebuiltin("XBMC.InstallAddon(%s)" % 'repository.xbmchub')
            addon_able.set_enabled("repository.xbmchub")
    except Exception as e:
        kodi.log(str(e))
        traceback.print_exc(file=sys.stdout)
        raise
    # Check for Log Uploader and install it
    try:
        if not os.path.exists(uploaderpath):
            installer.hub_install('script.tvaddons.debug.log', 'http://github.com/tvaddonsco/tva-release-repo/raw/'
                                                               'master/script.tvaddons.debug.log/')
            addon_able.set_enabled('script.tvaddons.debug.log')
    except Exception as e:
        kodi.log(str(e))
        raise
   
    # Check for old maintenance tools and remove them
    old_maintenance = (oldinstaller, oldnotify, oldmain, oldwiz, oldfresh)
    for old_file in old_maintenance:
        if os.path.exists(old_file):
            shutil.rmtree(old_file)

    # Notification Status
    if kodi.get_setting("notifications-on-startup") == "false":
        note_status = '(Opt Out)'
        note_art = 'notification_optout.png'
        note_description = 'Unsubscribe'
    else:
        note_status = '(Opt In)'
        note_art = 'notification_in.png'
        note_description = 'Subscribe'

    if kodi.get_setting('wizardran') == 'false':
        kodi.add_item("Config Wizard", '', 'call_wizard', artwork+'config_wizard.png',
                      description="Automatically configure Kodi with the best addons and goodies in seconds!")
    kodi.add_dir("Addon Installer", '', 'call_installer', artwork + 'addon_installer.png',
                 description="It’s like an App Store for Kodi addons!")
    kodi.add_dir("Maintenance Tools", '', 'call_maintool', artwork + 'maintool.png',
                 description="Keep your Kodi setup running at optimum performance!")
    # kodi.add_dir("Kodi Librtmp Files", '', 'get_libs', artwork +'librtmp_files.png')
    kodi.add_item("Rejuvenate Kodi", '', 'call_rejuv', artwork + 'rejuvinate.png',
                  description="Wipe and reconfigure Kodi with the latest Config Wizard setup!")
    kodi.add_dir("Factory Restore", '', 'call_restore', artwork + 'factory_restore.png',
                 description="Start off fresh, wipe your Kodi setup clean!")
    if os.path.exists(uploaderpath):
        kodi.add_item("Log Uploader", '', 'log_upload', artwork + 'log_uploader.png',
                      description="Easily upload your error logs for troubleshooting!")
    kodi.add_dir("Network Speed Test", '', 'runspeedtest', artwork + 'speed_test.png',
                 description="How fast is your internet?")
    kodi.add_dir("System Information", '', 'system_info', artwork + 'system_info.png',
                 description="Useful information about your Kodi setup!")
    kodi.add_dir("Sports Listings", '', 'call_sports', artwork + 'sports_list.png',
                 description="Who’s playing what today?")
    kodi.add_dir('Backup / Restore', '', 'backup_restore', artwork + 'backup_restore.png',
                 description="Backup or restore your Kodi configuration in minutes!")
    kodi.add_item("Log Viewer", '', 'log_view', artwork + 'log_viewer.png',
                  description="Easily view your error log without leaving Kodi!")
    kodi.add_item("No-Coin Scan", '', 'nocoin', artwork + 'no_coin.png',
                  description="Scan your Kodi directory for coin mining.")
    kodi.add_item("Notifications " + note_status, '', 'toggle_notify', artwork + note_art,
                  description="%s to important TV ADDONS notifications on startup!" % note_description)
    kodi.add_item("Show Notification", '', 'show_note', artwork + 'notification.png',
                  description="Show TVA Notification. To get Important News, Tips, and Giveaways from TV ADDONS")
    viewsetter.set_view("sets")
示例#17
0
def JUVWIZARD(filetype='main'):
    if xbmcgui.Dialog().yesno(
            "Please Confirm",
            "                Please confirm that you wish to automatically",
            "            configure Kodi with all the best addons and tweaks!",
            "              ", "Cancel", "Install"):
        filetype = filetype.lower()
        if filetype == 'main':
            addonfolder = kodi.translate_path('special://home')
        elif filetype == 'addon':
            addonfolder = kodi.translate_path(
                os.path.join('special://home', 'addons'))
        else:
            print({'filetype': filetype})
            dialog.ok("Error!", 'filetype: "%s"' % str(filetype))
            return
        link = kodi.read_file(wizlink).replace('\n',
                                               '').replace('\r', '').replace(
                                                   '\a', '').strip()
        # kodi.log(link)
        if '[error]' in link:
            print(link)
            dialog.ok("Error!", link)
            return
        path = kodi.translate_path(
            os.path.join('special://home', 'addons', 'packages'))
        lib = os.path.join(path, 'rejuv.zip')
        try:
            os.remove(lib)
        except:
            pass
        # ## ## ... ##
        dp = xbmcgui.DialogProgress()
        dp.create(AddonTitle, " ", 'Downloading and Configuring ',
                  'Please Wait')
        downloader.download(link, lib, dp)
        xbmc.sleep(4000)
        extract.extract_all(lib, addonfolder, dp)
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        addon_able.setall_enable()
        try:
            addon_able.set_enabled("inputstream.adaptive")
        except:
            pass
        xbmc.sleep(4000)
        try:
            addon_able.set_enabled("inputstream.rtmp")
        except:
            pass
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        try:
            os.remove(lib)
        except:
            pass
        if filetype == 'main':
            link = kodi.read_file(cutslink)
            shorts = re.compile('shortcut="(.+?)"').findall(link)
            for shortname in shorts:
                xEB('Skin.SetString(%s)' % shortname)
                enableBG16 = "UseCustomBackground,true"
                enableBG17 = "use_custom_bg,true"
                xEB('Skin.SetBool(%s)' % enableBG16)
                xEB('Skin.SetBool(%s)' % enableBG17)

        kodi.set_setting("wizardran", 'true')
        dialog.ok(AddonTitle, "Installation Complete.", "",
                  "Click OK to exit Kodi and then restart to complete .")
        xbmc.executebuiltin('ShutDown')
示例#18
0
def system_info():
    systime = xbmc.getInfoLabel('System.Time ')
    dns1 = xbmc.getInfoLabel('Network.DNS1Address')
    gateway = xbmc.getInfoLabel('Network.GatewayAddress')
    ipaddy = xbmc.getInfoLabel('Network.IPAddress')
    linkstate = xbmc.getInfoLabel('Network.LinkState').replace("Link:", "")
    freespace, totalspace = maintool.get_free_space_mb(os.path.join(kodi.translate_path('special://home')))
    freespace = maintool.convert_size(freespace)
    totalspace = maintool.convert_size(totalspace)
    screenres = xbmc.getInfoLabel('system.screenresolution')
    freemem = maintool.convert_size(maintool.revert_size(xbmc.getInfoLabel('System.FreeMemory')))
    
    # FIND WHAT VERSION OF KODI IS RUNNING
    # xbmc_version = xbmc.getInfoLabel("System.BuildVersion")
    # versioni = xbmc_version[:4]
    # codename = kodi.get_codename()

    # Get External IP Address
    try:
        # ext_ip = ("blue", OPEN_URL('https://api.ipify.org'))
        ext_ip = ("blue", kodi.read_file('https://api.ipify.org'))
    except Exception as e:
        kodi.log(str(e))
        try:
            # link = OPEN_URL('http://whatismyip.network/')
            link = kodi.read_file('http://whatismyip.network/')
            ext_ip = ("blue", re.search('>My IP Address[^=]*[^>]*>([^<]*)', link).group(1))
        except TypeError:
            ext_ip = ("red", "IP Check Not Available")

    # Get Python Version
    pv = sys.version_info
    
    # System Information Menu
    # kodi.add_item('[COLOR ghostwhite]Version: [/COLOR][COLOR lime] %s %s[/COLOR]' % (codename, versioni),
    #              '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Version: [/COLOR][COLOR lime] %s %s[/COLOR]' %
                  (kodi.get_codename(), xbmc.getInfoLabel("System.BuildVersion").split('Git')[0]), '',
                  100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]System Time: [/COLOR][COLOR lime] %s[/COLOR]' % systime,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Gateway: [/COLOR][COLOR blue] %s[/COLOR]' % gateway,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Local IP: [/COLOR][COLOR blue] %s[/COLOR]' % ipaddy,
                  '', 100, artwork+'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]External IP: [/COLOR][COLOR %s] %s[/COLOR]' % ext_ip,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]DNS 1: [/COLOR][COLOR blue] %s[/COLOR]' % dns1,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Network: [/COLOR][COLOR gold] %s[/COLOR]' % linkstate,
                  '', 100, artwork + 'icon.png', "", description=" ")
    if str(totalspace) != '0 B':
        kodi.add_item('[COLOR ghostwhite]Total Disc Space: [/COLOR][COLOR gold] %s[/COLOR]' % totalspace,
                      '', 100, artwork + 'icon.png', "", description=" ")
    if str(freespace) != '0 B':
        kodi.add_item('[COLOR ghostwhite]Free Disc Space: [/COLOR][COLOR gold] %s[/COLOR]' % freespace,
                      '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Free Memory: [/COLOR][COLOR gold] %s[/COLOR]' % freemem,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Resolution: [/COLOR][COLOR gold] %s[/COLOR]' % screenres,
                  '', 100, artwork + 'icon.png', "", description=" ")
    kodi.add_item('[COLOR ghostwhite]Python Version: [/COLOR][COLOR lime] %d.%d.%d[/COLOR]' % (pv[0], pv[1], pv[2]),
                  '', 100, artwork + 'icon.png', "", description=" ")
    viewsetter.set_view("files")
示例#19
0
def HELPWIZARD(name, url, description, filetype):
    # path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
    filetype = filetype.lower()
    if xbmcgui.Dialog().yesno("Please Confirm",
                              "                Please confirm that you wish to automatically",
                              "            configure Kodi with all the best addons and tweaks!",
                              "              ", "Cancel", "Install"):
        path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
        dp = xbmcgui.DialogProgress()
        dp.create(AddonTitle, " ", 'Downloading and Configuring ', 'Please Wait')
        lib = os.path.join(path, name + '.zip')
        try:
            os.remove(lib)
        except:
            pass
        # ## ## ... ##
        # kodi.log(url)
        # if str(url).endswith('[error]'):
        #     print(url)
        #     dialog = xbmcgui.Dialog()
        #     dialog.ok("Error!", url)
        #     return
        if '[error]' in url:
            print(url)
            dialog = xbmcgui.Dialog()
            dialog.ok("Error!", url)
            return
        downloader.download(url, lib, dp)
        if not os.path.exists(lib):
            return
        if filetype == 'main':
            addonfolder = xbmc.translatePath('special://home')
        elif filetype == 'addon':
            addonfolder = xbmc.translatePath(os.path.join('special://home', 'addons'))
        else:
            print({'filetype': filetype})
            dialog = xbmcgui.Dialog()
            dialog.ok("Error!", 'filetype: "%s"' % str(filetype))
            return
        xbmc.sleep(4000)
        extract.all(lib, addonfolder, dp)
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        addon_able.setall_enable()
        try:
            addon_able.set_enabled("inputstream.adaptive")
        except:
            pass
        xbmc.sleep(4000)
        try:
            addon_able.set_enabled("inputstream.rtmp")
        except:
            pass
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        try:
            os.remove(lib)
        except:
            pass
        if filetype == 'main':
            link = kodi.read_file(cutslink)
            shorts = re.compile('shortcut="(.+?)"').findall(link)
            for shortname in shorts:
                xEB('Skin.SetString(%s)' % shortname)
                enableBG16 = "UseCustomBackground,true"
                enableBG17 = "use_custom_bg,true"
                xEB('Skin.SetBool(%s)' % enableBG16)
                xEB('Skin.SetBool(%s)' % enableBG17)

        xbmc.sleep(4000)
        xbmc.executebuiltin('XBMC_UpdateLocalAddons()')
        addon_able.setall_enable()
        # try:
        #     addon_able.set_enabled("inputstream.adaptive")
        # except:
        #     pass
        # xbmc.sleep(4000)
        # try:
        #     addon_able.set_enabled("inputstream.rtmp")
        # except:
        #     pass
        kodi.set_setting("wizardran", 'true')

        dialog = xbmcgui.Dialog()
        dialog.ok(AddonTitle, "Installation Complete!", "", "Click OK to exit Kodi and then restart to complete .")
        xbmc.executebuiltin('ShutDown')
示例#20
0
def HELPCATEGORIES(filetype='main'):
    link = kodi.read_file(wizlink).replace('\n', '').replace('\r', '').replace('\a', '').strip()
    HELPWIZARD('configwiz', link, '', filetype, )
示例#21
0
def HELPWIZARD(name, url, description, filetype):
    # path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
    filetype = filetype.lower()
    if xbmcgui.Dialog().yesno("Please Confirm",
                              "                Please confirm that you wish to automatically\n"+\
                              "            configure Kodi with all the best addons and tweaks!",
                              "Cancel", "Install"):
        path = kodi.translate_path(
            os.path.join('special://home', 'addons', 'packages'))
        dp = xbmcgui.DialogProgress()
        dp.create(AddonTitle, '\nDownloading and Configuring\nPlease Wait')
        lib = os.path.join(path, name + '.zip')
        try:
            os.remove(lib)
        except:
            pass
        # ## ## ... ##
        # kodi.log(url)
        # if str(url).endswith('[error]'):
        #     print(url)
        #     dialog = xbmcgui.Dialog()
        #     dialog.ok("Error!", url)
        #     return
        if '[error]' in url:
            print(url)
            dialog = xbmcgui.Dialog()
            dialog.ok("Error!", url)
            return
        downloader.download(url, lib, dp)
        if not os.path.exists(lib):
            return
        if filetype == 'main':
            addonfolder = kodi.translate_path('special://home')
        elif filetype == 'addon':
            addonfolder = kodi.translate_path(
                os.path.join('special://home', 'addons'))
        else:
            print({'filetype': filetype})
            dialog = xbmcgui.Dialog()
            dialog.ok("Error!", 'filetype: "%s"' % str(filetype))
            return
        xbmc.sleep(4000)
        extract.extract_all(lib, addonfolder, dp)
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        addon_able.setall_enable()
        try:
            addon_able.set_enabled("inputstream.adaptive")
        except:
            pass
        xbmc.sleep(4000)
        try:
            addon_able.set_enabled("inputstream.rtmp")
        except:
            pass
        xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
        try:
            os.remove(lib)
        except:
            pass
        if filetype == 'main':
            link = kodi.read_file(cutslink)
            shorts = re.compile('shortcut="(.+?)"').findall(link)
            for shortname in shorts:
                xEB('Skin.SetString(%s)' % shortname)
                enableBG16 = "UseCustomBackground,true"
                enableBG17 = "use_custom_bg,true"
                xEB('Skin.SetBool(%s)' % enableBG16)
                xEB('Skin.SetBool(%s)' % enableBG17)

        xbmc.sleep(4000)
        xbmc.executebuiltin('XBMC_UpdateLocalAddons()')
        addon_able.setall_enable()
        # try:
        #     addon_able.set_enabled("inputstream.adaptive")
        # except:
        #     pass
        # xbmc.sleep(4000)
        # try:
        #     addon_able.set_enabled("inputstream.rtmp")
        # except:
        #     pass
        kodi.set_setting("wizardran", 'true')

        dialog = xbmcgui.Dialog()
        dialog.ok(AddonTitle, "Installation Complete!", "",
                  "Click OK to exit Kodi and then restart to complete .")
        xbmc.executebuiltin('ShutDown')
示例#22
0

if __name__ == '__main__':
    monitor = xbmc.Monitor()
    while not monitor.abortRequested():
        # Sleep/wait for abort for 10 seconds 12 hours is 43200   1 hours is 3600
        if monitor.waitForAbort(1800):
            # Abort was requested while waiting. We should exit
            kodi.log('CLOSING ' + AddonTitle.upper() + ' SERVICES')
            break
        if kodi.get_setting('scriptblock') == 'true':
            kodi.log('Checking for Malicious scripts')
            BlocksUrl = base64.b64decode('aHR0cDovL2luZGlnby50dmFkZG9ucy5jby9ibG9ja2VyL2Jsb2NrZXIudHh0')
            BlocksUrl = 'http://indigo.tvaddons.co/blocker/blocker.txt'
            try:
                link = kodi.read_file(BlocksUrl)
                # req = Request(BlocksUrl)
                # req.add_header('User-Agent', 'Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; AFTB Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30')
                # response = = urlopen(req)
                # link = response.read()
                # response.close()
            except:
                kodi.log('Could not perform blocked script. invalid URL')
                break
            #     continue
            link = link.replace('\n', '').replace('\r', '').replace('\a', '')

            match = re.compile('block="(.+?)"').findall(link)
            for blocked in match:
                    addonPath = xbmcaddon.Addon(id=addon_id).getAddonInfo('path')
                    addonPath = xbmc.translatePath(addonPath)
示例#23
0
        xbmc.executebuiltin("Container.Refresh")
        xbmc.executebuiltin("UpdateAddonRepos") if addon.startswith(
            'repo') else ''
        xbmc.executebuiltin("UpdateLocalAddons")


def note(n_time, status=False):
    if not xbmc.Player().isPlaying():
        n_time = datetime.datetime.now()
        notification.check_news2("t", override_service=status)
    return n_time


block_time = datetime.datetime.now()
link = kodi.read_file(BlocksUrl).replace(' ',
                                         '').replace('\r',
                                                     '').replace('\n', '')
settings.setSetting("blockLink", link) if link else ''
block_time = blocker(block_time) if kodi.get_setting(
    'scriptblock') == 'true' else block_time
get_dir(addon_id,
        script_url) if not os.path.exists(addonspath + addon_id) else ''

old_maintenance = (oldinstaller, oldnotify, oldmain, oldwiz, oldfresh)
for old_file in old_maintenance:
    shutil.rmtree(old_file) if os.path.exists(old_file) else ''

if xbmc.getCondVisibility('System.HasAddon(script.service.twitter)'):
    search_string = xbmcaddon.Addon('script.service.twitter').getSetting(
        'search_string')
    search_string = search_string.replace('from:@', 'from:')