From 94262e9a0cff453e2985a81578243a6689e9bb32 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Mon, 22 Nov 2021 16:35:12 +0100 Subject: [PATCH] UI Recaptcha --- platformcode/recaptcha.py | 70 +++-- resources/skins/Default/720p/Recaptcha.xml | 271 +++++++++++++------- resources/skins/Default/media/selection.png | Bin 0 -> 1862 bytes 3 files changed, 227 insertions(+), 114 deletions(-) create mode 100644 resources/skins/Default/media/selection.png diff --git a/platformcode/recaptcha.py b/platformcode/recaptcha.py index 9b6a55a0..d876f2be 100644 --- a/platformcode/recaptcha.py +++ b/platformcode/recaptcha.py @@ -2,6 +2,7 @@ import random import time from threading import Thread +from specials.globalsearch import CLOSE import xbmcgui from core import httptools @@ -17,6 +18,15 @@ grid_width = 450 tiles_texture_focus = 'white.png' tiles_texture_checked = 'Controls/check_mark.png' +TITLE = 10 +PANEL = 11 +IMAGE = 12 +CONTROL = 1 + +OK = 21 +CANCEL = 22 +RELOAD = 23 + class Kodi: def __init__(self, key, referer): @@ -64,15 +74,16 @@ class SolverKodi(xbmcgui.WindowXMLDialog): def onInit(self): logger.debug(self.image_path) - self.getControl(10020).setImage(self.image_path, False) - self.getControl(10000).setText(self.goal) - self.setFocusId(10005) - for x in range(self.num_columns): - for y in range(self.num_rows): - self.addControl(xbmcgui.ControlRadioButton(int(tiles_pos[0] + x*grid_width/self.num_rows), int(tiles_pos[1] + y*grid_width/self.num_columns), - int(grid_width/self.num_rows), int(grid_width/self.num_columns), '', tiles_texture_focus, tiles_texture_focus, - focusTexture=tiles_texture_checked, noFocusTexture=tiles_texture_checked)) + items=[] + self.getControl(IMAGE).setImage(self.image_path, False) + self.getControl(TITLE).setLabel(self.goal) + for x in range(self.num_tiles): + item = xbmcgui.ListItem(str(x)) + item.setProperty('selected', 'false') + items.append(item) + self.getControl(PANEL).reset() + self.getControl(PANEL).addItems(items) class MultiCaptchaKodi(SolverKodi): """ @@ -88,34 +99,38 @@ class MultiCaptchaKodi(SolverKodi): indices = self.handle_challenge(result) result = self.solver.select_indices(indices) return result - + def handle_challenge(self, challenge: ImageGridChallenge): goal = challenge.goal.plain self.num_rows = challenge.dimensions.rows self.num_columns = challenge.dimensions.columns + logger.debug('RIGHE',self.num_rows, 'COLONNE',self.num_columns) - num_tiles = challenge.dimensions.count + self.num_tiles = challenge.dimensions.count image = challenge.image self.show_image(image, goal) if self.closed: return False return self.result - + def onClick(self, control): - if control == 10003: + if control == CANCEL: self.closed = True self.close() - elif control == 10004: + elif control == RELOAD: self.result = None self.close() - elif control == 10002: + elif control == OK: self.result = [int(k) for k in range(9) if self.indices.get(k, False)] self.close() else: - index = control - 10005 - self.indices[control - 10005] = not self.indices.get(index, False) + item = self.getControl(PANEL) + index = item.getSelectedPosition() + selected = True if item.getSelectedItem().getProperty('selected') == 'false' else False + item.getSelectedItem().setProperty('selected', str(selected).lower()) + self.indices[index] = selected class DynamicKodi(SolverKodi): @@ -130,7 +145,8 @@ class DynamicKodi(SolverKodi): goal = challenge.goal.raw self.num_rows = challenge.dimensions.rows self.num_columns = challenge.dimensions.columns - num_tiles = challenge.dimensions.count + self.num_tiles = challenge.dimensions.count + logger.debug('RIGHE',self.num_rows, 'COLONNE',self.num_columns) self.show_image(image, goal) if self.closed: @@ -138,26 +154,30 @@ class DynamicKodi(SolverKodi): return self.result def changeTile(self, path, index, delay): - from core.support import dbg - dbg() time.sleep(delay) - tile = self.getControl(10005 + index) - self.addControl(xbmcgui.ControlImage(tile.getX(), tile.getY(), tile.getWidth(), tile.getHeigh(), path)) + self.getControl(PANEL).getListItem(index).setArt({'image', path}) + # tile = self.getControl(10005 + index) + # self.addControl(xbmcgui.ControlImage(tile.getX(), tile.getY(), tile.getWidth(), tile.getHeigh(), path)) def onClick(self, control): - if control == 10003: + if control == CLOSE: self.closed = True self.close() - elif control == 10004: + elif control == RELOAD: self.result = None self.close() - elif control == 10002: + elif control == OK: self.result = self.solver.finish() self.close() else: - index = control - 10005 + item = self.getControl(PANEL) + index = item.getSelectedPosition() + selected = True if item.getSelectedItem().getProperty('selected') == 'false' else False + item.getSelectedItem().setProperty('selected', str(selected).lower()) + self.indices[index] = selected + tile = self.solver.select_tile(index) path = config.get_temp_file(str(random.randint(1, 1000)) + '.png') filetools.write(path, tile.image) diff --git a/resources/skins/Default/720p/Recaptcha.xml b/resources/skins/Default/720p/Recaptcha.xml index acfe4d25..9521391e 100644 --- a/resources/skins/Default/720p/Recaptcha.xml +++ b/resources/skins/Default/720p/Recaptcha.xml @@ -1,97 +1,190 @@ - + false - - - + 11 + + + - - - + + + - - 40 - 390 - 600 - 640 - - 510 - 640 - 45 - Controls/dialog-bg-solid.png + + 40 + 398 + 484 + 640 + + 100% + 100% + white.png + + + Main Captcha Image + 90 + 20 + 444 + 444 + + + 20 + 20 + 60 + 444 + font13 + FFFFFFFF + true + center + center + + + + 20 + 90 + 21 + + + Override Image + 100% + 100% + $INFO[ListItem.Art(image)] + + + Focused + 100% + 100% + selection.png + + + String.IsEqual(ListItem.Property(selected), true) + Selected Image + 100% + 100% + Controls/check_mark.png + + + + + Override Image + 100% + 100% + $INFO[ListItem.Art(image)] + + + Focused + 100% + 100% + selection.png + + + String.IsEqual(ListItem.Property(selected), true) + Selected Image + 100% + 100% + Controls/check_mark.png + + + + + Override Image + 100% + 100% + $INFO[ListItem.Art(image)] + + + Focused + 100% + 100% + selection.png + + + Focused + 100% + 100% + white.png + + + String.IsEqual(ListItem.Property(selected), true) + Selected Image + 100% + 100% + Controls/check_mark.png + + + + + Override Image + 100% + 100% + $INFO[ListItem.Art(image)] + + + Focused + 100% + 100% + selection.png + + + Focused + 100% + 100% + white.png + + + String.IsEqual(ListItem.Property(selected), true) + Selected Image + 100% + 100% + Controls/check_mark.png + + + + + 565 + 20 + horizontal + + 150 + 50 + 11 + 110 + FFFFFFFF + FFFFFFFF + white.png + white.png + center + center + + + + 150 + 50 + 11 + 110 + FFFFFFFF + FFFFFFFF + white.png + white.png + center + center + + + + 150 + 50 + 11 + 110 + FFFFFFFF + FFFFFFFF + white.png + white.png + center + center + + + - - 30 - 20 - 60 - 560 - font13 - FFFFFFFF - true - center - - - - 565 - 75 - 150 - 50 - 110 - FFFFFFFF - FFFFFFFF - white.png - white.png - center - center - - 10011 - 10005 - 10004 - 10003 - - - 565 - 225 - 150 - 50 - 110 - FFFFFFFF - FFFFFFFF - white.png - white.png - center - center - - 10012 - 10006 - 10002 - 10004 - - - 565 - 375 - 150 - 50 - 110 - FFFFFFFF - FFFFFFFF - white.png - white.png - center - center - - 10013 - 10007 - 10003 - 10002 - - - 90 - 75 - 450 - 450 - - \ No newline at end of file diff --git a/resources/skins/Default/media/selection.png b/resources/skins/Default/media/selection.png new file mode 100644 index 0000000000000000000000000000000000000000..7fd322587b33fb960bd9e63a2d352f97073e3761 GIT binary patch literal 1862 zcmah~eM}Q)7(cSWq-ge`e-NX~?eK%Cz3Uwo;p8CD^3jcA2PG8vL$2-H_C|YG@2<2k z=0*h*P$b|mMCaUC#6J|BiCNfmabYvexyAT3<3`5j2Ajzu*~UZ`UH9I#77?6DKi>EG zJm`aT0@LySL7A3*oPU_;P2$Hy&v)W{vxs-MYKAd$5 zc7TU`euyJTPF~2*I_iOp+JT$n8Eo?OSq$Zz3|6H#>&$)w@NgwfBB*F8vpSmU9obGS zFISTjqG19bkXbb3^YRiMVlXu?4cCg9z);miu4gct*@7Ab5ukcpkL$2p4Voi5U39sz zC>9KN4Caw#KTQz9U=R;x;DYET$n5NFLPrr4rG*|^sgal2kd~LyloZh%Mj$yv&M$KU zk19D?yAY5W41+itOAbQZY<6CXwGW9P6oepg9r3Wc-y_I^Fiu)Dt66Zuq#0`5EMzhmETZ7z zybzPhiwjUwp&^sZ&dk(Oc(ee8N803L-JlfkZrKw*d={wUoR8X-2E74AA(cD_DWTMJ z)eze(#$cN$s7*yTDpb871TT#?Lv=e@nKiO9td!DGq?RPL6lEndY53WgwO&Wkx@aoZ zUvP4+#wU3zibivwzu8QeaFQ&DjjAas^9rynx{GeToT_g{;fg=&P`YCD__uv#%7qx@;tmgW9kdckF1@SN64B zz5L$WiP!3q?$=Dsthc;=#@%`g5yf{~NB^F@dIcpx=cj`uFu*Z(Nt&JuObo zj7~DY`fq<+mwcpm_Yc3dlx7}j3va(Ze6#1mosNU}3hLlxzwxtuY5xcqIDg=N6cam4!zy_l literal 0 HcmV?d00001