Пример #1
0
    def select_backend(self):
        self._logger.enter()
        choices, current_choice_index = self.get_backend_choices()
        if current_choice_index < 0:
            current_choice_index = 0
        script_path = Constants.ADDON_PATH
        self._logger.debug_verbose('SettingsDialog ADDON_PATH: {}'.format(
            Constants.ADDON_PATH))
        selection_dialog = SelectionDialog('selection-dialog.xml',
                                           script_path,
                                           'Default',
                                           title=Messages.get_msg(
                                               Messages.SELECT_SPEECH_ENGINE),
                                           choices=choices,
                                           initial_choice=current_choice_index)

        selection_dialog.show()
        selection_dialog.doModal()
        idx = selection_dialog.getCurrentListPosition()
        self._logger.debug_verbose('SelectionDialog value:',
                                   Messages.get_msg(Messages.CHOOSE_BACKEND),
                                   'idx:', str(idx))
        if idx < 0:
            return None

        engine = choices[idx]
        self._logger.debug_verbose('select_backend value: {} idx: {}'.format(
            engine.getLabel(), str(idx)))

        self.engine_engine_value.setLabel(engine.getLabel())
        new_backend = engine.getLabel2()
        if new_backend != self.previous_backend:
            self.set_backend(new_backend)
Пример #2
0
    def getMonitoredText(self,
                         isSpeaking=False
                         ):  #getLabel() Doesn't work currently with FadeLabels
        if self._visible: return None
        if not addoninfo.checkForNewVersions(): return None
        details = addoninfo.getUpdatedAddons()
        if not details: return None
        ret = ['{0}... '.format(Messages.get_msg(Messages.ADDONS_UPDATED))]
        for d in details:
            item = '{0} {1} {2}'.format(d['name'],
                                        Messages.get_msg(Messages.VERSION),
                                        d['version'])
            if not item in ret:
                ret.append(item)
        #print ret
        return ret


#        #print 'x'
#        heading = self.win.getControl(401).getLabel()
#        message = self.win.getControl(402).getLabel()
#        #print repr(message)
#        self.addNotice(heading,message)
#        if not isSpeaking: return self.takeNoticesForSpeech()
#        return None

#class NoticeDialogReader(NoticeHandler,WindowReaderBase): pass
Пример #3
0
def removeKeymap():
    targetPath = _keymapTarget()
    if os.path.exists(targetPath):
        xbmcvfs.delete(targetPath)
    xbmc.executebuiltin("action(reloadkeymaps)")
    xbmcgui.Dialog().ok(Messages.get_msg(Messages.REMOVED),
                        Messages.get_msg(Messages.KEYMAP_REMOVED))
Пример #4
0
 def getSettingControlText(self, controlID):
     text = xbmc.getInfoLabel('System.CurrentControl')
     if text.endswith(')'):  #Skip this most of the time
         text = text.replace('( )', '{0} {1}'.format(
             self.service.tts.pauseInsert,
             Messages.get_msg(Messages.NO)).replace(
                 '(*)', '{0} {1}'.format(
                     self.service.tts.pauseInsert,
                     Messages.get_msg(
                         Messages.YES))))  #For boolean settings
     return text
Пример #5
0
 def getControlText(self,controlID):
     if self.slideoutHasFocus():
         return self.getSlideoutText(controlID)
     if not controlID: return ('','')
     text = xbmc.getInfoLabel('ListItem.Label')
     if not text: return base.DefaultWindowReader.getControlText(self,controlID)
     status = ''
     if xbmc.getCondVisibility('ListItem.IsResumable'):
         status = ': {0}'.format(Messages.get_msg(Messages.RESUMABLE))
     else:
         if xbmc.getInfoLabel('ListItem.Overlay') == 'OverlayWatched.png':
             status = ': {0}'.format(Messages.get_msg(Messages.WATCHED))
     return ('{0}{1}'.format(text,status),text)
Пример #6
0
 def getControlPostfix(
     self,
     controlID,
 ):
     if not self.service.speakListCount:
         return ''
     numItems = xbmc.getInfoLabel('Container({0}).NumItems'.format(
         self.service.controlID))
     if numItems:
         return '... {0} {1}'.format(
             numItems, numItems != '1' and Messages.get_msg(Messages.ITEMS)
             or Messages.get_msg(Messages.ITEM))
     return ''
Пример #7
0
 def getControlText(self, controlID):
     ID = self.window().getFocusId()
     if ID == 9:
         text = xbmc.getLocalizedString(19133)
     else:
         text = xbmc.getInfoLabel('System.CurrentControl')
         text = text.replace(
             '( )', '{0} {1}'.format(
                 self.service.tts.pauseInsert, Messages.get_msg(
                     Messages.NO))).replace('(*)', '{0} {1}'.format(
                         self.service.tts.pauseInsert,
                         Messages.get_msg(
                             Messages.YES)))  # For boolean settings
     return (text, text)
    def setTitle(self):
        if self.title: return
        tail = utils.tailXBMCLog()
        for t in reversed(tail):
            l = t.lower()
            if 'thread epgupdater start' in l:
                self.title = Messages.get_msg(Messages.IMPORTING_PVR_EPG)
                return
            elif 'thread pvrguiinfo start' in l:
                self.title = Messages.get_msg(Messages.LOADING_PVR_EPG)
                return

        if self.progress:
            self.title = Messages.get_msg(Messages.BACKGROUND_PROGRESS_STARTED)
Пример #9
0
 def fallbackTTS(self, reason=None):
     if reason == 'RESET':
         return resetAddon()
     backend = backends.getBackendFallback()
     module_logger.info('Backend falling back to: {0}'.format(
         backend.provider))
     self.initTTS(backend)
     self.sayText(Messages.get_msg(
         Messages.SPEECH_ENGINE_FALLING_BACK_TO).format(
             backend.displayName),
                  interrupt=True)
     if reason:
         self.sayText('{0}: {1}'.format(Messages.get_msg(Messages.Reason),
                                        reason),
                      interrupt=False)
Пример #10
0
class PVRWindowReader(PVRWindowReaderBase):
    ID = 'pvr'
    timelineInfo = (Messages.get_msg(Messages.CHANNEL),
                        '$INFO[ListItem.ChannelNumber]',
                        '$INFO[ListItem.ChannelName]',
                        '$INFO[ListItem.StartTime]',
                        19160,
                        '$INFO[ListItem.EndTime]',
                        '$INFO[ListItem.Plot]'
    )

    channelInfo = (    '$INFO[ListItem.StartTime]',
                        19160,
                        '$INFO[ListItem.EndTime]',
                        '$INFO[ListItem.Plot]'
    )

    nowNextInfo = (Messages.get_msg(Messages.CHANNEL),
                        '$INFO[ListItem.ChannelNumber]',
                        '$INFO[ListItem.ChannelName]',
                        '$INFO[ListItem.StartTime]',
                        '$INFO[ListItem.Plot]'
    )

    def controlIsOnView(self,controlID):
        return controlID > 9 and controlID < 18

    def getControlText(self,controlID):
        if not controlID: return ('','')
        text = None
        if controlID == 11 or controlID == 12: #Channel (TV or Radio)
            text = '{0}... {1}... {2}'.format(xbmc.getInfoLabel('ListItem.ChannelNumber'),xbmc.getInfoLabel('ListItem.Label'),xbmc.getInfoLabel('ListItem.Title'))
        else:
            text = xbmc.getInfoLabel('System.CurrentControl')
        if not text: return ('','')
        compare = text + xbmc.getInfoLabel('ListItem.StartTime') + xbmc.getInfoLabel('ListItem.EndTime')
        return (text,compare)

    def getItemExtraTexts(self,controlID):
        text = None
        if self.controlIsOnView(controlID):
            if controlID == 10: #EPG: Timeline
                text = guitables.convertTexts(self.winID,self.timelineInfo)
            elif controlID == 11 or controlID == 12: #Channel (TV or Radio)
                text = guitables.convertTexts(self.winID,self.channelInfo)
            elif controlID == 16: #EPG: Now/Next
                text = guitables.convertTexts(self.winID,self.nowNextInfo)
        return text
Пример #11
0
    def select_player(self):
        (choices, current_choice_index) = self.get_player_choices()
        script_path = Constants.ADDON_PATH
        selection_dialog = SelectionDialog('selection-dialog.xml',
                                           script_path,
                                           'Default',
                                           title=Messages.get_msg(
                                               Messages.SELECT_VOICE_GENDER),
                                           choices=choices,
                                           initial_choice=current_choice_index)

        selection_dialog.show()
        selection_dialog.doModal()
        idx = selection_dialog.getCurrentListPosition()
        if idx < 0:
            return

        player_label = choices[idx].getLabel()
        player_id = choices[idx].getLabel2()
        self._logger.debug_verbose(
            'select_player value: {} setting: {} idx: {:d}'.format(
                player_label, player_id, idx))

        self.engine_player_value.setLabel(player_label)
        self.set_player(player_id)
Пример #12
0
    def select_gender(self):
        (choices, current_choice_index) = self.get_gender_choices()
        script_path = Constants.ADDON_PATH
        # xbmc.executebuiltin('Skin.ToggleDebug')

        selection_dialog = SelectionDialog('selection-dialog.xml',
                                           script_path,
                                           'Default',
                                           title=Messages.get_msg(
                                               Messages.SELECT_VOICE_GENDER),
                                           choices=choices,
                                           initial_choice=current_choice_index)

        selection_dialog.show()
        selection_dialog.doModal()
        idx = selection_dialog.getCurrentListPosition()
        if idx < 0:
            return

        gender_id = choices[idx]
        gender_label = Genders.get_label(gender_id)
        self._logger.debug_verbose(
            'select_gender value: {} setting: {} idx: {:d}'.format(
                gender_label, gender_id, idx))

        self.engine_gender_value.setLabel(gender_label)
        self.setSetting(Settings.GENDER, gender_id)
Пример #13
0
    def select_voice(self):
        choices, current_choice_index = self.get_voice_choices()
        script_path = Constants.ADDON_PATH
        selection_dialog = SelectionDialog('selection-dialog.xml',
                                           script_path,
                                           'Default',
                                           title=Messages.get_msg(
                                               Messages.SELECT_VOICE),
                                           choices=choices,
                                           initial_choice=current_choice_index)

        selection_dialog.show()
        selection_dialog.doModal()
        idx = selection_dialog.getCurrentListPosition()
        self._logger.debug_verbose('SelectionDialog voice idx: {}'.format(
            str(idx)))
        if idx < 0:
            return

        voice = choices[idx].getLabel()
        voice_id = choices[idx].getLabel2()
        self._logger.debug_verbose(
            'select_voice value: {} setting: {} idx: {:d}'.format(
                voice, voice_id, idx))

        self.engine_voice_value.setLabel(voice)
        self.setSetting(Settings.VOICE, voice_id)
Пример #14
0
    def checkWindow(self, newN):
        winID = xbmcgui.getCurrentWindowId()
        dialogID = xbmcgui.getCurrentWindowDialogId()
        if dialogID != 9999:
            winID = dialogID
        if winID == self.winID:
            return newN
        self.winID = winID
        self.updateWindowReader()
        if module_logger.isEnabledFor(LazyLogger.DEBUG):
            module_logger.debug('Window ID: {0} Handler: {1} File: {2}'.format(
                winID, self.windowReader.ID,
                xbmc.getInfoLabel('Window.Property(xmlfile)')))

        name = self.windowReader.getName()
        if name:
            self.sayText('{0}: {1}'.format(Messages.get_msg(Messages.WINDOW),
                                           name),
                         interrupt=not newN)
            self.insertPause()
        else:
            self.sayText(' ', interrupt=not newN)

        heading = self.windowReader.getHeading()
        if heading:
            self.sayText(heading)
            self.insertPause()

        texts = self.windowReader.getWindowTexts()
        if texts:
            self.insertPause()
            for t in texts:
                self.sayText(t)
                self.insertPause()
        return True
    def get_label(self) -> str:
        """
            Gets translated label for the genre

        :return:
        """
        return Messages.get_msg(self._translatable_label_id)
Пример #16
0
 def getControlText(self, controlID):
     if not controlID: return ('', '')
     sub = ''
     text = self.getSettingControlText(controlID)
     if text.startswith('-'):
         sub = '{0}: '.format(Messages.get_msg(Messages.SUB_SETTING))
     return ('{0}{1}'.format(sub, text), text)
Пример #17
0
 def getControlText(self, controlID):
     label = xbmc.getInfoLabel('System.CurrentControl')
     selected = xbmc.getCondVisibility(
         'Container({0}).ListItem.IsSelected'.format(controlID)
     ) and ': {0}'.format(Messages.get_msg(Messages.SELECTED)) or ''
     text = '{0}{1}'.format(label, selected)
     return (text, text)
Пример #18
0
    def checkNewVersion(self):
        try:
            # Fails on Helix beta 1 on OpenElec #1103
            from distutils.version import LooseVersion
        except ImportError:

            def LooseVersion(v):
                comp = [int(x) for x in re.split(r'a|b', v)[0].split(".")]
                fourth = 2
                fifth = 0
                if 'b' in v:
                    fourth = 1
                    fifth = int(v.split('b')[-1] or 0)
                elif 'a' in 'v':
                    fourth = 0
                    fifth = int(v.split('a')[-1] or 0)
                comp.append(fourth)
                comp.append(fifth)
                return comp

        lastVersion = Settings.getSetting('version', '0.0.0')
        Settings.setSetting(Settings.VERSION, __version__)

        if lastVersion == '0.0.0':
            self.firstRun()
            return True
        elif LooseVersion(lastVersion) < LooseVersion(__version__):
            self.queueNotice('{0}... {1}'.format(
                Messages.get_msg(Messages.NEW_TTS_VERSION), __version__))
            return True
        return False
Пример #19
0
 def getMonitoredText(self, isSpeaking=False):
     text = self.getEditText()
     if text != self.keyboardText:
         if not self.keyboardText and len(text) > 1:
             self.keyboardText = text
             self.lastChange = time.time()
             return None
         self.lastChange = time.time()
         out = ''
         d = difflib.Differ()
         if not text and self.keyboardText:
             self.keyboardText = ''
             out = Messages.get_msg(Messages.NO_TEXT)
         elif self.isIP(text):
             if self.isIP(text) and self.isIP(
                     self.keyboardText):  #IP Address
                 oldip = self.keyboardText.replace(' ', '').split('.')
                 newip = text.replace(' ', '').split('.')
                 for old, new in zip(oldip, newip):
                     if old == new: continue
                     out = ' '.join(list(new))
                     break
         elif len(text) > len(self.keyboardText):
             for c in d.compare(self.keyboardText, text):
                 if c.startswith('+'):
                     out += ' ' + (c.strip(' +')
                                   or Messages.get_msg(Messages.SPACE))
         else:
             for c in d.compare(self.keyboardText, text):
                 if c.startswith('-'):
                     out += ' ' + (c.strip(' -')
                                   or Messages.get_msg(Messages.SPACE))
             if out:
                 out = out.strip() + ' {0}'.format(
                     Messages.get_msg(Messages.DELETED))
         self.keyboardText = text
         if out:
             return out.strip()
     else:
         now = time.time()
         if now - self.lastChange > 2:  #We haven't had input for a second, read all the text
             if text != self.lastRead:
                 self.lastChange = now
                 self.lastRead = text
                 if self.isIP(text): return text.replace(' ', '')
                 return text
     return None
Пример #20
0
 def set_api_field(self):
     if self.get_backend_class().isSettingSupported(Settings.API_KEY):
         self.engine_api_key_group.setVisible(True)
         api_key = self.getSetting(Settings.API_KEY, '')
         self.engine_api_key_edit.setText(api_key)
         self.engine_api_key_edit.setLabel(
             Messages.get_msg(Messages.ENTER_API_KEY))
     else:
         self.engine_api_key_group.setVisible(False)
Пример #21
0
def getWindowName(winID):
    name = None
    if winID in winNames:
        name = winNames[winID]
        if isinstance(name,int): name = xbmc.getLocalizedString(name)
    elif winID > 12999:
        return getWindowAddonName(winID)
    return name or xbmc.getInfoLabel('System.CurrentWindow') \
           or Messages.get_msg(Messages.UNKNOWN) #T(unknown)
Пример #22
0
 def takeNoticesForSpeech(self):
     #print 'y'
     if not self.notices: return None
     ret = []
     for n in self.notices:
         ret.append('{0}: {1}... {2}'.format(
             Messages.get_msg(Messages.NOTICE), n[0], n[1]))
     self.init()
     #print ret
     return ret
Пример #23
0
 def volumeUp(self):
     if not self.settings or not 'volume' in self.settings:
         return Messages.get_msg(Messages.CANNOT_ADJUST_VOLUME)
     vol = type(self).getSetting('volume')
     vol += self.volumeStep
     if vol > self.volumeExternalEndpoints[1]:
         vol = self.volumeExternalEndpoints[1]
     self.setSetting('volume', vol)
     if type(self)._logger.isEnabledFor(LazyLogger.DEBUG):
         type(self)._logger.debug('Volume UP: {0}'.format(vol))
     return '{0} {1}'.format(vol, self.volumeSuffix)
Пример #24
0
 def volumeDown(self):
     if not self.settings or not Settings.VOLUME in self.settings:
         return Messages.get_msg(Messages.CANNOT_ADJUST_VOLUME)
     vol = type(self).getSetting(Settings.VOLUME)
     vol -= self.volumeStep
     if vol < self.volumeExternalEndpoints[0]:
         vol = self.volumeExternalEndpoints[0]
     self.setSetting(Settings.VOLUME, vol)
     if type(self)._logger.isEnabledFor(LazyLogger.DEBUG):
         type(self)._logger.debug('Volume DOWN: {0}'.format(vol))
     return '{0} {1}'.format(vol, self.volumeSuffix)
Пример #25
0
 def _cleanText(self, text):
     text = self._formatTagRE.sub('', text)
     text = self._colorTagRE.sub('', text)
     # Some speech engines say OK as Oklahoma
     text = self._okTagRE.sub(r'\1O K\2', text)
     # getLabel() on lists wrapped in [] and some speech engines have
     # problems with text starting with -
     text = text.strip('-[]')
     text = text.replace('XBMC', 'Kodi')
     if text == '..':
         text = Messages.get_msg(Messages.PARENT_DIRECTORY)
     return text
Пример #26
0
    def select_language(self):
        choices, current_choice_index = self.get_language_choices()
        if len(choices) == 0:
            self.setSetting(Settings.LANGUAGE, Settings.UNKNOWN_VALUE)
            self.engine_language_group.setVisible(False)
            self.engine_language_value.setEnabled(False)
            self.engine_language_value.setLabel(
                Messages.get_msg(Messages.UNKNOWN))
            return
        else:
            self.engine_language_group.setVisible(True)

        script_path = Constants.ADDON_PATH
        selection_dialog = SelectionDialog('selection-dialog.xml',
                                           script_path,
                                           'Default',
                                           title=Messages.get_msg(
                                               Messages.SELECT_LANGUAGE),
                                           choices=choices,
                                           initial_choice=current_choice_index)

        selection_dialog.show()
        self._logger.debug_verbose('SelectionDialog doModal start')
        selection_dialog.doModal()
        self._logger.debug_verbose('SelectionDialog doModal finished')
        idx = selection_dialog.getCurrentListPosition()
        self._logger.debug_verbose('SelectionDialog value:',
                                   Messages.get_msg(Messages.SELECT_LANGUAGE),
                                   'idx:', str(idx))
        if idx < 0:
            return

        language = choices[idx].getLabel()
        locale = choices[idx].getLabel2()
        self._logger.debug_verbose(
            'select_language value: {} setting: {} idx: {:d}'.format(
                language, locale, idx))

        self.engine_language_value.setLabel(language)
        self.setSetting(Settings.LANGUAGE, locale)
Пример #27
0
class PVRGuideWindowReader(PVRWindowReaderBase):
    ID = 'pvrguide'
    timelineInfo = (    Messages.get_msg(Messages.CHANNEL), #PVR
                        '$INFO[ListItem.ChannelNumber]',
                        '$INFO[ListItem.ChannelName]',
                        '$INFO[ListItem.StartTime]',
                        19160,
                        '$INFO[ListItem.EndTime]',
                        '$INFO[ListItem.Plot]'
    )

    nowNextInfo = ( Messages.get_msg(Messages.CHANNEL),
                        '$INFO[ListItem.ChannelNumber]',
                        '$INFO[ListItem.ChannelName]',
                        '$INFO[ListItem.StartTime]',
                        '$INFO[ListItem.Plot]'
    )

    def getControlText(self,controlID):
        if not controlID: return ('','')
        if self.slideoutHasFocus(): return self.getSlideoutText(controlID)
        text = xbmc.getInfoLabel('System.CurrentControl')
        if not text: return ('','')
        compare = text + xbmc.getInfoLabel('ListItem.StartTime') + xbmc.getInfoLabel('ListItem.EndTime')
        return (text,compare)

    def getItemExtraTexts(self,controlID):
        text = None
        if self.controlIsOnView(controlID):
            if controlID == 10: #EPG: Timeline
                text = guitables.convertTexts(self.winID,self.timelineInfo)
            elif controlID == 11 or controlID == 12 or controlID == 13: #EPG: Now/Next/Channel
                info = list(self.nowNextInfo)
                if xbmc.getCondVisibility('ListItem.IsRecording'):
                    info.append(19043)
                elif xbmc.getCondVisibility('ListItem.HasTimer'):
                    info.append(31510)
                text = guitables.convertTexts(self.winID,info)
        return text
Пример #28
0
    def record_played_trailer(self, trailer, use_movie_path=False, msg=''):
        # type: (Dict[str, Any], bool, str) -> None
        """

        :param trailer:
        :param use_movie_path:
        :param msg:
        :return:
        """
        if self.playlist_format:
            use_movie_path = True

        name = trailer.get(Movie.TITLE, 'unknown Title')
        year = '(' + str(trailer.get(Movie.YEAR, 'unknown Year')) + ')'
        movie_type = trailer.get(Movie.TYPE, 'Unknown MovieType')
        movie_path = trailer.get(Movie.FILE, None)
        if movie_path is None:
            if use_movie_path:  # Nothing to do if there is no movie path
                return
            movie_path = 'Unknown movie path'
        trailer_path = trailer.get(Movie.TRAILER, '')
        cache_path_prefix = Settings.get_downloaded_trailer_cache_path()
        trailer_path = trailer_path.replace(cache_path_prefix, '<cache_path>')
        missing_detail_msg = Messages.get_msg(Messages.MISSING_DETAIL)
        if trailer_path == missing_detail_msg:
            trailer_path = ''
        if name is None:
            name = 'name is None'
        if year is None:
            year = 'year is None'
        if movie_type is None:
            movie_type = 'movie_type is None'

        path = trailer_path
        if use_movie_path:
            path = movie_path

        formatted_title = Messages.get_formated_title(trailer)

        with Playlist._playlist_lock:
            # file closed
            if self._file is None:
                return

        if self.playlist_format:
            line = Playlist.PLAYLIST_ENTRY_PREFIX + name + '\n'
            line += path + '\n'
        else:
            line = name + '  ' + year + '  # path: ' + formatted_title + ' ' +\
                path + ' ' + msg + '\n'
        self._file.writelines(line)
Пример #29
0
 def getMessage(self):
     if not self.started or not self.valid: return
     if self.seen:
         if self.finished:
             self.valid = False
             return Messages.get_msg(Messages.BACKGROUND_PROGRESS_DONE)
         else:
             return self.getProgress()
     else:
         if self.finished:
             self.valid = False
             return None
         self.seen = True
         return self.title
Пример #30
0
    def get_backend_choices(self):
        self._logger.debug_verbose('get_backend_choices')
        auto_choice_label = Messages.get_msg(Messages.AUTO)
        choices = list()
        list_item = xbmcgui.ListItem(auto_choice_label)
        list_item.setLabel2(Settings.BACKEND_DEFAULT)
        choices.append(list_item)
        current_value = self.getSetting(Settings.BACKEND,
                                        Settings.BACKEND_DEFAULT)
        current_choice_index = 0
        for b in backends.getAvailableBackends():
            self._logger.debug_verbose(Settings.BACKEND, b.displayName)
            list_item = xbmcgui.ListItem(b.displayName)
            list_item.setLabel2(b.provider)
            choices.append(list_item)
            if b.provider == current_value:
                current_choice_index = len(choices) - 1

        return choices, current_choice_index