def __init__(self, msg='', L=0, T=0, W=1280, H=720, TxtColor='0xFFFFFFFF', Font='font12', BorderWidth=10): buttonfocus, buttonnofocus = artwork('button') radiobgfocus, radiobgnofocus, radiofocus, radionofocus = artwork( 'radio') slidernibfocus, slidernibnofocus = artwork('slider') image_path = FANART boxbg = os.path.join(SKINFOLD, 'Background', 'Fenetre.png') self.border = xbmcgui.ControlImage(L, T, W, H, image_path) self.addControl(self.border) self.BG = xbmcgui.ControlImage(L + BorderWidth, T + BorderWidth, W - (BorderWidth * 2), H - (BorderWidth * 2), FANART, aspectRatio=0, colorDiffuse='0xFFFFFFFF') self.addControl(self.BG) top = T #+BorderWidth leftside = L #+BorderWidth rightside = L + (W / 2) #-(BorderWidth*2) firstrow = top + 30 secondrow = firstrow + 300 + (BorderWidth / 2) currentwidth = ((W / 2) - (BorderWidth * 4)) / 2 header = '[COLOR %s][B]Configuration des paramètres Avancés de Kodi[/B][/COLOR]' % ( COLOR2) self.Header = xbmcgui.ControlLabel(L, top, W, 30, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header) top += 30 + BorderWidth self.bgarea = xbmcgui.ControlImage(leftside, firstrow, rightside - L, 300, boxbg, aspectRatio=0, colorDiffuse='0xFFFFFFFF') self.addControl(self.bgarea) self.bgarea2 = xbmcgui.ControlImage(rightside, firstrow, rightside - L, 300, boxbg, aspectRatio=0, colorDiffuse='0xFFFFFFFF') self.addControl(self.bgarea2) self.bgarea3 = xbmcgui.ControlImage(leftside, secondrow, rightside - L, 300, boxbg, aspectRatio=0, colorDiffuse='0xFFFFFFFF') self.addControl(self.bgarea3) self.bgarea4 = xbmcgui.ControlImage(rightside, secondrow, rightside - L, 300, boxbg, aspectRatio=0, colorDiffuse='0xFFFFFFFF') self.addControl(self.bgarea4) header = '[COLOR %s]Taille de la mémoire video[/COLOR]' % (COLOR2) self.Header2 = xbmcgui.ControlLabel(leftside + BorderWidth, firstrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header2) freeMemory = int( float(xbmc.getInfoLabel('System.Memory(free)')[:-2]) * .33) recMemory = int( float(xbmc.getInfoLabel('System.Memory(free)')[:-2]) * .23) msg3 = "[COLOR %s]Taille de la mémoire tampon de kodi. Si on le met à [COLOR %s]0[/COLOR] la mémoire tampon est mise sur le disque dur et pas sur la RAM. Note: Pour la taille de mémoire définie ici, Kodi nécessitera 3 fois la quantité de RAM libre. Si ce paramètre est trop élevé, Kodi risque de se bloquer s'il ne dispose pas de suffisamment de RAM (mémoire libre: [COLOR %s]%s[/COLOR])[/COLOR]" % ( COLOR2, COLOR1, COLOR1, freeMemory) self.Support3 = xbmcgui.ControlTextBox( leftside + int(BorderWidth * 2), firstrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 220, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.videoCacheSize = xbmcgui.ControlSlider( leftside + int(BorderWidth * 2.5), firstrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.videoCacheSize = xbmcgui.ControlSlider( leftside + int(BorderWidth * 2.5), firstrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.videoCacheSize) self.videomin = 0 self.videomax = freeMemory if freeMemory < 2000 else 2000 self.recommendedVideo = recMemory if recMemory < 500 else 500 self.currentVideo = self.recommendedVideo videopos = 100 * float(self.currentVideo) / float(self.videomax) self.videoCacheSize.setPercent(videopos) current1 = '[COLOR %s]Votre Choix:[/COLOR] [COLOR %s]%s MB[/COLOR]' % ( COLOR1, COLOR2, self.currentVideo) recommended1 = '[COLOR %s]Recommandé:[/COLOR] [COLOR %s]%s MB[/COLOR]' % ( COLOR1, COLOR2, self.recommendedVideo) self.currentVideo1 = xbmcgui.ControlTextBox(leftside + BorderWidth + 20, firstrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentVideo1) self.currentVideo1.setText(current1) self.recommendedVideo1 = xbmcgui.ControlTextBox( leftside + BorderWidth + currentwidth, firstrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedVideo1) self.recommendedVideo1.setText(recommended1) header = '[COLOR %s]Temps avant la déconnexion au site[/COLOR]' % ( COLOR2) self.Header3 = xbmcgui.ControlLabel(rightside, firstrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header3) msg3 = "[COLOR %s][B]curlclienttimeout[/B] est le temps en seconde pour arrêter la connexion au site internet sur dépassement du temps. \n[B]curllowspeedtime[/B] est le temps en seconde pour que le site soit considéré comme trop lent.\n\nPour les connexion lentes mettre 20s.[/COLOR]" % COLOR2 self.Support3 = xbmcgui.ControlTextBox( rightside + int(BorderWidth * 2.5), firstrow + 50 + BorderWidth, (W / 2) - (BorderWidth * 4), 220, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.CURLTimeout = xbmcgui.ControlSlider( rightside + int(BorderWidth * 2.5), firstrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.CURLTimeout = xbmcgui.ControlSlider( rightside + int(BorderWidth * 2.5), firstrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.CURLTimeout) self.curlmin = 0 self.curlmax = 20 self.recommendedCurl = 10 self.currentCurl = self.recommendedCurl curlpos = 100 * float(self.currentCurl) / float(self.curlmax) self.CURLTimeout.setPercent(curlpos) current2 = '[COLOR %s]Votre Choix:[/COLOR] [COLOR %s]%ss[/COLOR]' % ( COLOR1, COLOR2, self.currentCurl) recommended2 = '[COLOR %s]Recommandé:[/COLOR] [COLOR %s]%ss[/COLOR]' % ( COLOR1, COLOR2, self.recommendedCurl) self.currentCurl2 = xbmcgui.ControlTextBox(rightside + (BorderWidth * 3), firstrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentCurl2) self.currentCurl2.setText(current2) self.recommendedCurl2 = xbmcgui.ControlTextBox( rightside + (BorderWidth * 3) + currentwidth, firstrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedCurl2) self.recommendedCurl2.setText(recommended2) header = '[COLOR %s]Facteur de lecture de la mémoire tampon[/COLOR]' % ( COLOR2) self.Header4 = xbmcgui.ControlLabel(leftside, secondrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header4) msg3 = "[COLOR %s]Par défaut 4, Kodi remplira la mémoire tampon un peu au-dessus de ce qui est nécessaire pour la lecture. En augmentant cette valeur kodi prendra de l'avance sur le téléchargement et remplira la mémoire tampon! Donc en augmentant cette valeur la connexion internet sera monopoliser par kodi avec une augmentation de l'utilisation du processeur...[/COLOR]" % COLOR2 self.Support3 = xbmcgui.ControlTextBox( leftside + int(BorderWidth * 2), secondrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 240, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.readBufferFactor = xbmcgui.ControlSlider( leftside + int(BorderWidth * 2.5), secondrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.readBufferFactor = xbmcgui.ControlSlider( leftside + int(BorderWidth * 2.5), secondrow + 240, (W / 2) - (BorderWidth * 5), 20, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.readBufferFactor) self.readmin = 0 self.readmax = 30 self.recommendedRead = 5 self.currentRead = self.recommendedRead readpos = 100 * float(self.currentRead) / float(self.readmax) self.readBufferFactor.setPercent(readpos) current3 = '[COLOR %s]Votre Choix:[/COLOR] [COLOR %s]%s[/COLOR]' % ( COLOR1, COLOR2, self.currentRead) recommended3 = '[COLOR %s]Recommandé:[/COLOR] [COLOR %s]%s[/COLOR]' % ( COLOR1, COLOR2, self.recommendedRead) self.currentRead3 = xbmcgui.ControlTextBox(leftside + BorderWidth + 30, secondrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentRead3) self.currentRead3.setText(current3) self.recommendedRead3 = xbmcgui.ControlTextBox( leftside + BorderWidth + currentwidth, secondrow + 260, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedRead3) self.recommendedRead3.setText(recommended3) header = '[COLOR %s]Mode mémoire tampon[/COLOR]' % (COLOR2) self.Header4 = xbmcgui.ControlLabel(rightside, secondrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header4) msg4 = "[COLOR %s]Ce paramètre permet de choisir quels types de fichiers seront mis en mémoire tampon. La valeur par défaut et 0, Cela permet de mettre et mémoire tampon tous les fichiers distants.[/COLOR]" % COLOR2 self.Support4 = xbmcgui.ControlTextBox( rightside + int(BorderWidth * 2), secondrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 110, font='font12', textColor=TxtColor) self.addControl(self.Support4) self.Support4.setText(msg4) B1 = secondrow + 140 + BorderWidth B2 = B1 + 35 B3 = B2 + 35 B4 = B3 + 35 self.Button0 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3) - 22, B1, (W / 2) - (BorderWidth * 4) + 20, 30, "0: Mémoriser les fichier d'internet et réseau local", font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button1 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3) - 22, B2, (W / 2) - (BorderWidth * 4) + 20, 30, '1: Mémoriser tous les fichier', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button2 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3) - 22, B3, (W / 2) - (BorderWidth * 4) + 20, 30, "2: Mémoriser que les fichiers en streaming", font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button3 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3) - 22, B4, (W / 2) - (BorderWidth * 4) + 20, 30, '3: Pas de mémoire tampon', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.addControl(self.Button0) self.addControl(self.Button1) self.addControl(self.Button2) self.addControl(self.Button3) self.Button0.setSelected(False) self.Button1.setSelected(False) self.Button2.setSelected(True) self.Button3.setSelected(False) self.buttonWrite = xbmcgui.ControlButton( leftside, T + H - BorderWidth, (W / 2) - (BorderWidth * 2), 35, "Ecrire le fichier de configuration", textColor="0xFFFFFFFF", focusedColor="0xFFFFFFFF", alignment=2, focusTexture=buttonfocus, noFocusTexture=buttonnofocus) self.buttonCancel = xbmcgui.ControlButton( rightside + BorderWidth * 2, T + H - BorderWidth, (W / 2) - (BorderWidth * 2), 35, "Annuler", textColor="0xFFFFFFFF", focusedColor="0xFFFFFFFF", alignment=2, focusTexture=buttonfocus, noFocusTexture=buttonnofocus) self.addControl(self.buttonWrite) self.addControl(self.buttonCancel) self.buttonWrite.controlLeft(self.buttonCancel) self.buttonWrite.controlRight(self.buttonCancel) self.buttonWrite.controlUp(self.Button3) self.buttonWrite.controlDown(self.videoCacheSize) self.buttonCancel.controlLeft(self.buttonWrite) self.buttonCancel.controlRight(self.buttonWrite) self.buttonCancel.controlUp(self.Button3) self.buttonCancel.controlDown(self.videoCacheSize) self.currentVideo1.controlUp(self.buttonWrite) self.currentVideo1.controlDown(self.CURLTimeout) self.videoCacheSize.controlUp(self.buttonWrite) self.videoCacheSize.controlDown(self.CURLTimeout) self.CURLTimeout.controlUp(self.videoCacheSize) self.CURLTimeout.controlDown(self.readBufferFactor) self.readBufferFactor.controlUp(self.CURLTimeout) self.readBufferFactor.controlDown(self.Button0) self.Button0.controlUp(self.CURLTimeout) self.Button0.controlDown(self.Button1) self.Button0.controlLeft(self.readBufferFactor) self.Button0.controlRight(self.readBufferFactor) self.Button1.controlUp(self.Button0) self.Button1.controlDown(self.Button2) self.Button1.controlLeft(self.readBufferFactor) self.Button1.controlRight(self.readBufferFactor) self.Button2.controlUp(self.Button1) self.Button2.controlDown(self.Button3) self.Button2.controlLeft(self.readBufferFactor) self.Button2.controlRight(self.readBufferFactor) self.Button3.controlUp(self.Button2) self.Button3.controlDown(self.buttonWrite) self.Button3.controlLeft(self.readBufferFactor) self.Button3.controlRight(self.readBufferFactor) self.setFocus(self.videoCacheSize)
def get_response(img, cookie): # on telecharge l'image import xbmcvfs dialogs = dialog() filename = "special://home/userdata/addon_data/plugin.video.vstream/Captcha.raw" # PathCache = xbmc.translatePath(xbmcaddon.Addon('plugin.video.vstream').getAddonInfo("profile")) # filename = os.path.join(PathCache, 'Captcha.raw') # hostComplet = re.sub(r'(https*:\/\/[^/]+)(\/*.*)', '\\1', img) # host = re.sub(r'https*:\/\/', '', hostComplet) url = img oRequestHandler = cRequestHandler(url) oRequestHandler.addHeaderEntry('User-Agent', UA) # oRequestHandler.addHeaderEntry('Referer', url) oRequestHandler.addHeaderEntry('Cookie', cookie) htmlcontent = oRequestHandler.request() NewCookie = oRequestHandler.GetCookies() downloaded_image = xbmcvfs.File(filename, 'wb') # downloaded_image = file(filename, "wb") downloaded_image.write(htmlcontent) downloaded_image.close() # on affiche le dialogue solution = '' if (True): # nouveau captcha try: # affichage du dialog perso class XMLDialog(xbmcgui.WindowXMLDialog): # """ # Dialog class for captcha # """ def __init__(self, *args, **kwargs): xbmcgui.WindowXMLDialog.__init__(self) pass def onInit(self): # image background captcha self.getControl(1).setImage(filename.encode("utf-8"), False) # image petit captcha memory fail self.getControl(2).setImage(filename.encode("utf-8"), False) self.getControl(2).setVisible(False) # Focus clavier self.setFocus(self.getControl(21)) def onClick(self, controlId): if controlId == 20: # button Valider solution = self.getControl(5000).getLabel() xbmcgui.Window(10101).setProperty('captcha', solution) self.close() return elif controlId == 30: # button fermer self.close() return elif controlId == 21: # button clavier self.getControl(2).setVisible(True) kb = xbmc.Keyboard( self.getControl(5000).getLabel(), '', False) kb.doModal() if (kb.isConfirmed()): self.getControl(5000).setLabel(kb.getText()) self.getControl(2).setVisible(False) else: self.getControl(2).setVisible(False) def onFocus(self, controlId): self.controlId = controlId def _close_dialog(self): self.close() def onAction(self, action): # touche return 61448 if action.getId() in (9, 10, 11, 30, 92, 216, 247, 257, 275, 61467, 61448): self.close() path = "special://home/addons/plugin.video.vstream" wd = XMLDialog('DialogCaptcha.xml', path, 'default', '720p') wd.doModal() del wd finally: solution = xbmcgui.Window(10101).getProperty('captcha') if solution == '': dialogs.VSinfo("Vous devez taper le captcha") else: # ancien Captcha try: img = xbmcgui.ControlImage(450, 0, 400, 130, filename.encode("utf-8")) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() # xbmc.sleep(3000) kb = xbmc.Keyboard("", "Tapez les Lettres/chiffres de l'image", False) kb.doModal() if (kb.isConfirmed()): solution = kb.getText() if solution == '': dialogs.VSinfo("Vous devez taper le captcha") else: dialogs.VSinfo("Vous devez taper le captcha") finally: wdlg.removeControl(img) wdlg.close() return solution, NewCookie
def get_media_url(self, host, media_id): try: url = self.get_url(host, media_id) ######### dialog = xbmcgui.DialogProgress() dialog.create('Resolving', 'Resolving BillionUploads Link...') dialog.update(0) common.addon.log( self.name + ' - Requesting GET URL: %s' % url ) cj = cookielib.CookieJar() normal = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) normal.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36')] ######################################################## ######## CLOUD FLARE STUFF ####################################################### class NoRedirection(urllib2.HTTPErrorProcessor): # Stop Urllib2 from bypassing the 503 page. def http_response(self, request, response): code, msg, hdrs = response.code, response.msg, response.info() return response https_response = http_response opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36')] response = opener.open(url).read() jschl=re.compile('name="jschl_vc" value="(.+?)"/>').findall(response) if jschl: jschl = jschl[0] maths=re.compile('value = (.+?);').findall(response)[0].replace('(','').replace(')','') domain_url = re.compile('(https?://.+?/)').findall(url)[0] domain = re.compile('https?://(.+?)/').findall(domain_url)[0] time.sleep(5) final= normal.open(domain_url+'cdn-cgi/l/chk_jschl?jschl_vc=%s&jschl_answer=%s'%(jschl,eval(maths)+len(domain))).read() html = normal.open(url).read() else: html = response ################################################################################ #Check page for any error msgs if re.search('This server is in maintenance mode', html): common.addon.log_error(self.name + ' - Site reported maintenance mode') xbmc.executebuiltin('XBMC.Notification([B][COLOR white]BILLIONUPLOADS[/COLOR][/B],[COLOR red]Site reported maintenance mode[/COLOR],8000,'+logo+')') return self.unresolvable(code=2, msg='Site reported maintenance mode') # Check for file not found if re.search('File Not Found', html): common.addon.log_error(self.name + ' - File Not Found') xbmc.executebuiltin('XBMC.Notification([B][COLOR white]BILLIONUPLOADS[/COLOR][/B],[COLOR red]File Not Found[/COLOR],8000,'+logo+')') return self.unresolvable(code=1, msg='File Not Found') data = {} r = re.findall(r'type="hidden" name="(.+?)" value="(.+?)">', html) for name, value in r: data[name] = value captchaimg = re.search('<img src="((?:http://|www\.)?BillionUploads.com/captchas/.+?)"', html) if captchaimg: dialog.close() img = xbmcgui.ControlImage(550,15,240,100,captchaimg.group(1)) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() time.sleep(3) kb = xbmc.Keyboard('', 'Type the letters in the image', False) kb.doModal() capcode = kb.getText() if (kb.isConfirmed()): userInput = kb.getText() if userInput != '': capcode = kb.getText() elif userInput == '': common.addon.show_error_dialog("You must enter the text from the image to access video") return False else: return False wdlg.close() dialog.close() dialog.create('Resolving', 'Resolving BillionUploads Link...') dialog.update(50) data.update({'code':capcode}) else: dialog.create('Resolving', 'Resolving BillionUploads Link...') dialog.update(50) data.update({'submit_btn':''}) r = re.search('document\.getElementById\(\'.+\'\)\.innerHTML=decodeURIComponent\(\"(.+?)\"\);', html) if r: r = re.findall('type="hidden" name="(.+?)" value="(.+?)">', urllib.unquote(r.group(1)).decode('utf8') ) for name, value in r: data.update({name:value}) html = normal.open(url, urllib.urlencode(data)).read() dialog.update(100) def custom_range(start, end, step): while start <= end: yield start start += step def checkwmv(e): s = "" # Create an array containing A-Z,a-z,0-9,+,/ i=[] u=[[65,91],[97,123],[48,58],[43,44],[47,48]] for z in range(0, len(u)): for n in range(u[z][0],u[z][1]): i.append(chr(n)) #print i # Create a dict with A=0, B=1, ... t = {} for n in range(0, 64): t[i[n]]=n #print t for n in custom_range(0, len(e), 72): a=0 h=e[n:n+72] c=0 #print h for l in range(0, len(h)): f = t.get(h[l], 'undefined') if f == 'undefined': continue a= (a<<6) + f c = c + 6 while c >= 8: c = c - 8 s = s + chr( (a >> c) % 256 ) return s dll = re.compile('<input type="hidden" id="dl" value="(.+?)">').findall(html)[0] dl = dll.split('GvaZu')[1] dl = checkwmv(dl) dl = checkwmv(dl) common.addon.log(self.name + ' - Link Found: %s' % dl) return dl except Exception, e: common.addon.log_error(self.name + ' - Exception: %s' % e) return self.unresolvable(code=0, msg='Exception: %s' % e)
def __init__(self): self.addControl( xbmcgui.ControlImage(0, 0, 1280, 720, art + '/infoposter.png'))
def __init__(self, authorize_url): # save window resolution to arrange the text fields an QR code screenx = self.getWidth() screeny = self.getHeight() utils.log('Screen resolution: %dx%d' % (screenx, screeny), xbmc.LOGDEBUG) # Show Dialog with Dropbox Authorization URL res_qr_code = [0, 0] # resolution of the QR-code image. # Show QR-Code Dropbox Authorization URL (source code from qr-code.py from service.linuxwhatelse.notify) if PIL_AVAILABLE: tmp_dir = os.path.join(utils.data_dir()) # tmp_dir has to exist tmp_file = os.path.join(tmp_dir, 'dropbox-auth-qr-code.png') # Create the QR-code image and save it to temp direcotry qr = qrcode.main.QRCode(box_size=40, border=2) qr.add_data(authorize_url) qr.make(fit=True) img = qr.make_image() img.save(tmp_file) # Show the QR-Code in Kodi # http://www.programcreek.com/python/example/84322/xbmcgui.getCurrentWindowId utils.log( 'Add control image with %dx%d at (%d,%d)' % (screeny / 2, screeny / 2, 100, 100), xbmc.LOGDEBUG) res_qr_code = [ int(screeny / 4), int(screeny / 4) ] # TODO: the image is displayed bigger than the desired size. Find out why. image = xbmcgui.ControlImage(100, 100, res_qr_code[0], res_qr_code[1], tmp_file) self.addControl(image) else: # The PIL module isn't available so we inform the user about it utils.showNotification(utils.getString(32102), utils.getString(32201)) # Print the Information text below the QR code self.addControl( xbmcgui.ControlLabel(x=100, y=(100 + res_qr_code[1] + 50), width=screenx, height=25, label=utils.getString(32704), textColor='0xFFFFFFFF')) self.addControl( xbmcgui.ControlLabel(x=100, y=(100 + res_qr_code[1] + 100), width=screenx, height=25, label=authorize_url, textColor='0xFFFFFFFF')) self.addControl( xbmcgui.ControlLabel(x=100, y=(100 + res_qr_code[1] + 150), width=screenx, height=25, label=utils.getString(32705), textColor='0xFFFFFFFF')) # Also print the text to the log file for manual use utils.log('Open the following URL: %s' % authorize_url) # this shows the window on the screen self.show()
def __init__(self, *args, **kwargs): self.cptloc = kwargs.get('captcha') self.img = xbmcgui.ControlImage(335, 30, 624, 60, self.cptloc) self.addControl(self.img) self.kbd = xbmc.Keyboard()
def __init__(self, msg='', L=0, T=0, W=1280, H=720, TxtColor='0xFFFFFFFF', Font='font14', BorderWidth=10): image_path = os.path.join(ART, 'ContentPanel.png') self.border = xbmcgui.ControlImage(L, T, W, H, image_path) self.addControl(self.border) self.BG = xbmcgui.ControlImage(L + BorderWidth, T + BorderWidth, W - (BorderWidth * 2), H - (BorderWidth * 2), BACKGROUND, aspectRatio=0, colorDiffuse='0x9FFFFFFF') self.addControl(self.BG) #title if HEADERTYPE == 'Image': iLogoW = 144 iLogoH = 68 self.iLogo = xbmcgui.ControlImage((L + (W / 2)) - (iLogoW / 2), T + 10, iLogoW, iLogoH, HEADERIMAGE, aspectRatio=0) self.addControl(self.iLogo) else: title = '[COLOR hotpink]First Disclaimer[/COLOR]' times = int(float(FONTHEADER[-2:])) temp = title.replace('[', '<').replace(']', '>') temp = re.sub('<[^<]+?>', '', temp) title_width = len(str(temp)) * (times - 1) title = title self.title = xbmcgui.ControlTextBox(L + (W - title_width) / 2, T + BorderWidth, title_width, 30, font=FONTHEADER, textColor='0xFF1E90FF') self.addControl(self.title) self.title.setText(title) #body msg = TERMS self.TxtMessage = xbmcgui.ControlTextBox( L + BorderWidth + 10, T + 30 + BorderWidth, W - (BorderWidth * 2) - 20, H - (BorderWidth * 2) - 75, font=Font, textColor=TxtColor) self.addControl(self.TxtMessage) self.TxtMessage.setText(msg) #buttons focus, nofocus = artwork('button') w1 = int((W - (BorderWidth * 5)) / 3) h1 = 35 t = int(T + H - h1 - (BorderWidth * 1.5)) space = int(L + (BorderWidth * 1.5)) dismiss = int(space + w1 + BorderWidth) self.buttonDismiss = xbmcgui.ControlButton( dismiss, t, w1, h1, "I Agree", textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=focus, noFocusTexture=nofocus) self.addControl(self.buttonDismiss) self.setFocus(self.buttonDismiss)
def __init__(self, *args, **kwargs): self.tmdb = kwargs.get("tmdb", {}) self.imdb = kwargs.get("imdb", {}) self.mal = kwargs.get("mal", {}) self.fanartv = kwargs.get("fanartv", {}) self.image_list = [] for key, value in self.tmdb.items(): for detail in value: self.image_list.append('https://image.tmdb.org/t/p/original' + detail["file_path"]) for image in self.imdb: self.image_list.append(image["src"]) for image, title in self.mal: self.image_list.append(image) for key, value in self.fanartv.items(): for image in value: self.image_list.append(image["url"]) #### Kodi 18 Compatibility #### if config.get_platform(True)['num_version'] < 18: self.setCoordinateResolution(2) log self.background = xbmcgui.ControlImage(0, 0, 1280, 720, imagepath('white'), colorDiffuse='FF232323') self.addControl(self.background) main_image = self.image_list[0] if self.image_list else '' self.main_image = xbmcgui.ControlImage(0, 0, 1280, 720, main_image, 2) self.addControl(self.main_image) if self.image_list: self.counter = xbmcgui.ControlTextBox(1180, 640, 60, 40, 'font13') self.addControl(self.counter) self.counter.setText('%s/%s' % (1, len(self.image_list))) else: self.text = xbmcgui.ControlLabel(0, 0, 1280, 720, 'NESSUNA IMMAGINE', 'font13', alignment=2 | 4) self.addControl(self.text) self.close_btn = xbmcgui.ControlButton(0, 0, 1280, 720, '', '', '') self.addControl(self.close_btn) if len(self.image_list) > 1: # BUTTON LEFT self.btn_left = xbmcgui.ControlButton( 0, 330, 60, 60, '', imagepath('previous_focus'), imagepath('previous_nofocus')) self.addControl(self.btn_left) self.btn_left.setAnimations([ ('WindowOpen', 'effect=slide start=-60,0 end=0,0 delay=100 time=200'), ('WindowClose', 'effect=slide start=0,0 end=-60,0 delay=100 time=200') ]) # BUTTON RIGHT self.btn_right = xbmcgui.ControlButton(1220, 330, 60, 60, '', imagepath('next_focus'), imagepath('next_nofocus')) self.addControl(self.btn_right) self.btn_right.setAnimations([ ('WindowOpen', 'effect=slide start=60,0 end=0,0 delay=100 time=200'), ('WindowClose', 'effect=slide start=0,0 end=60,0 delay=100 time=200') ]) self.count = 0
sys.exit() #generating screenshot subprocess.call(["killall", "hyperiond"]) os.chdir("/storage") if grabber == "utv007": xbmcgui.Dialog().ok( addonname, subprocess.check_output([ "/storage/hyperion/bin/hyperion-v4l2.sh", "--video-standard", "PAL", "--screenshot" ])) else: xbmcgui.Dialog().ok( addonname, subprocess.check_output([ "/storage/hyperion/bin/hyperion-v4l2.sh", "--video-standard", "PAL", "--width", "240", "--height", "192", "--screenshot" ])) okno = xbmcgui.WindowDialog(xbmcgui.getCurrentWindowId()) obrazek = xbmcgui.ControlImage(0, 0, 1280, 720, "/storage/screenshot.png") okno.addControl(obrazek) okno.show() obrazek.setVisible(True) time.sleep(5) okno.close() except Exception, e: xbmcgui.Dialog().ok(addonname, repr(e), "Please report an error at plugin github issue list")
def __init__(self, xmlFile, scriptPath): xbmcgui.Window(10000).setProperty('HelpGui', 'True') self.HelpImg =xbmcgui.ControlImage(50, 50, 1180, 596,__addon__.getAddonInfo('path') + '/resources/media/background.png' , aspectRatio=0) self.addControl(self.HelpImg)
def billionuploads(self, url): try: cookie_file = os.path.join(cookiepath,'billionuploads.lwp') cj = cookielib.LWPCookieJar() if os.path.exists(cookie_file): try: cj.load(cookie_file,True) except: cj.save(cookie_file,True) else: cj.save(cookie_file,True) normal = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) headers = [ ('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0'), ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ('Accept-Language', 'en-US,en;q=0.5'), ('Accept-Encoding', ''), ('DNT', '1'), ('Connection', 'keep-alive'), ('Pragma', 'no-cache'), ('Cache-Control', 'no-cache') ] normal.addheaders = headers class NoRedirection(urllib2.HTTPErrorProcessor): # Stop Urllib2 from bypassing the 503 page. def http_response(self, request, response): code, msg, hdrs = response.code, response.msg, response.info() return response https_response = http_response opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cj)) opener.addheaders = normal.addheaders response = opener.open(url).read() decoded = re.search('(?i)var z="";var b="([^"]+?)"', response) if decoded: decoded = decoded.group(1) z = [] for i in range(len(decoded)/2): z.append(int(decoded[i*2:i*2+2],16)) decoded = ''.join(map(unichr, z)) incapurl = re.search('(?i)"GET","(/_Incapsula_Resource[^"]+?)"', decoded) if incapurl: incapurl = 'http://billionuploads.com'+incapurl.group(1) opener.open(incapurl) cj.save(cookie_file,True) response = opener.open(url).read() captcha = re.search('(?i)<iframe src="(/_Incapsula_Resource[^"]+?)"', response) if captcha: captcha = 'http://billionuploads.com'+captcha.group(1) opener.addheaders.append(('Referer', url)) response = opener.open(captcha).read() formurl = 'http://billionuploads.com'+re.search('(?i)<form action="(/_Incapsula_Resource[^"]+?)"', response).group(1) resource = re.search('(?i)src=" (/_Incapsula_Resource[^"]+?)"', response) if resource: import random resourceurl = 'http://billionuploads.com'+resource.group(1) + str(random.random()) opener.open(resourceurl) recaptcha = re.search('(?i)<script type="text/javascript" src="(https://www.google.com/recaptcha/api[^"]+?)"', response) if recaptcha: response = opener.open(recaptcha.group(1)).read() challenge = re.search('''(?i)challenge : '([^']+?)',''', response) if challenge: challenge = challenge.group(1) captchaimg = 'https://www.google.com/recaptcha/api/image?c=' + challenge img = xbmcgui.ControlImage(450,15,400,130,captchaimg) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() xbmc.sleep(3000) kb = xbmc.Keyboard('', 'Please enter the text in the image', False) kb.doModal() capcode = kb.getText() if (kb.isConfirmed()): userInput = kb.getText() if userInput != '': capcode = kb.getText() elif userInput == '': logerror('BillionUploads - Image-Text not entered') xbmc.executebuiltin("XBMC.Notification(Image-Text not entered.,BillionUploads,2000)") return None else: return None wdlg.close() captchadata = {} captchadata['recaptcha_challenge_field'] = challenge captchadata['recaptcha_response_field'] = capcode opener.addheaders = headers opener.addheaders.append(('Referer', captcha)) resultcaptcha = opener.open(formurl,urllib.urlencode(captchadata)).info() opener.addheaders = headers response = opener.open(url).read() ga = re.search('(?i)"text/javascript" src="(/ga[^"]+?)"', response) if ga: jsurl = 'http://billionuploads.com'+ga.group(1) p = "p=%7B%22appName%22%3A%22Netscape%22%2C%22platform%22%3A%22Win32%22%2C%22cookies%22%3A1%2C%22syslang%22%3A%22en-US%22" p += "%2C%22userlang%22%3A%22en-US%22%2C%22cpu%22%3A%22WindowsNT6.1%3BWOW64%22%2C%22productSub%22%3A%2220100101%22%7D" opener.open(jsurl, p) response = opener.open(url).read() # pid = re.search('(?i)PID=([^"]+?)"', response) # if pid: # normal.addheaders += [('Cookie','D_UID='+pid.group(1)+';')] # opener.addheaders = normal.addheaders if re.search('(?i)url=/distil_r_drop.html', response) and filename: url += '/' + filename response = normal.open(url).read() jschl=re.compile('name="jschl_vc" value="(.+?)"/>').findall(response) if jschl: jschl = jschl[0] maths=re.compile('value = (.+?);').findall(response)[0].replace('(','').replace(')','') domain_url = re.compile('(https?://.+?/)').findall(url)[0] domain = re.compile('https?://(.+?)/').findall(domain_url)[0] final= normal.open(domain_url+'cdn-cgi/l/chk_jschl?jschl_vc=%s&jschl_answer=%s'%(jschl,eval(maths)+len(domain))).read() html = normal.open(url).read() else: html = response data = {} r = re.findall(r'type="hidden" name="(.+?)" value="(.*?)">', html) for name, value in r: data[name] = value captchaimg = re.search('<img src="((?:http://|www\.)?BillionUploads.com/captchas/.+?)"', html) if captchaimg: img = xbmcgui.ControlImage(550,15,240,100,captchaimg.group(1)) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() kb = xbmc.Keyboard('', 'Please enter the text in the image', False) kb.doModal() capcode = kb.getText() if (kb.isConfirmed()): userInput = kb.getText() if userInput != '': capcode = kb.getText() elif userInput == '': showpopup('BillionUploads','[B]You must enter the text from the image to access video[/B]',5000, elogo) return None else: return None wdlg.close() data.update({'code':capcode}) data.update({'submit_btn':''}) enc_input = re.compile('decodeURIComponent\("(.+?)"\)').findall(html) if enc_input: dec_input = urllib2.unquote(enc_input[0]) r = re.findall(r'type="hidden" name="(.+?)" value="(.*?)">', dec_input) for name, value in r: data[name] = value extradata = re.compile("append\(\$\(document.createElement\('input'\)\).attr\('type','hidden'\).attr\('name','(.*?)'\).val\((.*?)\)").findall(html) if extradata: for attr, val in extradata: if 'source="self"' in val: val = re.compile('<textarea[^>]*?source="self"[^>]*?>([^<]*?)<').findall(html)[0] data[attr] = val.strip("'") r = re.findall("""'input\[name="([^"]+?)"\]'\)\.remove\(\)""", html) for name in r: del data[name] normal.addheaders.append(('Referer', url)) html = normal.open(url, urllib.urlencode(data)).read() cj.save(cookie_file,True) def custom_range(start, end, step): while start <= end: yield start start += step def checkwmv(e): s = "" i=[] u=[[65,91],[97,123],[48,58],[43,44],[47,48]] for z in range(0, len(u)): for n in range(u[z][0],u[z][1]): i.append(chr(n)) t = {} for n in range(0, 64): t[i[n]]=n for n in custom_range(0, len(e), 72): a=0 h=e[n:n+72] c=0 for l in range(0, len(h)): f = t.get(h[l], 'undefined') if f == 'undefined': continue a = (a<<6) + f c = c + 6 while c >= 8: c = c - 8 s = s + chr( (a >> c) % 256 ) return s dll = re.compile('<input type="hidden" id="dl" value="(.+?)">').findall(html) if dll: dl = dll[0].split('GvaZu')[1] dl = checkwmv(dl); dl = checkwmv(dl); else: alt = re.compile('<source src="([^"]+?)"').findall(html) if alt: dl = alt[0] else: raise Exception('Unable to resolve - No Video File Found') return dl except Exception, e: raise
def load_skin(window): #background image window.bg = xbmcgui.ControlImage(0, 0, 720, 576, imageDir + "background.png") window.addControl(window.bg) window.bg1 = xbmcgui.ControlImage(0, 0, 720, 576, imageDir + "background.png") window.addControl(window.bg1) #Navi-X logo at top-right position window.logo = xbmcgui.ControlImage(620, 20, 80, 80, imageDir + "logo.png") window.addControl(window.logo) #user logo above the buttons window.user_logo = xbmcgui.ControlImage(32, 120, 210, 172, imageDir + "logo.png") window.addControl(window.user_logo) window.user_logo.setVisible(0) #user thumb above the buttons (overlaps with the user logo) window.user_thumb = xbmcgui.ControlImage(32, 120, 210, 172, imageDir + "logo.png") window.addControl(window.user_thumb) window.user_thumb.setVisible(0) #downloading state at the bottom of screen window.download_logo = xbmcgui.ControlImage(40, 480, 30, 30, imageDir + "icon_download.png") window.addControl(window.download_logo) window.download_logo.setVisible(0) #URL label at top-center position window.urllbl = xbmcgui.ControlLabel(40, 80, 350, 40, "", "font14") window.addControl(window.urllbl) #Navi-X Version label at top-left position window.version = xbmcgui.ControlLabel( 40, 20, 155, 40, 'version: ' + Version + '.' + SubVersion, "font14") window.addControl(window.version) #"Loading..." text at down-left side window.infotekst = xbmcgui.ControlLabel(60, 520, 250, 30, "Loading...") window.addControl(window.infotekst) window.infotekst.setVisible(0) #"Download progress information..." text at down-left side window.dlinfotekst = xbmcgui.ControlLabel(80, 490, 250, 30, "") window.addControl(window.dlinfotekst) window.dlinfotekst.setVisible(0) #"Please wait..." text displayed on top of the main list window.loading = xbmcgui.ControlLabel(280, 130, 250, 30, "Please wait...") window.addControl(window.loading) window.loading.setVisible(0) #Main lists displaying playlist entries. #Large list 10 entries without text box on top. window.list1 = xbmcgui.ControlList(260, 120, 450, 435, 'font14', '0xFFDDDDDD', buttonFocusTexture=RootDir + 'images\\list-focus.png', imageWidth=32, imageHeight=32, itemHeight=38) window.addControl(window.list1) window.list1.setPageControlVisible(False) #Small list 8 entries with text box on top. window.list2 = xbmcgui.ControlList(260, 210, 450, 345, 'font14', '0xFFDDDDDD', buttonFocusTexture=RootDir + 'images\\list-focus.png', imageWidth=32, imageHeight=32, itemHeight=38) window.addControl(window.list2) window.list2.setPageControlVisible(False) #the text box above main list 2 window.list2tb = xbmcgui.ControlTextBox(270, 115, 420, 85) window.addControl(window.list2tb) window.list2tb.setVisible(0) #set the large list as default window.list = window.list1 #list cursor position label displayed at the bottom right of the screen window.listpos = xbmcgui.ControlLabel(640, 540, 250, 30, "") window.addControl(window.listpos) #buttons creation x = 50 y = 303 window.button_home = xbmcgui.ControlButton( x, y, 120, 32, ' Home', RootDir + "images\\button-focus1.png", RootDir + "images\\button-nofocus1.png") window.addControl(window.button_home) window.button_favorites = xbmcgui.ControlButton( x, y + 32, 120, 32, ' Favorites', RootDir + "images\\button-focus1.png", RootDir + "images\\button-nofocus1.png") window.addControl(window.button_favorites) window.button_downloads = xbmcgui.ControlButton( x, y + 64, 120, 32, ' Downloads', RootDir + "images\\button-focus1.png", RootDir + "images\\button-nofocus1.png") window.addControl(window.button_downloads) window.button_url = xbmcgui.ControlButton( x, y + 96, 120, 32, ' Browse', RootDir + "images\\button-focus1.png", RootDir + "images\\button-nofocus1.png") window.addControl(window.button_url) window.button_about = xbmcgui.ControlButton( x, y + 128, 120, 32, ' About', RootDir + "images\\button-focus1.png", RootDir + "images\\button-nofocus1.png") window.addControl(window.button_about) #button behaviour window.list2tb.controlDown(window.list1) window.button_home.controlDown(window.button_favorites) window.button_favorites.controlDown(window.button_downloads) window.button_downloads.controlDown(window.button_url) window.button_url.controlDown(window.button_about) window.button_about.controlUp(window.button_url) window.button_url.controlUp(window.button_downloads) window.button_downloads.controlUp(window.button_favorites) window.button_favorites.controlUp(window.button_home) window.button_home.controlUp(window.list2tb) window.button_home.controlRight(window.list1) window.button_favorites.controlRight(window.list1) window.button_downloads.controlRight(window.list1) window.button_url.controlRight(window.list1) window.button_about.controlRight(window.list1) window.list1.controlLeft(window.button_home) window.list2.controlLeft(window.button_home) window.list2tb.controlLeft(window.button_home)
def viewTallImage(image_url, width, height): log('viewTallImage %s: %sx%s' % (image_url, width, height)) #image_url=unescape(image_url) #special case for handling reddituploads urls #log( 'viewTallImage %s: %sx%s' %(image_url, width, height)) xbmc_busy(False) can_quit = True if can_quit == True: useWindow = xbmcgui.WindowDialog() useWindow.setCoordinateResolution(0) try: w = int(float(width)) h = int(float(height)) optimal_h = int(h * 1.5) #log( ' **' + repr(h)) loading_img = xbmc.validatePath('/'.join( (addon_path, 'resources', 'skins', 'Default', 'media', 'srr_busy.gif'))) img_control = xbmcgui.ControlImage( 0, 800, 1920, optimal_h, '', aspectRatio=2 ) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars) img_loading = xbmcgui.ControlImage(1820, 0, 100, 100, loading_img, aspectRatio=2) #the cached image is of lower resolution. we force nocache by using setImage() instead of defining the image in ControlImage() img_control.setImage(image_url, False) useWindow.addControls([img_loading, img_control]) #useWindow.addControl( img_control ) scroll_time = (int(h) / int(w)) * 20000 img_control.setAnimations([ ('conditional', "condition=true effect=fade delay=0 start=0 end=100 time=4000 " ), ('conditional', "condition=true effect=slide delay=2000 start=0,-%d end=0,0 tween=sine easing=in time=%d pulse=true" % ((h * 1.4), scroll_time)), ]) useWindow.doModal() useWindow.removeControls([img_control, img_loading]) del useWindow except Exception as e: log(" EXCEPTION viewTallImage:=" + str(sys.exc_info()[0]) + " " + str(e)) else: # can be done this way but can't get keypress to exit animation useWindow = xbmcgui.Window(xbmcgui.getCurrentWindowId()) xbmc_busy(False) w = int(float(width)) h = int(float(height)) optimal_h = int(h * 1.5) #log( ' **' + repr(h)) loading_img = xbmc.validatePath('/'.join( (addon_path, 'resources', 'skins', 'Default', 'media', 'srr_busy.gif'))) img_control = xbmcgui.ControlImage( 0, 1080, 1920, optimal_h, '', aspectRatio=2 ) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars) img_loading = xbmcgui.ControlImage(1820, 0, 100, 100, loading_img, aspectRatio=2) #the cached image is of lower resolution. we force nocache by using setImage() instead of defining the image in ControlImage() img_control.setImage(image_url, False) useWindow.addControls([img_loading, img_control]) scroll_time = int(h) * (int(h) / int(w)) * 10 img_control.setAnimations([ ('conditional', "condition=true effect=fade delay=0 start=0 end=100 time=4000 " ), ('conditional', "condition=true effect=slide delay=2000 start=0,0 end=0,-%d time=%d pulse=true" % ((h * 1.6), scroll_time)), ('conditional', "condition=true effect=fade delay=%s start=100 end=0 time=2000 " % (scroll_time * 1.8)), ]) xbmc.sleep(scroll_time * 2) useWindow.removeControls([img_control, img_loading])
def Captcha_Get_Reponse(img, cookie): #on telecharge l'image PathCache = xbmc.translatePath( xbmcaddon.Addon('plugin.video.vstream').getAddonInfo("profile")) filename = os.path.join(PathCache, 'Captcha.raw').decode("utf-8") headers2 = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0', #'Referer' : url , 'Host': 'protect.ddl-island.su', 'Accept': 'image/png,image/*;q=0.8,*/*;q=0.5', 'Accept-Language': 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept-Encoding': 'gzip, deflate', #'Content-Type' : 'application/x-www-form-urlencoded', } if cookie: headers2['Cookie'] = cookie try: req = urllib2.Request(img, None, headers2) image_on_web = urllib2.urlopen(req) if image_on_web.headers.maintype == 'image': buf = image_on_web.read() downloaded_image = file(filename, "wb") downloaded_image.write(buf) downloaded_image.close() image_on_web.close() else: return '' except: return '' #on affiche le dialogue solution = '' if (NewMethod): ####nouveau captcha try: ##affichage du dialog perso class XMLDialog(xbmcgui.WindowXMLDialog): #""" #Dialog class for captcha #""" def __init__(self, *args, **kwargs): xbmcgui.WindowXMLDialog.__init__(self) pass def onInit(self): #image background captcha self.getControl(1).setImage(filename.encode("utf-8"), False) #image petit captcha memory fail self.getControl(2).setImage(filename.encode("utf-8"), False) self.getControl(2).setVisible(False) ##Focus clavier self.setFocus(self.getControl(21)) def onClick(self, controlId): if controlId == 20: #button Valider solution = self.getControl(5000).getLabel() xbmcgui.Window(10101).setProperty( 'captcha', str(solution)) self.close() return elif controlId == 30: #button fermer self.close() return elif controlId == 21: #button clavier self.getControl(2).setVisible(True) kb = xbmc.Keyboard( self.getControl(5000).getLabel(), '', False) kb.doModal() if (kb.isConfirmed()): self.getControl(5000).setLabel(kb.getText()) self.getControl(2).setVisible(False) else: self.getControl(2).setVisible(False) def onFocus(self, controlId): self.controlId = controlId def _close_dialog(self): self.close() def onAction(self, action): #touche return 61448 if action.getId() in (9, 10, 11, 30, 92, 216, 247, 257, 275, 61467, 61448): self.close() wd = XMLDialog('DialogCaptcha.xml', cConfig().getAddonPath().decode("utf-8"), 'default', '720p') wd.doModal() del wd finally: solution = xbmcgui.Window(10101).getProperty('captcha') if solution == '': cConfig().showInfo("Erreur", 'Vous devez taper le captcha', 4) else: #ancien Captcha try: img = xbmcgui.ControlImage(450, 0, 400, 130, filename.encode("utf-8")) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() #xbmc.sleep(3000) kb = xbmc.Keyboard('', 'Tapez les Lettres/chiffres de l\'image', False) kb.doModal() if (kb.isConfirmed()): solution = kb.getText() if solution == '': cConfig().showInfo("Erreur", 'Vous devez taper le captcha', 4) else: cConfig().showInfo("Erreur", 'Vous devez taper le captcha', 4) finally: wdlg.removeControl(img) wdlg.close() return solution
def __init__(self, *args, **kwargs): logger.debug() #### Compatibilidad con Kodi 18 #### if config.get_platform(True)['num_version'] < 18: if xbmcgui.__version__ == "1.2": self.setCoordinateResolution(1) else: self.setCoordinateResolution(5) self.show = kwargs.get("show") self.channel = kwargs.get("channel") self.data = kwargs.get("data") self.init = True self.mediapath = os.path.join(config.get_runtime_path(), 'resources', 'skins', 'Default', 'media') self.font = "font12" window_bg = xbmcgui.ControlImage( 320, 130, 600, 440, os.path.join(self.mediapath, 'Windows', 'DialogBack.png')) self.addControl(window_bg) header_bg = xbmcgui.ControlImage( window_bg.getX(), window_bg.getY() + 8, window_bg.getWidth(), 35, os.path.join(self.mediapath, 'Windows', 'dialogheader.png')) self.addControl(header_bg) btn_close_w = 64 self.btn_close = xbmcgui.ControlButton( window_bg.getX() + window_bg.getWidth() - btn_close_w - 13, header_bg.getY() + 6, btn_close_w, 30, '', focusTexture=os.path.join(self.mediapath, 'Controls', 'DialogCloseButton-focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'DialogCloseButton.png')) self.addControl(self.btn_close) header_title_x = window_bg.getX() + 20 header_title = xbmcgui.ControlFadeLabel(header_title_x, header_bg.getY() + 5, self.btn_close.getX() - header_title_x, 30, font="font12_title", textColor="0xFFFFA500", _alignment=ALIGN_CENTER) self.addControl(header_title) header_title.addLabel(self.show) self.controls_bg = xbmcgui.ControlImage( window_bg.getX() + 20, header_bg.getY() + header_bg.getHeight() + 6, 562, 260, os.path.join(self.mediapath, 'Windows', 'BackControls.png')) self.addControl(self.controls_bg) self.scroll_bg = xbmcgui.ControlImage( window_bg.getX() + window_bg.getWidth() - 25, self.controls_bg.getY(), 10, self.controls_bg.getHeight(), os.path.join(self.mediapath, 'Controls', 'ScrollBack.png')) self.addControl(self.scroll_bg) self.scroll_bg.setVisible(False) self.scroll2_bg = xbmcgui.ControlImage( window_bg.getX() + window_bg.getWidth() - 25, self.controls_bg.getY(), 10, self.controls_bg.getHeight(), os.path.join(self.mediapath, 'Controls', 'ScrollBar.png')) self.addControl(self.scroll2_bg) self.scroll2_bg.setVisible(False) btn_add_season = xbmcgui.ControlButton( window_bg.getX() + 20, self.controls_bg.getY() + self.controls_bg.getHeight() + 14, 165, 30, 'Añadir Temporada', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(btn_add_season) self.btn_info = xbmcgui.ControlButton( window_bg.getX() + 210, btn_add_season.getY(), 120, 30, 'Información', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_info) check_update_internet_w = 235 # Versiones antiguas no admite algunas texturas if xbmcgui.__version__ in ["1.2", "2.0"]: self.check_update_internet = xbmcgui.ControlRadioButton( window_bg.getX() + window_bg.getWidth() - check_update_internet_w - 20, btn_add_season.getY() - 3, check_update_internet_w, 34, "Actualizar desde Internet:", font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png')) else: self.check_update_internet = xbmcgui.ControlRadioButton( window_bg.getX() + window_bg.getWidth() - check_update_internet_w - 20, btn_add_season.getY() - 3, check_update_internet_w, 34, "Actualizar desde Internet:", font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'), focusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), noFocusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), focusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png'), noFocusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png')) self.addControl(self.check_update_internet) self.check_update_internet.setEnabled(False) hb_bg = xbmcgui.ControlImage( window_bg.getX() + 20, btn_add_season.getY() + btn_add_season.getHeight() + 13, window_bg.getWidth() - 40, 2, os.path.join(self.mediapath, 'Controls', 'ScrollBack.png')) self.addControl(hb_bg) self.btn_ok = xbmcgui.ControlButton( window_bg.getX() + 68, hb_bg.getY() + hb_bg.getHeight() + 13, 120, 30, 'OK', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_ok) self.btn_cancel = xbmcgui.ControlButton( self.btn_info.getX() + 30, self.btn_ok.getY(), 120, 30, 'Cancelar', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_cancel) self.btn_delete = xbmcgui.ControlButton( self.btn_cancel.getX() + self.btn_cancel.getWidth() + 50, self.btn_ok.getY(), 120, 30, 'Borrar', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_delete) self.controls = [] self.onInit() self.setFocus(self.controls[0].edit_season) self.doModal()
def __init__(self, noteType='t', noteMessage='', noteImage='', L=140, T=110, W=1000, H=500, Font='font14', TxtColor='0xFF64d1ff', logo='', firstButtonText="Ok", secondButtonText="Cancel"): if len(noteImage) == 0: noteImage = DefaultWindow.DefaultNoteImage if (noteType.lower() == 'text') or (noteType.lower() == 't'): noteType = 't' elif (noteType.lower() == 'image') or (noteType.lower() == 'i'): noteType = 'i' self.noteType = noteType self.noteMessage = noteMessage self.noteImage = noteImage self.Font = Font self.TxtColor = TxtColor self.background = XBMCUtils.getAddonFilePath( 'resources/images/ContentPanel.png') self.BG = xbmcgui.ControlImage(L, T, W, H, self.background, aspectRatio=0, colorDiffuse='0xFF3030FF') if logo == '': logo = XBMCUtils.getAddonFilePath('icon.png') iLogoW = 68 iLogoH = 68 self.iLogo = xbmcgui.ControlImage((L + (W / 2)) - (iLogoW / 2), T + 10, iLogoW, iLogoH, logo, aspectRatio=0) L2 = 200 T2 = 200 W2 = 880 H2 = 340 L3 = L2 + 5 T3 = T2 + 60 W3 = W2 - 18 H3 = H2 - 5 - 60 self.ImgMessage = xbmcgui.ControlImage(L2, T2, W2, H2, self.noteImage, aspectRatio=0) self.TxtMessage = xbmcgui.ControlTextBox(L2 + 5, T2, W2 - 10, H2, font=self.Font, textColor=self.TxtColor) focus = XBMCUtils.getAddonFilePath( 'resources/images/button-focus_lightblue.png') nofocus = XBMCUtils.getAddonFilePath( 'resources/images/button-focus_grey.png') w1 = 120 h1 = 35 w2 = 160 h2 = 35 spacing1 = 20 l2 = L + W - spacing1 - w2 t2 = T + H - h2 - spacing1 l1 = L + W - spacing1 - w2 - spacing1 - w1 t1 = T + H - h1 - spacing1 self.firstButton = xbmcgui.ControlButton(l1, t1, w1, h1, firstButtonText, textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=focus, noFocusTexture=nofocus) self.secondButton = xbmcgui.ControlButton(l2, t2, w2, h2, secondButtonText, textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=focus, noFocusTexture=nofocus) for z in [ self.BG, self.ImgMessage, self.TxtMessage, self.iLogo, self.secondButton, self.firstButton ]: self.addControl(z) for z in [ self.BG, self.ImgMessage, self.TxtMessage, self.iLogo, self.secondButton, self.firstButton ]: z.setAnimations([('WindowOpen', 'effect=fade delay=0 time=1000 start=0 end=100'), ('WindowClose', 'effect=slide delay=0 time=1000 start=0 end=0,' + str(0 - (H + T + 10)))]) self.secondButton.controlLeft(self.firstButton) self.secondButton.controlRight(self.firstButton) self.firstButton.controlLeft(self.secondButton) self.firstButton.controlRight(self.secondButton) self.TxtMessage.setText(self.noteMessage) self.TxtMessage.autoScroll( 20000, 2500, 15000 ) #all in ms -> delay, scroll speed (less is faster), repeat time self.setFocus(self.secondButton)
def onInit(self, *args, **kwargs): try: # listado temporada / episodios pos_y = self.controls_bg.getY() + 10 # eliminamos los componentes al repintar la ventana for linea in self.controls: self.removeControls(linea.list_elements()) # mostramos el scroll si hay más de 5 elementos if len(self.data) > 5: self.controls_bg.setWidth(545) self.scroll_bg.setVisible(True) self.scroll2_bg.setVisible(True) else: self.controls_bg.setWidth(562) self.scroll_bg.setVisible(False) self.scroll2_bg.setVisible(False) self.controls = [] # cambiamos el orden para que se vea en orden ascendente self.data.sort(key=lambda el: int(el[0]), reverse=False) for index, e in enumerate(self.data): pos_x = self.controls_bg.getX() + 15 label_season_w = 100 label_season = xbmcgui.ControlLabel(pos_x, pos_y + 3, label_season_w, 34, "Temporada:", font=self.font, textColor="0xFF2E64FE") self.addControl(label_season) label_season.setVisible(False) pos_x += label_season_w + 5 # TODO mirar retro-compatilibidad # if xbmcgui.ControlEdit == ControlEdit: # edit_season = xbmcgui.ControlEdit(0, 0, 0, 0, '', font=self.font, isPassword=False, # textColor='', # focusTexture=os.path.join(self.mediapath, 'Controls', # 'MenuItemFO.png'), # noFocusTexture=os.path.join(self.mediapath, 'Controls', # 'MenuItemNF.png'), window=self) # else: # control bugeado se tiene que usar metodos sets para que se cree correctamente. edit_season = xbmcgui.ControlEdit( 0, 0, 0, 0, "", self.font, "", '', 4, isPassword=False, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png')) self.addControl(edit_season) edit_season.setText(str(e[0])) # edit_season.setLabel("Temporada:", font=self.font, textColor="0xFF2E64FE") edit_season.setPosition(pos_x, pos_y - 2) edit_season.setWidth(25) edit_season.setHeight(35) edit_season.setVisible(False) label_episode_w = 90 pos_x += edit_season.getWidth() + 60 label_episode = xbmcgui.ControlLabel( pos_x, pos_y + 3, label_episode_w, 34, "Episodios:", font=self.font, textColor="0xFF2E64FE") self.addControl(label_episode) label_episode.setVisible(False) pos_x += label_episode_w + 5 # control bugeado se tiene que usar metodos sets para que se cree correctamente. edit_episode = xbmcgui.ControlEdit( 0, 0, 0, 0, "", self.font, "", '', 4, isPassword=False, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png')) self.addControl(edit_episode) edit_episode.setText(str(e[1])) # edit_episode.setLabel("Episodios:", font=self.font, textColor="0xFF2E64FE") edit_episode.setPosition(pos_x, pos_y - 2) edit_episode.setWidth(40) edit_episode.setHeight(35) edit_episode.setVisible(False) btn_delete_season_w = 120 btn_delete_season = xbmcgui.ControlButton( self.controls_bg.getX() + self.controls_bg.getWidth() - btn_delete_season_w - 14, pos_y, btn_delete_season_w, 30, 'Eliminar', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(btn_delete_season) btn_delete_season.setVisible(False) hb_bg = xbmcgui.ControlImage( self.controls_bg.getX() + 10, pos_y + 40, self.controls_bg.getWidth() - 20, 2, os.path.join(self.mediapath, 'Controls', 'ScrollBack.png')) self.addControl(hb_bg) hb_bg.setVisible(False) group = ControlGroup(label_season=label_season, edit_season=edit_season, label_episode=label_episode, edit_episode=edit_episode, btn_delete_season=btn_delete_season, hb=hb_bg) pos_y += 50 if index < 5: group.set_visible(True) self.controls.append(group) if len(self.data) > 5: self.move_scroll() except Exception as Ex: logger.error("HA HABIDO UNA HOSTIA %s" % Ex)
def __init__(self): if Emulating: xbmcgui.Window.__init__(self) self.X = (float(self.getWidth()) / float(720)) self.Y = (float(self.getHeight()) / float(480)) self.saves = [] self.status = "SAVE" if not os.path.exists(ROOT_DIR): os.makedirs(ROOT_DIR) if not os.path.exists(TRAINER_DIR): os.makedirs(ROOT_DIR) self.addControl( xbmcgui.ControlImage(0, 0, int(720 * self.X), int(480 * self.Y), "background.png")) self.list = xbmcgui.ControlList(int(211 * self.X), int(100 * self.Y), int(450 * self.X), int(350 * self.Y)) self.btnSearch = xbmcgui.ControlButton(int(60 * self.X), int(100 * self.Y), int(140 * self.X), int(30 * self.Y), "Search") self.btnRestore = xbmcgui.ControlButton(int(60 * self.X), int(132 * self.Y), int(140 * self.X), int(30 * self.Y), "Restore") self.btnClear = xbmcgui.ControlButton(int(60 * self.X), int(164 * self.Y), int(140 * self.X), int(30 * self.Y), "Clear Backup") self.btnTrainer = xbmcgui.ControlButton(int(60 * self.X), int(228 * self.Y), int(140 * self.X), int(30 * self.Y), "Trainers") self.btnOptions = xbmcgui.ControlButton(int(60 * self.X), int(260 * self.Y), int(140 * self.X), int(30 * self.Y), "Options") self.addControl(self.list) self.addControl(self.btnSearch) self.addControl(self.btnRestore) self.addControl(self.btnClear) self.addControl(self.btnTrainer) self.addControl(self.btnOptions) self.list.controlLeft(self.btnSearch) self.btnSearch.controlUp(self.btnOptions) self.btnSearch.controlDown(self.btnRestore) self.btnSearch.controlRight(self.list) self.btnRestore.controlUp(self.btnSearch) self.btnRestore.controlDown(self.btnClear) self.btnRestore.controlRight(self.list) self.btnClear.controlUp(self.btnRestore) self.btnClear.controlDown(self.btnTrainer) self.btnClear.controlRight(self.list) self.btnTrainer.controlUp(self.btnClear) self.btnTrainer.controlDown(self.btnOptions) self.btnTrainer.controlRight(self.list) self.btnOptions.controlUp(self.btnTrainer) self.btnOptions.controlDown(self.btnSearch) self.btnOptions.controlRight(self.list) self.setFocus(self.btnSearch)
def __init__(self): self.addControl( xbmcgui.ControlImage( 0, 0, 1280, 720, '/home/vader/.xbmc/scripts/helpMenu/helpMenuBackground.jpg')) # Top Menu Text self.strActionInfo = xbmcgui.ControlLabel(570, 60, 200, 200, 'Help Menu', 'Font_Bold35', '0xFF000000') self.addControl(self.strActionInfo) self.strActionInfo = xbmcgui.ControlLabel(550, 100, 300, 200, 'Select a Topic', 'Font_Bold35', '0xFF000000') self.addControl(self.strActionInfo) #Location & size of source buttons self.gettingStartedButton = xbmcgui.ControlButton( 300, 150, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/gettingStartedIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTgettingStartedIcon.jpg' ) self.addControl(self.gettingStartedButton) self.iptvButton = xbmcgui.ControlButton( 300, 275, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/iptvIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTiptvIcon.jpg') self.addControl(self.iptvButton) self.imagesButton = xbmcgui.ControlButton( 300, 400, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/imagesIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTimagesIcon.jpg' ) self.addControl(self.imagesButton) self.videosButton = xbmcgui.ControlButton( 300, 525, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/videosIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTvideosIcon.jpg' ) self.addControl(self.videosButton) self.remoteButton = xbmcgui.ControlButton( 650, 150, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/remoteIcon2.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTremoteIcon2.jpg' ) self.addControl(self.remoteButton) self.sourceButton = xbmcgui.ControlButton( 650, 275, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/sourceIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTsourceIcon.jpg' ) self.addControl(self.sourceButton) self.documentsButton = xbmcgui.ControlButton( 650, 400, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/documentsIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTdocumentsIcon.jpg' ) self.addControl(self.documentsButton) self.webControlButton = xbmcgui.ControlButton( 650, 525, 350, 125, '', textOffsetY=20, textColor='0xFF000000', focusedColor='0xFF000000', noFocusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/webIcon.jpg', focusTexture= '/home/vader/.xbmc/scripts/helpMenu/MainMenuIcons/FTwebIcon.jpg') self.addControl(self.webControlButton) #Start flashing icon on Projector Icon self.setFocus(self.gettingStartedButton) #Moves buttons can make self.gettingStartedButton.controlLeft(self.remoteButton) self.gettingStartedButton.controlRight(self.remoteButton) self.gettingStartedButton.controlUp(self.videosButton) self.gettingStartedButton.controlDown(self.iptvButton) self.iptvButton.controlLeft(self.sourceButton) self.iptvButton.controlRight(self.sourceButton) self.iptvButton.controlUp(self.gettingStartedButton) self.iptvButton.controlDown(self.imagesButton) self.imagesButton.controlLeft(self.documentsButton) self.imagesButton.controlRight(self.documentsButton) self.imagesButton.controlUp(self.iptvButton) self.imagesButton.controlDown(self.videosButton) self.videosButton.controlLeft(self.webControlButton) self.videosButton.controlRight(self.webControlButton) self.videosButton.controlUp(self.imagesButton) self.videosButton.controlDown(self.gettingStartedButton) self.remoteButton.controlLeft(self.gettingStartedButton) self.remoteButton.controlRight(self.gettingStartedButton) self.remoteButton.controlUp(self.webControlButton) self.remoteButton.controlDown(self.sourceButton) self.sourceButton.controlLeft(self.iptvButton) self.sourceButton.controlRight(self.iptvButton) self.sourceButton.controlUp(self.remoteButton) self.sourceButton.controlDown(self.documentsButton) self.documentsButton.controlLeft(self.imagesButton) self.documentsButton.controlRight(self.imagesButton) self.documentsButton.controlUp(self.sourceButton) self.documentsButton.controlDown(self.webControlButton) self.webControlButton.controlLeft(self.videosButton) self.webControlButton.controlRight(self.videosButton) self.webControlButton.controlUp(self.documentsButton) self.webControlButton.controlDown(self.remoteButton)
def onInit(self): utils.log('onInit') utils.setProperty('uEPGRunning', 'True') self.closeCount = 0 curtime = time.time() self.lastActTime = time.time() self.windowID = self.getWindowID() self.windowIDS = [ "ActivateWindow(fullscreenvideo)", "ActivateWindow(%s)" % self.windowID ] self.windowToggle = itertools.cycle(self.windowIDS).next if self.onInitReturn == False: utils.log('onInit, onInitReturn = False') self.guideLimit = 14400 self.rowCount = self.chkRows(self.rowCount) self.epgButtonwidth = float((utils.getProperty("uEPG.buttonWidth")) or "5400.0") self.timeCount = int((utils.getProperty("uEPG.timeCount")) or "3") self.textColor = hex( int((utils.getProperty("uEPG.textColor") or "0xFFFFFFFF"), 16))[2:] self.disabledColor = hex( int((utils.getProperty("uEPG.disabledColor") or "0xFFFFFFFF"), 16))[2:] self.focusedColor = hex( int((utils.getProperty("uEPG.focusedColor") or "0xFFFFFFFF"), 16))[2:] self.shadowColor = hex( int((utils.getProperty("uEPG.shadowColor") or "0xFF000000"), 16))[2:] self.pastColor = hex( int((utils.getProperty("uEPG.pastColor") or "0xFF0f85a5"), 16))[2:] self.timeColor = hex( int((utils.getProperty("uEPG.timeColor") or "0xFF0f85a5"), 16))[2:] self.futureColor = hex( int((utils.getProperty("uEPG.futureColor") or "0xFF0f85a5"), 16))[2:] self.singleLineFade = (utils.getProperty("uEPG.singleLineFade") or "false") == "true" self.textFont = (utils.getProperty("uEPG.timeCount") or "font12") self.timeFormat = (utils.getProperty("uEPG.timeFormat") or "%A, %B %d") self.clockMode = int(utils.REAL_SETTINGS.getSetting("ClockMode")) self.channelButtons = [None] * self.rowCount for i in range(self.rowCount): self.channelButtons[i] = [] try: self.removeControl(self.fadePast) self.removeControl(self.currentTimeBar) except: pass self.focusChannel = self.getControl(33009) self.currentHighLT = self.getControl(33010) self.currentTime = self.getControl(33007) timetx, timety = self.currentTime.getPosition() timetw = self.currentTime.getWidth() timeth = self.currentTime.getHeight() self.currentLine = self.getControl(33013) timex, timey = self.currentLine.getPosition() timew = self.currentLine.getWidth() timeh = self.currentLine.getHeight() self.timeButtonBar = os.path.join(self.channelLST.mediaFolder, utils.TIME_BAR) self.currentTimeBar = xbmcgui.ControlImage( timex, timey, timew, timeh, self.timeButtonBar, colorDiffuse=self.timeColor) self.addControl(self.currentTimeBar) self.pastLine = self.getControl(33011) timex, timey = self.pastLine.getPosition() timew = self.pastLine.getWidth() timeh = self.pastLine.getHeight() self.pastTime = os.path.join(self.channelLST.mediaFolder, utils.PAST_FADE) self.fadePast = xbmcgui.ControlImage(timex, timey, timew, timeh, self.pastTime, colorDiffuse=self.pastColor) self.addControl(self.fadePast) self.futureLine = self.getControl(33012) timex, timey = self.futureLine.getPosition() timew = self.futureLine.getWidth() timeh = self.futureLine.getHeight() self.futureTime = os.path.join(self.channelLST.mediaFolder, utils.FUTURE_FADE) self.fadeFuture = xbmcgui.ControlImage( timex, timey, timew, timeh, self.futureTime, colorDiffuse=self.futureColor) self.addControl(self.fadeFuture) self.TimeXYW = {} for i in range(self.timeCount): self.TimeXYW['Time%dX' % (i + 1)] = self.getControl(33101 + i).getPosition()[0] self.TimeXYW['Time%dY' % (i + 1)] = self.getControl(33101 + i).getPosition()[1] self.TimeXYW['Time%dW' % (i + 1)] = int( round(self.getControl(33101 + i).getWidth() // 2)) self.TimeRange = {} for i in range(self.timeCount): self.TimeRange['Time%dRange' % (i + 1)] = range( self.TimeXYW['Time%dX' % (i + 1)] - self.TimeXYW['Time%dW' % (i + 1)], self.TimeXYW['Time%dX' % (i + 1)] + self.TimeXYW['Time%dW' % (i + 1)]) if self.setChannelButtons(curtime, self.fixChannel( self.currentChannel)) == False: utils.log('Unable to add channel buttons') utils.notificationDialog( "%s Error, Contact %s for support" % (self.channelLST.pluginName, self.channelLST.pluginAuthor)) self.closeUEPG() self.setChannelButtons(curtime, self.fixChannel(self.currentChannel)) basex, basey = self.getControl(33611 + self.focusRow).getPosition() basew = self.getControl(33611 + self.focusRow).getWidth() for i in range(len(self.channelButtons[self.focusRow])): left, top = self.channelButtons[self.focusRow][i].getPosition() width = self.channelButtons[self.focusRow][i].getWidth() left = left - basex starttime = self.shownTime + (left / (basew / self.epgButtonwidth)) endtime = starttime + (width / (basew / self.epgButtonwidth)) if curtime >= starttime and curtime <= endtime: utils.log('curtime focusIndex = %s' % i) self.focusIndex = i self.setFocus(self.channelButtons[self.focusRow][i]) self.focusTime = int(curtime) self.focusEndTime = endtime break if self.focusIndex == -1: self.focusIndex = 0 self.setFocus(self.channelButtons[self.focusRow][self.focusIndex]) left, top = self.channelButtons[self.focusRow][ self.focusIndex].getPosition() width = self.channelButtons[self.focusRow][ self.focusIndex].getWidth() left = left - basex starttime = self.shownTime + (left / (basew / self.epgButtonwidth)) endtime = starttime + (width / (basew / self.epgButtonwidth)) self.focusTime = int(starttime + 30) self.focusEndTime = endtime self.setProperButton(0) self.setShowInfo() self.onInitReturn = True utils.log('onInit return')
def addCitiesPosition(self, cities): oldimages = self.listimages.values() if oldimages: try: self.windowback.removeControls(oldimages) except: for image in oldimages: try: self.windowback.removeControl(image) except: pass oldicons = self.listicons.values() if oldicons: try: self.windowback.removeControls(oldicons) except: for icon in oldicons: try: self.windowback.removeControl(icon) except: pass self.listimages = {} self.listicons = {} showcities = xbmc.getCondVisibility( "StringCompare(Window.Property(showcitieslayout),1)") if showcities: rects = {} for city in cities: try: lat, long = city["coords"]["lat"][1], city["coords"][ "long"][1] posx, posy = self.getPosition(float(lat), float(long), self.mapwidth, self.mapheight) self.listimages[lat + long] = xbmcgui.ControlImage( posx - 4, posy - 4, 8, 8, self.pointer, colorDiffuse="0x" + self.colorDiffuse) layout = (posx - 10, posy - 10, 20, 20) rect = Rect(*layout) if not rect.collidedictall(rects): # copy icon to cache, because linux not show icon with http://, on windows it's OK with url !!! city["icon"] = self.getIconCache(city["icon"]) self.listicons[lat + long] = xbmcgui.ControlImage( *layout, filename=city["icon"]) rects[lat + long] = rect except: pass #print city[ "icon" ] if self.listicons: icons = self.listicons.values() try: self.windowback.addControls(icons) for icon in icons: icon.setVisibleCondition( "StringCompare(Window.Property(showcitiesicons),1)") except: print_exc() for icon in icons: try: self.windowback.addControl(icons) icon.setVisibleCondition( "StringCompare(Window.Property(showcitiesicons),1)" ) except: print_exc() if self.listimages: images = self.listimages.values() try: self.windowback.addControls(images) for image in images: image.setVisibleCondition( "StringCompare(Window.Property(showcities),1)") except: print_exc() for image in images: try: self.windowback.addControl(image) image.setVisibleCondition( "StringCompare(Window.Property(showcities),1)") except: print_exc()
def __init__(self, control, ctype, coords=(0, 0), anim=[], **kwargs): self.SKINS_PATH = os.path.join(addonDir, "resources", "skins") self.ADDON_SKIN = ("default", XBMC_SKIN)[os.path.exists( os.path.join(self.SKINS_PATH, XBMC_SKIN))] self.MEDIA_PATH = os.path.join(self.SKINS_PATH, self.ADDON_SKIN, "media") self.controlXML = control # from self.getControl(2001) self.id = self.controlXML.getId() self.label = xbmc.getInfoLabel("Control.GetLabel(%i)" % self.id) self.anim = anim try: extra = dict([k.split("=") for k in self.label.split(",")]) except: extra = {} option = {} x, y, w, h = self.getCoords(coords) # HERE! print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA self.controlXML: " + repr( type(self.controlXML)) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA self.controlXML: " + repr( self.controlXML) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlImage: " + repr( xbmcgui.ControlImage) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlLabel: " + repr( xbmcgui.ControlLabel) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlProgress: " + repr( xbmcgui.ControlProgress) if type(self.controlXML) == xbmcgui.ControlImage or ctype == 0: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlImage texture = self.label valideOption = "colorKey, aspectRatio, colorDiffuse".split(", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key == "texture": texture = value if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "aspectRatio" and value.isdigit(): option[key] = int(value) texture = self.getTexture(texture) # ControlImage(x, y, width, height, filename[, colorKey, aspectRatio, colorDiffuse]) self.control = xbmcgui.ControlImage(x, y, w, h, texture, **option) elif type(self.controlXML) == xbmcgui.ControlLabel or ctype == 1: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlLabel valideOption = "font, textColor, disabledColor, alignment, hasPath, angle".split( ", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "alignment": option[key] = self.getAlignment(value) elif key == "hasPath" and value == "true": option[key] = True elif key == "angle" and value.isdigit(): option[key] = int(value) # ControlLabel(x, y, width, height, label[, font, textColor, disabledColor, alignment, hasPath, angle]) self.control = xbmcgui.ControlLabel(x, y, w, h, "", **option) elif type(self.controlXML) == xbmcgui.ControlProgress or ctype == 2: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlProgress valideOption = "texturebg, textureleft, texturemid, textureright, textureoverlay".split( ", ") for key, value in kwargs.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = self.getTexture(value) # ControlProgress(x, y, width, height[, texturebg, textureleft, texturemid, textureright, textureoverlay]) self.control = xbmcgui.ControlProgress(x, y, w, h, **option) else: print "ERROR TRACEBACK BLAA. no match for self.controlXML: " + repr( self.controlXML)
def __init__(self, *args, **kwargs): bg_image = os.path.join(common.addon_path, 'resources', 'images', 'DialogBack2.png') check_image = os.path.join(common.addon_path, 'resources', 'images', 'checked.png') button_fo = os.path.join(common.kodi.get_path(), 'resources', 'skins', 'Default', 'media', 'button-fo.png') button_nofo = os.path.join(common.kodi.get_path(), 'resources', 'skins', 'Default', 'media', 'button-nofo.png') self.cancelled = False self.chk = [0] * 9 self.chkbutton = [0] * 9 self.chkstate = [False] * 9 imgX, imgY, imgw, imgh = 436, 210, 408, 300 ph, pw = imgh / 3, imgw / 3 x_gap = 70 y_gap = 70 button_gap = 40 button_h = 40 button_y = imgY + imgh + button_gap middle = imgX + (imgw / 2) win_x = imgX - x_gap win_y = imgY - y_gap win_h = imgh + 2 * y_gap + button_h + button_gap win_w = imgw + 2 * x_gap ctrlBackgound = xbmcgui.ControlImage(win_x, win_y, win_w, win_h, bg_image) self.addControl(ctrlBackgound) self.msg = '[COLOR red]%s[/COLOR]' % (kwargs.get('msg')) self.strActionInfo = xbmcgui.ControlLabel(imgX, imgY - 30, imgw, 20, self.msg, 'font13') self.addControl(self.strActionInfo) img = xbmcgui.ControlImage(imgX, imgY, imgw, imgh, kwargs.get('captcha')) self.addControl(img) self.iteration = kwargs.get('iteration') self.strActionInfo = xbmcgui.ControlLabel( imgX, imgY + imgh, imgw, 20, common.i18n('captcha_round') % (str(self.iteration)), 'font40') self.addControl(self.strActionInfo) self.cancelbutton = xbmcgui.ControlButton(middle - 110, button_y, 100, button_h, common.i18n('cancel'), focusTexture=button_fo, noFocusTexture=button_nofo, alignment=2) self.okbutton = xbmcgui.ControlButton(middle + 10, button_y, 100, button_h, common.i18n('ok'), focusTexture=button_fo, noFocusTexture=button_nofo, alignment=2) self.addControl(self.okbutton) self.addControl(self.cancelbutton) for i in xrange(9): row = i / 3 col = i % 3 x_pos = imgX + (pw * col) y_pos = imgY + (ph * row) self.chk[i] = xbmcgui.ControlImage(x_pos, y_pos, pw, ph, check_image) self.addControl(self.chk[i]) self.chk[i].setVisible(False) self.chkbutton[i] = xbmcgui.ControlButton( x_pos, y_pos, pw, ph, str(i + 1), font='font1', focusTexture=button_fo, noFocusTexture=button_nofo) self.addControl(self.chkbutton[i]) for i in xrange(9): row_start = (i / 3) * 3 right = row_start + (i + 1) % 3 left = row_start + (i - 1) % 3 up = (i - 3) % 9 down = (i + 3) % 9 self.chkbutton[i].controlRight(self.chkbutton[right]) self.chkbutton[i].controlLeft(self.chkbutton[left]) if i <= 2: self.chkbutton[i].controlUp(self.okbutton) else: self.chkbutton[i].controlUp(self.chkbutton[up]) if i >= 6: self.chkbutton[i].controlDown(self.okbutton) else: self.chkbutton[i].controlDown(self.chkbutton[down]) self.okbutton.controlLeft(self.cancelbutton) self.okbutton.controlRight(self.cancelbutton) self.cancelbutton.controlLeft(self.okbutton) self.cancelbutton.controlRight(self.okbutton) self.okbutton.controlDown(self.chkbutton[2]) self.okbutton.controlUp(self.chkbutton[8]) self.cancelbutton.controlDown(self.chkbutton[0]) self.cancelbutton.controlUp(self.chkbutton[6]) self.setFocus(self.okbutton)
def __init__(self): xbmcgui.Window.__init__(self) self.setCoordinateResolution(6) try: self.addControl( xbmcgui.ControlImage( 0, 0, 725, 576, os.path.join(RESOURCES, "media", 'Background.png'))) self.addControl( xbmcgui.ControlLabel(655, 500, 250, 35, "[B]%s[/B]" % VER, textColor='0xa0ffffff')) self.btnClearError = xbmcgui.ControlButton( btnX, btnY + 180, btnW, 35, GET_LOCALIZED_STRING(32140), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnClearError) self.btnReveal = xbmcgui.ControlButton( btnX, btnY + 225, btnW, 35, GET_LOCALIZED_STRING(32150), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnReveal) self.btnSave = xbmcgui.ControlButton( btnX, btnY + 270, btnW, 35, GET_LOCALIZED_STRING(32160), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnSave) self.btnLoad = xbmcgui.ControlButton( btnX, btnY + 315, btnW, 35, GET_LOCALIZED_STRING(32170), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnLoad) self.btnDelete = xbmcgui.ControlButton( btnX, btnY + 360, btnW, 35, GET_LOCALIZED_STRING(32180), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnDelete) self.btnExit = xbmcgui.ControlButton( btnX, btnY + 405, btnW, 35, GET_LOCALIZED_STRING(32190), textColor='0xff000000', focusTexture=os.path.join(RESOURCES, "media", 'b0.png'), noFocusTexture=os.path.join(RESOURCES, "media", 'y0.png')) self.addControl(self.btnExit) self.lblHint = xbmcgui.ControlLabel(xOfs + 2, yOfs + 10 * size - 30, 250, 35, '', textColor='0xff000000') self.addControl(self.lblHint) self.lblName = xbmcgui.ControlLabel(xOfs + 2, yOfs + 10 * size - 10, 350, 35, '', textColor='0xff000000') self.addControl(self.lblName) self.lblTimer = xbmcgui.ControlLabel(xOfs + 400, yOfs + 10 * size - 30, 200, 35, GET_LOCALIZED_STRING(32220) % '00:00:00', textColor='0xff000000', alignment=0x00000001) self.addControl(self.lblTimer) self.btnClearError.controlDown(self.btnReveal) self.btnReveal.controlUp(self.btnClearError) self.btnReveal.controlDown(self.btnSave) self.btnSave.controlUp(self.btnReveal) self.btnSave.controlDown(self.btnLoad) self.btnLoad.controlUp(self.btnSave) self.btnLoad.controlDown(self.btnDelete) self.btnDelete.controlUp(self.btnLoad) self.btnDelete.controlDown(self.btnExit) self.btnExit.controlUp(self.btnDelete) except: print 'Failed to draw buttons' print_exc() self.grid = [] self.gameName = getGame('') self.generateMode = 10 self.genMode() self.gameTimer = 0 if self.gameName == '': self.newGrid() else: self.loadGrid() self.tmrStatus = 1 self.startTimer()
def __init__(self, msg='', L=0, T=0, W=1280, H=720, TxtColor='0xFFFFFFFF', Font='font12', BorderWidth=10): buttonfocus, buttonnofocus = artwork('button') radiobgfocus, radiobgnofocus, radiofocus, radionofocus = artwork( 'radio') slidernibfocus, slidernibnofocus, sliderfocus, slidernofocus = artwork( 'slider') image_path = os.path.join(ART, 'ContentPanel.png') boxbg = os.path.join(ART, 'bgg2.png') self.border = xbmcgui.ControlImage(L, T, W, H, image_path) self.addControl(self.border) self.BG = xbmcgui.ControlImage(L + BorderWidth, T + BorderWidth, W - (BorderWidth * 2), H - (BorderWidth * 2), FANART, aspectRatio=0, colorDiffuse='0x5FFFFFFF') self.addControl(self.BG) top = T + BorderWidth leftside = L + BorderWidth rightside = L + (W / 2) - (BorderWidth * 2) firstrow = top + 30 secondrow = firstrow + 275 + (BorderWidth / 2) currentwidth = ((W / 2) - (BorderWidth * 4)) / 2 header = '[COLOR %s]Configurador Buffer[/COLOR]' % (COLOR2) self.Header = xbmcgui.ControlLabel(L, top, W, 30, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header) top += 30 + BorderWidth self.bgarea = xbmcgui.ControlImage(leftside, firstrow, rightside - L, 275, boxbg, aspectRatio=0, colorDiffuse='0x5FFFFFFF') self.addControl(self.bgarea) self.bgarea2 = xbmcgui.ControlImage(rightside + BorderWidth + BorderWidth, firstrow, rightside - L, 275, boxbg, aspectRatio=0, colorDiffuse='0x5FFFFFFF') self.addControl(self.bgarea2) self.bgarea3 = xbmcgui.ControlImage(leftside, secondrow, rightside - L, 275, boxbg, aspectRatio=0, colorDiffuse='0x5FFFFFFF') self.addControl(self.bgarea3) self.bgarea4 = xbmcgui.ControlImage(rightside + BorderWidth + BorderWidth, secondrow, rightside - L, 275, boxbg, aspectRatio=0, colorDiffuse='0x5FFFFFFF') self.addControl(self.bgarea4) header = '[COLOR %s]Video cache[/COLOR]' % (COLOR2) self.Header2 = xbmcgui.ControlLabel(leftside + BorderWidth, firstrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header2) freeMemory = int( float(wiz.getInfo('System.Memory(free)')[:-2]) * .33) recMemory = int( float(wiz.getInfo('System.Memory(free)')[:-2]) * .23) msg3 = "[COLOR %s]Numero de bytes utilizados para almacenar secuencias en la memoria. Cuando se establece en [COLOR %s]0[/COLOR] el cache se escribira en el disco en lugar de la RAM. Nota: para la cantidad de memoria establecida aqui, Kodi requerira 3 veces la cantidad de RAM libre. Establecerlo demasiado alto podria hacer que Kodi se bloquee si no puede obtener suficiente RAM (1/3 de Memoria Libre: [COLOR %s]%s[/COLOR])[/COLOR]" % ( COLOR2, COLOR1, COLOR1, freeMemory) self.Support3 = xbmcgui.ControlTextBox( leftside + int(BorderWidth * 1.5), firstrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 150, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.videoCacheSize = xbmcgui.ControlSlider( leftside + int(BorderWidth * 1.5), firstrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.videoCacheSize = xbmcgui.ControlSlider( leftside + int(BorderWidth * 1.5), firstrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.videoCacheSize) self.videomin = 0 self.videomax = freeMemory if freeMemory < 2000 else 2000 self.recommendedVideo = recMemory if recMemory < 500 else 500 self.currentVideo = self.recommendedVideo videopos = wiz.percentage(self.currentVideo, self.videomax) self.videoCacheSize.setPercent(videopos) current1 = '[COLOR %s]Actual:[/COLOR] [COLOR %s]%s MB[/COLOR]' % ( COLOR1, COLOR2, self.currentVideo) recommended1 = '[COLOR %s]Recomendado:[/COLOR] [COLOR %s]%s MB[/COLOR]' % ( COLOR1, COLOR2, self.recommendedVideo) self.currentVideo1 = xbmcgui.ControlTextBox(leftside + BorderWidth, firstrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentVideo1) self.currentVideo1.setText(current1) self.recommendedVideo1 = xbmcgui.ControlTextBox( leftside + BorderWidth + currentwidth, firstrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedVideo1) self.recommendedVideo1.setText(recommended1) header = '[COLOR %s]CURL Timeout/CURL Baja velocidad[/COLOR]' % ( COLOR2) self.Header3 = xbmcgui.ControlLabel(rightside + BorderWidth, firstrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header3) msg3 = "[COLOR %s][B]curlclienttimeout[/B] es el tiempo en segundos que tardara la conexion de libcurl en agotar el tiempo de espera y [B] curllowspeedtime [/ B] es el tiempo en segundos que libcurl considerara una conexion a velocidad minima. Para conexiones mas lentas, configurelo en 20.[/COLOR]" % COLOR2 self.Support3 = xbmcgui.ControlTextBox( rightside + int(BorderWidth * 3.5), firstrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 150, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.CURLTimeout = xbmcgui.ControlSlider( rightside + int(BorderWidth * 3.5), firstrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.CURLTimeout = xbmcgui.ControlSlider( rightside + int(BorderWidth * 3.5), firstrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.CURLTimeout) self.curlmin = 0 self.curlmax = 20 self.recommendedCurl = 10 self.currentCurl = self.recommendedCurl curlpos = wiz.percentage(self.currentCurl, self.curlmax) self.CURLTimeout.setPercent(curlpos) current2 = '[COLOR %s]Actual:[/COLOR] [COLOR %s]%ss[/COLOR]' % ( COLOR1, COLOR2, self.currentCurl) recommended2 = '[COLOR %s]Recomendado:[/COLOR] [COLOR %s]%ss[/COLOR]' % ( COLOR1, COLOR2, self.recommendedCurl) self.currentCurl2 = xbmcgui.ControlTextBox(rightside + (BorderWidth * 3), firstrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentCurl2) self.currentCurl2.setText(current2) self.recommendedCurl2 = xbmcgui.ControlTextBox( rightside + (BorderWidth * 3) + currentwidth, firstrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedCurl2) self.recommendedCurl2.setText(recommended2) header = '[COLOR %s]Factor de lectura del Buffer[/COLOR]' % ( COLOR2) self.Header4 = xbmcgui.ControlLabel(leftside, secondrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header4) msg3 = "[COLOR %s]El valor de esta configuracion es un multiplicador del limite predeterminado. Si Kodi esta cargando un archivo bluray tipico a 36 Mbit/s, entonces un valor de 2 necesitara al menos 72 Mbit/s de ancho de banda de red. Sin embargo, a diferencia de la configuracion de la memoria RAM, puede aumentar este valor de manera segura por alto que sea, y Kodi no se bloqueara.[/COLOR]" % COLOR2 self.Support3 = xbmcgui.ControlTextBox( leftside + int(BorderWidth * 1.5), secondrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 150, font='font12', textColor=TxtColor) self.addControl(self.Support3) self.Support3.setText(msg3) try: self.readBufferFactor = xbmcgui.ControlSlider( leftside + int(BorderWidth * 1.5), secondrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus, orientation=xbmcgui.HORIZONTAL) except: self.readBufferFactor = xbmcgui.ControlSlider( leftside + int(BorderWidth * 1.5), secondrow + 210, (W / 2) - (BorderWidth * 5), 20, textureback=sliderfocus, texture=slidernibnofocus, texturefocus=slidernibfocus) self.addControl(self.readBufferFactor) self.readmin = 0 self.readmax = 10 self.recommendedRead = 5 self.currentRead = self.recommendedRead readpos = wiz.percentage(self.currentRead, self.readmax) self.readBufferFactor.setPercent(readpos) current3 = '[COLOR %s]Actual:[/COLOR] [COLOR %s]%s[/COLOR]' % ( COLOR1, COLOR2, self.currentRead) recommended3 = '[COLOR %s]Recomendado:[/COLOR] [COLOR %s]%s[/COLOR]' % ( COLOR1, COLOR2, self.recommendedRead) self.currentRead3 = xbmcgui.ControlTextBox(leftside + BorderWidth, secondrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.currentRead3) self.currentRead3.setText(current3) self.recommendedRead3 = xbmcgui.ControlTextBox( leftside + BorderWidth + currentwidth, secondrow + 235, currentwidth, 20, font=Font, textColor=TxtColor) self.addControl(self.recommendedRead3) self.recommendedRead3.setText(recommended3) header = '[COLOR %s]Modo Buffer[/COLOR]' % (COLOR2) self.Header4 = xbmcgui.ControlLabel(rightside + BorderWidth, secondrow + 5, (W / 2) - (BorderWidth * 2), 20, header, font='font13', textColor=TxtColor, alignment=0x00000002) self.addControl(self.Header4) msg4 = "[COLOR %s]Esta configuracion obligara a Kodi a usar un cache para todos los archivos de video, incluida la red local, Internet e incluso el disco duro local. El valor predeterminado es 0 y solo almacenara en cache videos que usen rutas / fuentes de archivos de Internet.[/COLOR]" % COLOR2 self.Support4 = xbmcgui.ControlTextBox( rightside + int(BorderWidth * 3.5), secondrow + 30 + BorderWidth, (W / 2) - (BorderWidth * 4), 110, font='font12', textColor=TxtColor) self.addControl(self.Support4) self.Support4.setText(msg4) B1 = secondrow + 130 + BorderWidth B2 = B1 + 30 B3 = B2 + 30 B4 = B3 + 30 self.Button0 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3), B1, (W / 2) - (BorderWidth * 4), 30, '0: Buffer para todos los archivos de internet', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button1 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3), B2, (W / 2) - (BorderWidth * 4), 30, '1: Buffer para todos los archivos', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button2 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3), B3, (W / 2) - (BorderWidth * 4), 30, '2: Solo Buffer de archivos de internet reales', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.Button3 = xbmcgui.ControlRadioButton( rightside + (BorderWidth * 3), B4, (W / 2) - (BorderWidth * 4), 30, '3: Sin Buffer', font='font12', focusTexture=radiobgfocus, noFocusTexture=radiobgnofocus, focusOnTexture=radiofocus, noFocusOnTexture=radiofocus, focusOffTexture=radionofocus, noFocusOffTexture=radionofocus) self.addControl(self.Button0) self.addControl(self.Button1) self.addControl(self.Button2) self.addControl(self.Button3) self.Button0.setSelected(False) self.Button1.setSelected(False) self.Button2.setSelected(True) self.Button3.setSelected(False) self.buttonWrite = xbmcgui.ControlButton( leftside, T + H - 40 - BorderWidth, (W / 2) - (BorderWidth * 2), 35, "Escribir Archivo", textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=buttonfocus, noFocusTexture=buttonnofocus) self.buttonCancel = xbmcgui.ControlButton( rightside + BorderWidth * 2, T + H - 40 - BorderWidth, (W / 2) - (BorderWidth * 2), 35, "Cancelar", textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=buttonfocus, noFocusTexture=buttonnofocus) self.addControl(self.buttonWrite) self.addControl(self.buttonCancel) self.buttonWrite.controlLeft(self.buttonCancel) self.buttonWrite.controlRight(self.buttonCancel) self.buttonWrite.controlUp(self.Button3) self.buttonWrite.controlDown(self.videoCacheSize) self.buttonCancel.controlLeft(self.buttonWrite) self.buttonCancel.controlRight(self.buttonWrite) self.buttonCancel.controlUp(self.Button3) self.buttonCancel.controlDown(self.videoCacheSize) self.videoCacheSize.controlUp(self.buttonWrite) self.videoCacheSize.controlDown(self.CURLTimeout) self.CURLTimeout.controlUp(self.videoCacheSize) self.CURLTimeout.controlDown(self.readBufferFactor) self.readBufferFactor.controlUp(self.CURLTimeout) self.readBufferFactor.controlDown(self.Button0) self.Button0.controlUp(self.CURLTimeout) self.Button0.controlDown(self.Button1) self.Button0.controlLeft(self.readBufferFactor) self.Button0.controlRight(self.readBufferFactor) self.Button1.controlUp(self.Button0) self.Button1.controlDown(self.Button2) self.Button1.controlLeft(self.readBufferFactor) self.Button1.controlRight(self.readBufferFactor) self.Button2.controlUp(self.Button1) self.Button2.controlDown(self.Button3) self.Button2.controlLeft(self.readBufferFactor) self.Button2.controlRight(self.readBufferFactor) self.Button3.controlUp(self.Button2) self.Button3.controlDown(self.buttonWrite) self.Button3.controlLeft(self.readBufferFactor) self.Button3.controlRight(self.readBufferFactor) self.setFocus(self.videoCacheSize)
def setMarker(self, row, col, nr=0): global box, xOfs, yOfs, size if row == 0 and col == 0: col = 9 row = 9 if col > self.col: while col > 8 or self.grid[row * 9 + col][12] <> 0: col += 1 if col > 8: col = 0 row += 1 if row > 8: row = 0 elif col < self.col: while col < 0 or self.grid[row * 9 + col][12] <> 0: col -= 1 if col < 0: col = 8 row -= 1 if row < 0: row = 8 elif row > self.row: while row > 8 or self.grid[row * 9 + col][12] <> 0: row += 1 if row > 8: row = 0 col += 1 if col > 8: col = 0 elif row < self.row: while row < 0 or self.grid[row * 9 + col][12] <> 0: row -= 1 if row < 0: row = 8 col -= 1 if col < 0: col = 8 self.row = row self.col = col gPtr = self.grid[self.row * 9 + self.col] try: self.removeControl(self.marker) except: pass try: self.nr = nr if nr == 0: icon = os.path.join(RESOURCES, "media", 'b%s.png' % str(gPtr[10])) else: icon = os.path.join(RESOURCES, "media", 'b%s.png' % str(nr)) self.marker = xbmcgui.ControlImage( xOfs + self.col * size + self.col / 3 * 5, yOfs + self.row * size + self.row / 3 * 5, size, size, icon) self.addControl(self.marker) except: pass hint = '' if gPtr[10] == 0: for i in range(0, 10): if gPtr[i] > 0: hint = hint + str(i) + '-' set = 0 for i in range(0, 81): if self.grid[i][10] == 0: set += 1 if set > 0: if len(hint) > 1: message = GET_LOCALIZED_STRING(32200) % (hint[:len(hint) - 1], str(set)) else: message = GET_LOCALIZED_STRING(32201) % str(set) else: message = GET_LOCALIZED_STRING(32202) % self.timeFormat( self.gameTimer) self.lblHint.setLabel(message)
def createPreview(self, fav): imgW = 256 imgH = 150 # collect all controls and add them in one call to save time allControls = [] # create preview images first so they are behind highlight image images = [] for nr in range(0, 16): pos = self.getControlPos(nr) image = xbmcgui.ControlImage(pos['x'], pos['y'] + 1, imgW - 2, imgH, '') allControls.append(image) images.append(image) self.highlightImage = xbmcgui.ControlImage(0, 0, imgW, 178, '') allControls.append(self.highlightImage) self.highLabel = '' #add a scroll label for highlighted item self.scrollLabel = xbmcgui.ControlFadeLabel(0, 0, 240, 30, 'font13', '0xFF000000') allControls.append(self.scrollLabel) #preloadImage is buffer for image update self.preloadImage = xbmcgui.ControlImage(0, -200, 256, 150, '') allControls.append(self.preloadImage) for nr in range(0, 16): pos = self.getControlPos(nr) logo = xbmcgui.ControlImage(pos['x'] + 5, pos['y'] + 100, 84, 48, '') label = xbmcgui.ControlLabel(pos['x'] + 6, pos['y'] + imgH - 1, 250, 30, 'font13') channelNr = xbmcgui.ControlLabel(pos['x'] + 200, pos['y'] + 5, 50, 20, 'font13', alignment=1) allControls.append(logo) allControls.append(label) allControls.append(channelNr) self.controls.append({ 'image': images[nr], 'logo': logo, 'label': label, 'channelNr': channelNr, 'program': '', 'visible': True }) addonPath = xbmcaddon.Addon().getAddonInfo('path') #add info controls posX = 768 #bg = xbmcgui.ControlImage(posX-10, -10, 530, 376, 'recentaddedback.png') #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'ContentPanel.png') #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'episodematte.png', colorDiffuse='0xFF333333') bg = xbmcgui.ControlImage(posX, 0, 512, 360, addonPath + '/resources/previewInfo.png') self.infoLogo = xbmcgui.ControlImage( 74 + posX, 5, 140, 70, (xbmcaddon.Addon().getAddonInfo('path') + '/resources/channel-highlight.png')) self.infoChannelTitle = xbmcgui.ControlLabel(0 + posX, 85, 287, 30, 'TITLE', alignment=2) self.infoImg = xbmcgui.ControlImage( 284 + posX, 3, 225, 146, (xbmcaddon.Addon().getAddonInfo('path') + '/resources/channel-highlight.png')) self.infoTitle = xbmcgui.ControlFadeLabel(5 + posX, 150, 500, 20, 'font16', '0xFFFFFFFF', 2) self.infoDesc = xbmcgui.ControlFadeLabel(5 + posX, 180, 500, 20, 'font13', '0xFFFFFFFF', 2) self.infoPlot = xbmcgui.ControlTextBox(8 + posX, 205, 500, 148, 'font13') allControls.append(bg) allControls.append(self.infoLogo) allControls.append(self.infoChannelTitle) allControls.append(self.infoImg) allControls.append(self.infoTitle) allControls.append(self.infoDesc) allControls.append(self.infoPlot) self.addControls(allControls) self.highlightImage.setImage(addonPath + '/resources/channel-highlight.png') self.infoPlot.autoScroll(5000, 1800, 5000) self.db = ZattooDB() if fav == 'popular': self.channels = self.db.getPopularList() else: self.channels = self.db.getChannelList(fav)
def __init__(self, noteType='t', noteMessage='', noteImage='', L=140, T=110, W=1000, H=500, Font='font14', TxtColor='0xFF64d1ff'): if len(noteImage) == 0: noteImage = DefaultNoteImage if (noteType.lower() == 'text') or (noteType.lower() == 't'): noteType = 't' elif (noteType.lower() == 'image') or (noteType.lower() == 'i'): noteType = 'i' self.noteType = noteType self.noteMessage = noteMessage self.noteImage = noteImage self.Font = Font self.TxtColor = TxtColor ## ### ## self.background = OverlayBackground #artp('black1'); self.BG = xbmcgui.ControlImage(L, T, W, H, self.background, aspectRatio=0, colorDiffuse='0xFF3030FF') #self.OlayBrdr=xbmcgui.ControlImage(L,T,W,H,OverlayBorder,aspectRatio=0); #self.OlaySplash=xbmcgui.ControlImage(L,T,W,H,icon,aspectRatio=0); iLogoW = 144 iLogoH = 68 self.iLogo = xbmcgui.ControlImage((L + (W / 2)) - (iLogoW / 2), T + 10, iLogoW, iLogoH, hubLogo, aspectRatio=0) ## ### ## ###L2=L+110; T2=T+130; W2=W-(T2-T)-90; H2=H-(L2-L)-110; #L3=L2+5; T3=T2+5; W3=W2-18; H3=H2-10; ##L2=L+87; T2=T+80; W2=W-(T2-T)-96; H2=H-(L2-L)-74; L3=L2+5; T3=T2+60; W3=W2-18; H3=H2-5-60; #L2=L+67; T2=T+60; W2=W-(T2-T)-96; H2=H-(L2-L)-74; L2 = 200 T2 = 200 W2 = 880 H2 = 340 L3 = L2 + 5 T3 = T2 + 60 W3 = W2 - 18 H3 = H2 - 5 - 60 self.ImgMessage = xbmcgui.ControlImage(L2, T2, W2, H2, self.noteImage, aspectRatio=0) self.TxtMessage = xbmcgui.ControlTextBox(L2 + 5, T2, W2 - 10, H2, font=self.Font, textColor=self.TxtColor) #self.TxtMessage=xbmcgui.ControlTextBox(L3,T3,W3,H3,font=self.Font,textColor=self.TxtColor); #print [self.background,OverlayBorder,self.noteImage] ## ### ## focus = artp('button-focus_lightblue') nofocus = artp('button-focus_grey') w1 = 120 h1 = 35 w2 = 160 h2 = 35 spacing1 = 20 l2 = L + W - spacing1 - w2 t2 = T + H - h2 - spacing1 l1 = L + W - spacing1 - w2 - spacing1 - w1 t1 = T + H - h1 - spacing1 self.buttonDismiss = xbmcgui.ControlButton(l1, t1, w1, h1, "Dismiss", textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=focus, noFocusTexture=nofocus) self.buttonRemindMe = xbmcgui.ControlButton(l2, t2, w2, h2, "Hide", textColor="0xFF000000", focusedColor="0xFF000000", alignment=2, focusTexture=focus, noFocusTexture=nofocus) #self.OlaySplash for z in [ self.BG, self.ImgMessage, self.TxtMessage, self.iLogo, self.buttonRemindMe, self.buttonDismiss ]: self.addControl(z) #for z in [self.BG,self.ImgMessage,self.TxtMessage,self.OlayBrdr,self.buttonRemindMe,self.buttonDismiss]: self.addControl(z); #for z in [self.BG,self.OlayBrdr,self.ImgMessage,self.TxtMessage,self.buttonRemindMe,self.buttonDismiss]: self.addControl(z); #self.OlayBrdr.setAnimations([('WindowOpen','effect=fade delay=0 time=0 start=0 end=70')]); #self.ImgMessage.setAnimations([('WindowOpen','effect=fade delay=0 time=0 start=0 end=70')]); #self.OlaySplash.setAnimations([('WindowOpen','effect=fade delay=0 time=8000 start=100 end=0')]); #self.OlaySplash.setAnimations([('WindowOpen','effect=slide delay=0 time=5000 start=-1800 end=1800')]); #self.ImgMessage.setAnimations([('WindowOpen','effect=fade delay=2000 time=2000 start=0 end=100')]); #for z in [self.BG,self.ImgMessage,self.TxtMessage,self.OlayBrdr,self.buttonRemindMe,self.buttonDismiss]: for z in [ self.BG, self.ImgMessage, self.TxtMessage, self.iLogo, self.buttonRemindMe, self.buttonDismiss ]: #z.setAnimations([('WindowOpen','effect=slide delay=0 time=5000 start=0,-1800 end=0'),('WindowClose','effect=slide delay=0 time=5000 start=0 end=0,-1800')]); z.setAnimations([('WindowOpen', 'effect=fade delay=0 time=2000 start=0 end=100'), ('WindowClose', 'effect=slide delay=0 time=2000 start=0 end=0,' + str(0 - (H + T + 10)))]) ## ### ## self.buttonRemindMe.controlLeft(self.buttonDismiss) self.buttonRemindMe.controlRight(self.buttonDismiss) self.buttonDismiss.controlLeft(self.buttonRemindMe) self.buttonDismiss.controlRight(self.buttonRemindMe) ## ### ## self.TxtMessage.setText(self.noteMessage) self.setFocus(self.buttonRemindMe)
def __init__(self, *args, **kwargs): bg_image = os.path.join(__addon__.getAddonInfo('path'), 'Images/') + "background.png" check_image = os.path.join(__addon__.getAddonInfo('path'), 'Images/') + "trans_checked.png" uncheck_image = os.path.join(__addon__.getAddonInfo('path'), 'Images/') + "trans_unchecked1.png" self.ctrlBackgound = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image) self.cancelled = False self.addControl(self.ctrlBackgound) self.msg = kwargs.get( 'msg' ) + '\nNormally there are 3-4 selections and 2 rounds of pictures' self.round = kwargs.get('round') self.strActionInfo = xbmcgui.ControlLabel(335, 120, 700, 300, self.msg, 'font13', '0xFFFF00FF') self.addControl(self.strActionInfo) self.strActionInfo = xbmcgui.ControlLabel( 335, 20, 724, 400, 'Captcha round %s' % (str(self.round)), 'font40', '0xFFFF00FF') self.addControl(self.strActionInfo) self.cptloc = kwargs.get('captcha') #self.img = xbmcgui.ControlImage(335,200,624,400,self.cptloc) imgw = 400 imgh = 300 imgX = 335 imgY = 200 pw = imgw / 3 ph = imgh / 3 self.img = xbmcgui.ControlImage(imgX, imgY, imgw, imgh, self.cptloc) self.addControl(self.img) self.chk = [0] * 9 self.chkbutton = [0] * 9 self.chkstate = [False] * 9 #self.chk[0] = xbmcgui.ControlCheckMark(335,200,200,200,'select',checkWidth=30, checkHeight=30) self.chk[0] = xbmcgui.ControlImage( imgX, imgY, pw, ph, check_image ) # '', font='font1',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[1] = xbmcgui.ControlImage( imgX + pw, imgY, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[2] = xbmcgui.ControlImage( imgX + pw + pw, imgY, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[3] = xbmcgui.ControlImage( imgX, imgY + ph, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[4] = xbmcgui.ControlImage( imgX + pw, imgY + ph, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[5] = xbmcgui.ControlImage( imgX + pw + pw, imgY + ph, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[6] = xbmcgui.ControlImage( imgX, imgY + ph + ph, pw, ph, check_image ) #, '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[7] = xbmcgui.ControlImage( imgX + pw, imgY + ph + ph, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chk[8] = xbmcgui.ControlImage( imgX + pw + pw, imgY + ph + ph, pw, ph, check_image ) # '', font='font14',focusTexture=check_image ,noFocusTexture=uncheck_image,checkWidth=220,checkHeight=150) self.chkbutton[0] = xbmcgui.ControlButton(imgX, imgY, pw, ph, '1', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[1] = xbmcgui.ControlButton(imgX + pw, imgY, pw, ph, '2', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[2] = xbmcgui.ControlButton(imgX + pw + pw, imgY, pw, ph, '3', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[3] = xbmcgui.ControlButton(imgX, imgY + ph, pw, ph, '4', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[4] = xbmcgui.ControlButton(imgX + pw, imgY + ph, pw, ph, '5', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[5] = xbmcgui.ControlButton(imgX + pw + pw, imgY + ph, pw, ph, '6', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[6] = xbmcgui.ControlButton(imgX, imgY + ph + ph, pw, ph, '7', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[7] = xbmcgui.ControlButton(imgX + pw, imgY + ph + ph, pw, ph, '8', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) self.chkbutton[8] = xbmcgui.ControlButton(imgX + pw + pw, imgY + ph + ph, pw, ph, '9', font='font1') #,focusTexture=check_image ,noFocusTexture=uncheck_image);#,checkWidth=220,checkHeight=150) for obj in self.chk: self.addControl(obj) obj.setVisible(False) for obj in self.chkbutton: self.addControl(obj) #self.chk[0].setSelected(False) self.cancelbutton = xbmcgui.ControlButton(imgX + (imgw / 2) - 110, imgY + imgh + 10, 100, 40, 'Cancel', alignment=2) self.okbutton = xbmcgui.ControlButton(imgX + (imgw / 2) + 10, imgY + imgh + 10, 100, 40, 'OK', alignment=2) self.addControl(self.okbutton) self.addControl(self.cancelbutton) self.chkbutton[6].controlDown(self.cancelbutton) self.chkbutton[6].controlUp(self.chkbutton[3]) self.chkbutton[7].controlDown(self.cancelbutton) self.chkbutton[7].controlUp(self.chkbutton[4]) self.chkbutton[8].controlDown(self.okbutton) self.chkbutton[8].controlUp(self.chkbutton[5]) self.chkbutton[6].controlLeft(self.chkbutton[8]) self.chkbutton[6].controlRight(self.chkbutton[7]) self.chkbutton[7].controlLeft(self.chkbutton[6]) self.chkbutton[7].controlRight(self.chkbutton[8]) self.chkbutton[8].controlLeft(self.chkbutton[7]) self.chkbutton[8].controlRight(self.chkbutton[6]) self.chkbutton[3].controlDown(self.chkbutton[6]) self.chkbutton[3].controlUp(self.chkbutton[0]) self.chkbutton[4].controlDown(self.chkbutton[7]) self.chkbutton[4].controlUp(self.chkbutton[1]) self.chkbutton[5].controlDown(self.chkbutton[8]) self.chkbutton[5].controlUp(self.chkbutton[2]) self.chkbutton[3].controlLeft(self.chkbutton[5]) self.chkbutton[3].controlRight(self.chkbutton[4]) self.chkbutton[4].controlLeft(self.chkbutton[3]) self.chkbutton[4].controlRight(self.chkbutton[5]) self.chkbutton[5].controlLeft(self.chkbutton[4]) self.chkbutton[5].controlRight(self.chkbutton[3]) self.chkbutton[0].controlDown(self.chkbutton[3]) self.chkbutton[0].controlUp(self.cancelbutton) self.chkbutton[1].controlDown(self.chkbutton[4]) self.chkbutton[1].controlUp(self.cancelbutton) self.chkbutton[2].controlDown(self.chkbutton[5]) self.chkbutton[2].controlUp(self.okbutton) self.chkbutton[0].controlLeft(self.chkbutton[2]) self.chkbutton[0].controlRight(self.chkbutton[1]) self.chkbutton[1].controlLeft(self.chkbutton[0]) self.chkbutton[1].controlRight(self.chkbutton[2]) self.chkbutton[2].controlLeft(self.chkbutton[1]) self.chkbutton[2].controlRight(self.chkbutton[0]) self.cancelled = False self.setFocus(self.okbutton) self.okbutton.controlLeft(self.cancelbutton) self.okbutton.controlRight(self.cancelbutton) self.cancelbutton.controlLeft(self.okbutton) self.cancelbutton.controlRight(self.okbutton) self.okbutton.controlDown(self.chkbutton[2]) self.okbutton.controlUp(self.chkbutton[8]) self.cancelbutton.controlDown(self.chkbutton[0]) self.cancelbutton.controlUp(self.chkbutton[6])
def __get_cached_url(self, url, cache_limit=8): utils.log('Fetching Cached URL: %s' % url, xbmc.LOGDEBUG) before = time.time() db_connection=DB_Connection() html = db_connection.get_cached_url(url, cache_limit) if html: utils.log('Returning cached result for: %s' % (url), xbmc.LOGDEBUG) return html utils.log('No cached url found for: %s' % url, xbmc.LOGDEBUG) req = urllib2.Request(url) host = re.sub('http://', '', self.base_url) req.add_header('User-Agent', USER_AGENT) req.add_unredirected_header('Host', host) req.add_unredirected_header('Referer', self.base_url) try: body = self.__http_get_with_retry_2(url, req) if '<title>Are You a Robot?</title>' in body: utils.log('bot detection') # download the captcha image and save it to a file for use later captchaimgurl = 'http://' + host + '/CaptchaSecurityImages.php' captcha_save_path = xbmc.translatePath('special://userdata/addon_data/plugin.video.1channel/CaptchaSecurityImage.jpg') req = urllib2.Request(captchaimgurl) host = re.sub('http://', '', self.base_url) req.add_header('User-Agent', USER_AGENT) req.add_header('Host', host) req.add_header('Referer', self.base_url) response = urllib2.urlopen(req) the_img = response.read() with open(captcha_save_path, 'wb') as f: f.write(the_img) # now pop open dialog for input # TODO: make the size and loc configurable img = xbmcgui.ControlImage(550, 15, 240, 100, captcha_save_path) wdlg = xbmcgui.WindowDialog() wdlg.addControl(img) wdlg.show() kb = xbmc.Keyboard('', 'Type the letters in the image', False) kb.doModal() capcode = kb.getText() if (kb.isConfirmed()): userInput = kb.getText() if userInput != '': # post back user string wdlg.removeControl(img) capcode = kb.getText() data = {'security_code':capcode, 'not_robot':'I\'m Human! I Swear!'} data = urllib.urlencode(data) roboturl = 'http://' + host + '/are_you_a_robot.php' req = urllib2.Request(roboturl) host = re.sub('http://', '', self.base_url) req.add_header('User-Agent', USER_AGENT) req.add_header('Host', host) req.add_header('Referer', self.base_url) response = urllib2.urlopen(req, data) body = self.__get_url(url) elif userInput == '': dialog = xbmcgui.Dialog() dialog.ok("Robot Check", "You must enter text in the image to continue") wdlg.close() body = unicode(body, 'windows-1252', 'ignore') parser = HTMLParser.HTMLParser() body = parser.unescape(body) except Exception as e: dialog = xbmcgui.Dialog() dialog.ok("Connection failed", "Failed to connect to url", url) utils.log('Failed to connect to URL %s: %s' % (url, str(e)), xbmc.LOGERROR) return '' db_connection.cache_url(url, body) after = time.time() utils.log('Cached Url Fetch took: %.2f secs' % (after - before), xbmc.LOGDEBUG) return body