def keyOK(self):
        if self.idx == len(self.list):
            self.keySave()
            return

        def VirtualKeyBoardCallBack(newTxt):
            if isinstance(newTxt, basestring):
                self[self.activeInput].setText(newTxt)
            self.setKeyboardMode()

        # title
        try:
            title = self.list[self.idx]['title']
        except Exception:
            title = ''

        # virtual keyboard type
        captchaKeyBoard = False
        try:
            if 'icon_path' in self.list[self.idx] and (self.list[self.idx]['icon_path'].endswith('.jpg') or self.list[self.idx]['icon_path'].endswith('.png')):
                captchaKeyBoard = True
                captchaSize = self.list[self.idx]['label_size']
                captchaPath = self.list[self.idx]['icon_path']
                params = dict(self.params.get('vk_params', {}))
                params.update({'captcha_size': captchaSize, 'captcha_path': captchaPath})
        except Exception:
            printExc()

        if not captchaKeyBoard:
            self.session.openWithCallback(VirtualKeyBoardCallBack, GetVirtualKeyboard(), title=title, text=self[self.activeInput].getText())
        else:
            self.session.openWithCallback(VirtualKeyBoardCallBack, IPTVVirtualKeyBoardWithCaptcha, title=title, text=self[self.activeInput].getText(), additionalParams=params)
Esempio n. 2
0
 def getitems(self, cItem):
     printDBG('Start Get items from:' + str(cItem))
     section_ = cItem['section']
     plugin_id_ = cItem['plugin_id']
     py_file = cItem['py_file']
     argv2 = cItem.get('argv2', '{}')
     type_ = cItem.get('type_', '')
     lst = []
     sys.argv = [py_file, '1', argv2, '']
     if type_ == 'search':
         printDBG('11111')
         ret = self.sessionEx.waitForFinishOpen(GetVirtualKeyboard(),
                                                title=_('Set file name'))
         printDBG('22222')
         input_txt = ret[0]
         if not isinstance(input_txt, basestring): input_txt = ''
         if not os.path.exists('/tmp/TSmedia'): os.makedirs('/tmp/TSmedia')
         file = open('/tmp/TSmedia/searchSTR', 'w')
         file.write(input_txt)
         file.close()
         file = open('/tmp/TSmedia/searchSTR.txt', 'w')
         file.write(input_txt)
         file.close()
     try:
         import_ = 'from Plugins.Extensions.TSmedia.addons.' + section_ + '.' + plugin_id_ + '.default import start'
         exec(import_)
         lst = start()
         printDBG(str(lst))
     except Exception, e:
         lst = None
         self.PrintExTs(e)
Esempio n. 3
0
 def confirmMovieTitle(self):
     # first ask user to provide movie title
     self.session.openWithCallback(
         self.confirmMovieTitleCallBack,
         GetVirtualKeyboard(),
         title=(_("Confirm the title of the movie")),
         text=self.movieTitle)
Esempio n. 4
0
 def write_search(self, txt='', txt_def=''):
     if txt_def == '':
         if os.path.isfile(self.MyPath + 'searchSTR'):
             with open(self.MyPath + 'searchSTR', 'r') as f:
                 txt_def = f.read().strip()
     if txt == '':
         ret = self.sessionEx.waitForFinishOpen(GetVirtualKeyboard(),
                                                title=_('Set file name'),
                                                text=txt_def)
         input_txt = ret[0]
     else:
         input_txt = txt
     if isinstance(input_txt, basestring):
         file = open(self.MyPath + 'searchSTR', 'w')
         file.write(input_txt)
         file.close()
Esempio n. 5
0
 def newDir(self):
     self.session.openWithCallback(self.enterPatternCallBack,
                                   GetVirtualKeyboard(),
                                   title=(_("Enter name")),
                                   text="")
    def keyOK(self):
        if not self.isOkEnabled:
            return

        curIndex = self["config"].getCurrentIndex()
        currItem = self["config"].list[curIndex][1]

        if isinstance(currItem, ConfigIPTVFileSelection):

            def SetFilePathCallBack(curIndex, newPath):
                if None != newPath:
                    self["config"].list[curIndex][1].value = newPath

            try:
                if None != currItem.fileMatch:
                    if currItem.ignoreCase:
                        fileMatch = re.compile(currItem.fileMatch,
                                               re.IGNORECASE)
                    else:
                        fileMatch = re.compile(currItem.fileMatch)
                else:
                    fileMatch = None
            except Exception:
                printExc()
                return
            self.session.openWithCallback(
                boundFunction(SetFilePathCallBack,
                              curIndex), IPTVFileSelectorWidget,
                currItem.value, _('Select the file'), fileMatch)
            return

        elif isinstance(currItem, ConfigDirectory):

            def SetDirPathCallBack(curIndex, newPath):
                if None != newPath:
                    self["config"].list[curIndex][1].value = newPath

            self.session.openWithCallback(boundFunction(
                SetDirPathCallBack, curIndex),
                                          IPTVDirectorySelectorWidget,
                                          currDir=currItem.value,
                                          title=_('Select the directory'))
            return
        elif isinstance(currItem, ConfigText):

            def VirtualKeyBoardCallBack(curIndex, newTxt):
                if isinstance(newTxt, basestring):
                    self["config"].list[curIndex][1].value = newTxt

            try:
                # we need hide NumericalTextInputHelpDialog before
                self["config"].list[curIndex][1].help_window.hide()
            except Exception:
                printExc()
            self.session.openWithCallback(boundFunction(
                VirtualKeyBoardCallBack, curIndex),
                                          GetVirtualKeyboard(),
                                          title=(_("Enter a value")),
                                          text=currItem.value)
            return

        ConfigListScreen.keyOK(self)
Esempio n. 7
0
    def showmenu0(self, cItem):
        type_ = cItem.get('gnr', '')
        cat_id_filtre = []
        if type_ == 'ar': cat_id_filtre = ['21']
        if type_ == 'fr': cat_id_filtre = ['31']
        if type_ == 'en': cat_id_filtre = ['41']
        self.list = []
        if config.plugins.iptvplayer.xtream_active.value == 'Yes':
            cat_id_filtre.append('101')
        str_ch = cItem.get('str_ch', 'NoneNone')
        page = cItem.get('page', 1)
        if str_ch == 'NoneNone':
            ret = self.sessionEx.waitForFinishOpen(GetVirtualKeyboard(),
                                                   title=_('Set file name'))
            if isinstance(ret[0], basestring): str_ch = ret[0]
            else:
                self.addMarker({'title': 'String Search Not Valid !!'})
                return
        folder = '/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer/tsiplayer'
        import_ = 'Plugins.Extensions.IPTVPlayer.tsiplayer.'
        lst = []
        lst = os.listdir(folder)
        lst.sort()
        threads = []
        for (file_) in lst:
            if (file_.endswith('.py')) and (file_.startswith('host_')):
                try:
                    path_ = folder + '/' + file_
                    file_ = file_.replace('.py', '')
                    import_str = import_ + file_
                    _temp = __import__(import_str, globals(), locals(),
                                       ['getinfo'], -1)
                    info = _temp.getinfo()
                    search = info.get('recherche_all', '0')
                    cat_id = info.get('cat_id', '0')
                    name = info['name']
                    if (cat_id in cat_id_filtre) and (search != '0'):
                        printDBG('--------------> Recherche ' + name +
                                 '<----------------')
                        threads.append(
                            TsThread(self.get_results, import_str, str_ch,
                                     page, name, file_))
                except:
                    printDBG('--------------> Error ' + file_ +
                             '<----------------')
        for i in threads:
            i.start()
            i.join(timeout=2)
            #GetIPTVSleep().Sleep(0.2)

        #GetIPTVSleep().Sleep(3)
        #[i.start() for i in threads]
        #[i.join(timeout=2)  for i in threads]
        for elm in self.list:
            if elm.get('category', '') == 'video':
                self.addVideo(elm)
            elif elm.get('category', '') == 'mark':
                self.addMarker(elm)
            else:
                self.addDir(elm)
        self.addDir({
            'category': 'host2',
            'title': tscolor('\c0000??00') + 'Next',
            'str_ch': str_ch,
            'desc': '',
            'icon': cItem['icon'],
            'mode': '00',
            'import': cItem['import'],
            'gnr': type_
        })
Esempio n. 8
0
    def performCustomAction(self, privateData):
        retCode = RetHost.ERROR
        retlist = []
        if privateData['action'] == 'remove_file':
            try:
                ret = self.host.sessionEx.waitForFinishOpen(
                    MessageBox,
                    text=_('Are you sure you want to remove file "%s"?') %
                    privateData['file_path'],
                    type=MessageBox.TYPE_YESNO,
                    default=False)
                if ret[0]:
                    os_remove(privateData['file_path'])
                    retlist = ['refresh']
                    retCode = RetHost.OK
            except Exception:
                printExc()
        if privateData['action'] == 'rename_file':
            try:
                path, fileName = os_path.split(privateData['file_path'])
                name, ext = os_path.splitext(fileName)
                ret = self.host.sessionEx.waitForFinishOpen(
                    GetVirtualKeyboard(), title=_('Set file name'), text=name)
                printDBG('rename_file new name[%s]' % ret)
                if isinstance(ret[0], basestring):
                    newPath = os_path.join(path, ret[0] + ext)
                    printDBG('rename_file new path[%s]' % newPath)
                    if not os_path.isfile(newPath) and not os_path.islink(
                            newPath):
                        os_rename(privateData['file_path'], newPath)
                        retlist = ['refresh']
                        retCode = RetHost.OK
                    else:
                        retlist = [_('File "%s" already exists!') % newPath]
            except Exception:
                printExc()
        elif privateData['action'] == 'cut_file':
            self.cFilePath = privateData['file_path']
            self.cType = 'cut'
            retCode = RetHost.OK
        elif privateData['action'] == 'copy_file':
            self.cFilePath = privateData['file_path']
            self.cType = 'copy'
            retCode = RetHost.OK
        elif privateData['action'] == 'paste_file':
            try:
                ok = True
                cutPath, cutFileName = os_path.split(self.cFilePath)
                newPath = os_path.join(privateData['path'], cutFileName)
                if os_path.isfile(newPath):
                    retlist = [_('File "%s" already exists') % newPath]
                    ok = False
                else:
                    ret = {'sts': True, 'code': 0, 'data': ''}
                    if self.cType == 'cut':
                        try:
                            os_rename(self.cFilePath, newPath)
                            self.needRefresh = cutPath
                        except Exception:
                            printExc()
                            cmd = 'mv -f "%s" "%s"' % (self.cFilePath, newPath)
                            ret = iptv_execute_wrapper(cmd)
                    elif self.cType == 'copy':
                        cmd = 'cp "%s" "%s"' % (self.cFilePath, newPath)
                        ret = iptv_execute_wrapper(cmd)

                if ret['sts'] and 0 != ret['code']:
                    retlist = [(_('Moving file from "%s" to "%s" failed.\n') %
                                (self.cFilePath, newPath)) +
                               (_('Error code: %s\n') % ret['code']) +
                               (_('Error message: %s\n') % ret['data'])]
                    ok = False

                if ok:
                    self.cType = ''
                    self.cFilePath = ''
                    retlist = ['refresh']
                    retCode = RetHost.OK
            except Exception:
                printExc()
        elif privateData['action'] == 'umount_iso_file':
            cmd = 'umount "{0}"'.format(
                privateData['iso_mount_path']) + ' 2>&1'
            ret = iptv_execute_wrapper(cmd)
            if ret['sts'] and 0 != ret['code']:
                # normal umount failed, so detach filesystem only
                cmd = 'umount -l "{0}"'.format(
                    privateData['iso_mount_path']) + ' 2>&1'
                ret = iptv_execute_wrapper(cmd)

        return RetHost(retCode, value=retlist)