コード例 #1
0
 def _deactivate():
     """ Deactivate IPTV Simple """
     kodiutils.jsonrpc(method="Addons.SetAddonEnabled",
                       params={
                           "addonid": IPTV_SIMPLE_ID,
                           "enabled": False
                       })
コード例 #2
0
 def update(path=None):
     """ Update the library integration. """
     _LOGGER.debug('Scanning %s', path)
     if path:
         # We can use this to instantly add something to the library when we've added it to 'My List'.
         kodiutils.jsonrpc(method='VideoLibrary.Scan', params=dict(
             directory=path,
             showdialogs=False,
         ))
     else:
         kodiutils.jsonrpc(method='VideoLibrary.Scan')
コード例 #3
0
 def type(self):
     text = self.args.get('title', '')
     try:
         window = xbmcgui.Window(10103)
     except Exception:
         return None
     window.setFocusId(300)
     p = {"text": text, "done": False}
     debug('p: {}'.format(p))
     debug('json p: {}'.format(dumps(p)))
     jsonrpc(method="Input.SendText", params=p)
     xbmcplugin.endOfDirectory(args.handle)
コード例 #4
0
    def __check_subtitles(self):
        """ Check subtitles """

        # Check if subtitles are enabled before making any changes
        response = kodiutils.jsonrpc(method='Player.GetProperties', params=dict(playerid=1, properties=['currentsubtitle', 'subtitleenabled', 'subtitles']))
        subtitle_enabled = response.get('result').get('subtitleenabled')

        # Make sure an internal InputStream Adaptive subtitle is selected, if available
        available_subtitles = self.getAvailableSubtitleStreams()
        if available_subtitles:
            for i, subtitle in enumerate(available_subtitles):
                if '(External)' not in subtitle and '(External)' in self.getSubtitles():
                    self.setSubtitleStream(i)
                    break
        elif self.__av_started:
            _LOGGER.debug('Player: No internal subtitles found')

            # Add external subtitles
            if self.__subtitle_paths:
                for subtitle in self.__subtitle_paths:
                    _LOGGER.debug('Player: Adding external subtitles %s', subtitle)
                    self.setSubtitles(subtitle)

        # Enable subtitles if needed
        show_subtitles = kodiutils.get_setting_bool('showsubtitles')
        if show_subtitles and not subtitle_enabled:
            _LOGGER.debug('Player: Enabling subtitles')
            self.showSubtitles(True)
        elif not subtitle_enabled:
            _LOGGER.debug('Player: Disabling subtitles')
            self.showSubtitles(False)
コード例 #5
0
ファイル: addon.py プロジェクト: im85288/service.iptv.manager
    def detect_iptv_addons():
        """Find add-ons that provide IPTV channel data"""
        result = kodiutils.jsonrpc(method="Addons.GetAddons",
                                   params={
                                       'installed': True,
                                       'enabled': True,
                                       'type': 'xbmc.python.pluginsource'
                                   })

        addons = []
        for row in result['result']['addons']:
            addon = kodiutils.get_addon(row['addonid'])

            # Check if add-on supports IPTV Manager
            if addon.getSetting('iptv.enabled') != 'true':
                continue

            addons.append(
                Addon(
                    addon_id=row['addonid'],
                    addon_obj=addon,
                    channels_uri=addon.getSetting('iptv.channels_uri'),
                    epg_uri=addon.getSetting('iptv.epg_uri'),
                ))

        return addons
コード例 #6
0
    def get_stream_details(self, player_id):
        details = kodiutils.jsonrpc(
            "VideoGetProperties", {
                'method': 'Player.GetProperties',
                'params': {
                    'playerid': player_id,
                    'properties': ['currentaudiostream', 'subtitleenabled']
                }
            })

        return (details['currentaudiostream']['language'],
                details['subtitleenabled'])
コード例 #7
0
def set_kodi_cache_size():
    free_mem = xbmc.getInfoLabel('System.FreeMemory')
    free_mem = int(free_mem) / 1e6 if 'MB' not in free_mem else int(free_mem.replace('MB', ''))
    msg = Strings.txt(Strings.SETUP_VIDEO_CACHE_MSG1)
    user_input = dinput(msg.format(free_mem), '80', type=INPUT_NUMERIC)
    debug('user input: {}'.format(user_input))
    if user_input == '':
        return
    coefficient = int('{}'.format(user_input).replace('%', ''))
    coefficient = 80 if coefficient is None or 1 < coefficient > 80 else coefficient
    filename = translate_path('special://userdata/advancedsettings.xml')

    debug('cache size: {} * {}% / 3 = {}, '.format(free_mem, coefficient, int(free_mem / 3 * (coefficient/100))))
    if xbmcvfs.exists(filename):
        res = dyesno('WARNING', Strings.txt(Strings.SETUP_VIDEO_CACHE_MSG2))
        if not res:
            return False

    cache_size = int(min(500, int(free_mem / 3 * (coefficient/100))) * 1e6)
    debug('Nova cache {}'.format(cache_size))
    advanced_settings = '<advancedsettings>' \
                        '<cache><memorysize>{}</memorysize>' \
                        '<buffermode>1</buffermode>' \
                        '<readfactor>20</readfactor></cache>' \
                        '</advancedsettings>'.format(cache_size)
    debug('Nove advanced settings: {}'.format(advanced_settings))
    f = xbmcvfs.File(filename, 'w')
    f.write(advanced_settings)
    f.close()
    platform = get_system_platform()
    if platform in ['linux', 'windows']:
        res = dyesno('INFO', Strings.txt(Strings.SETUP_VIDEO_CACHE_MSG3))
        if res:
            jsonrpc(method="RestartApp")
    else:
        dok('INFO', Strings.txt(Strings.SETUP_VIDEO_CACHE_MSG4))
    pass
コード例 #8
0
    def get_iptv_addons():
        """ Find add-ons that provide IPTV channel data """
        result = kodiutils.jsonrpc(method="Addons.GetAddons",
                                   params={
                                       'installed': True,
                                       'enabled': True,
                                       'type': 'xbmc.python.pluginsource'
                                   })

        addons = []
        for row in result['result']['addons']:
            addon = kodiutils.get_addon(row['addonid'])
            addon_path = kodiutils.addon_path(addon)
            addon_iptv_config = os.path.join(addon_path, IPTV_FILENAME)

            # Check if this addon has an iptv.json
            if not os.path.exists(addon_iptv_config):
                continue

            # Read iptv.json
            with open(addon_iptv_config) as fdesc:
                data = json.load(fdesc)

            # Check version
            if data.get('version', 1) > IPTV_VERSION:
                _LOGGER.warning(
                    'Skipping %s since it uses an unsupported version of iptv.json: %d',
                    row['addonid'], data.get('version'))
                continue

            if not data.get('channels'):
                _LOGGER.warning('Skipping %s since it has no channels defined',
                                row['addonid'])
                continue

            addons.append(
                Addon(
                    addon_id=row['addonid'],
                    channels_uri=data.get('channels'),
                    epg_uri=data.get('epg'),
                ))

        return addons
コード例 #9
0
 def clean(path=None):
     """ Cleanup the library integration. """
     _LOGGER.debug('Cleaning %s', path)
     if path:
         # We can use this to instantly remove something from the library when we've removed it from 'My List'.
         # This only works from Kodi 19 however. See https://github.com/xbmc/xbmc/pull/18562
         if kodiutils.kodi_version_major() > 18:
             kodiutils.jsonrpc(method='VideoLibrary.Clean',
                               params=dict(
                                   directory=path,
                                   showdialogs=False,
                               ))
         else:
             kodiutils.jsonrpc(method='VideoLibrary.Clean',
                               params=dict(showdialogs=False, ))
     else:
         kodiutils.jsonrpc(method='VideoLibrary.Clean')
コード例 #10
0
    def get_active_player_id(self):
        active_player = kodiutils.jsonrpc(
            1, {'method': 'Player.GetActivePlayers'})

        return active_player[0]['playerid']