UI Recaptcha

This commit is contained in:
Alhaziel01
2021-11-22 16:35:12 +01:00
parent 377044a879
commit 94262e9a0c
3 changed files with 227 additions and 114 deletions

View File

@@ -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)

View File

@@ -1,97 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<window>
<allowoverlays>false</allowoverlays>
<animation type="WindowOpen" reversible="false">
<effect type="zoom" start="80" end="100" center="640,225" delay="160" tween="back" time="240" />
<effect type="fade" delay="160" end="100" time="240" />
<defaultcontrol>11</defaultcontrol>
<animation type='WindowOpen' reversible='false'>
<effect type='zoom' start='80' end='100' center='640,225' delay='160' tween='back' time='240' />
<effect type='fade' delay='160' end='100' time='240' />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="zoom" start="100" end="80" center="640,225" easing="in" tween="back" time="240" />
<effect type="fade" start="100" end="0" time="240" />
<animation type='WindowClose' reversible='false'>
<effect type='zoom' start='100' end='80' center='640,225' easing='in' tween='back' time='240' />
<effect type='fade' start='100' end='0' time='240' />
</animation>
<controls>
<control type="group" id="10001">
<top>40</top>
<left>390</left>
<width>600</width>
<height>640</height>
<control type="image">
<width>510</width>
<height>640</height>
<left>45</left>
<texture>Controls/dialog-bg-solid.png</texture>
<control type='group'>
<top>40</top>
<left>398</left>
<width>484</width>
<height>640</height>
<control type='image'>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='FF232323'>white.png</texture>
</control>
<control type='image' id='12'>
<description>Main Captcha Image</description>
<top>90</top>
<left>20</left>
<width>444</width>
<height>444</height>
</control>
<control type='label' id='10'>
<top>20</top>
<left>20</left>
<height>60</height>
<width>444</width>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<wrapmultiline>true</wrapmultiline>
<align>center</align>
<aligny>center</aligny>
<label></label>
</control>
<control type='panel' id='11'>
<left>20</left>
<top>90</top>
<ondown>21</ondown>
<itemlayout height='148' width='148' condition='Integer.IsEqual(Container(11).NumItems, 9)'>
<control type='image'>
<description>Override Image</description>
<width>100%</width>
<height>100%</height>
<texture>$INFO[ListItem.Art(image)]</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='FFFFFFFF' border='2'>selection.png</texture>
</control>
<control type='image'>
<visible>String.IsEqual(ListItem.Property(selected), true)</visible>
<description>Selected Image</description>
<width>100%</width>
<height>100%</height>
<texture>Controls/check_mark.png</texture>
</control>
</itemlayout>
<itemlayout height='111' width='111'>
<control type='image'>
<description>Override Image</description>
<width>100%</width>
<height>100%</height>
<texture>$INFO[ListItem.Art(image)]</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='FFFFFFFF' border='2'>selection.png</texture>
</control>
<control type='image'>
<visible>String.IsEqual(ListItem.Property(selected), true)</visible>
<description>Selected Image</description>
<width>100%</width>
<height>100%</height>
<texture>Controls/check_mark.png</texture>
</control>
</itemlayout>
<focusedlayout height='148' width='148' condition='Integer.IsEqual(Container(11).NumItems, 9)'>
<control type='image'>
<description>Override Image</description>
<width>100%</width>
<height>100%</height>
<texture>$INFO[ListItem.Art(image)]</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='FF0082C2' border='2'>selection.png</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='550082C2'>white.png</texture>
</control>
<control type='image'>
<visible>String.IsEqual(ListItem.Property(selected), true)</visible>
<description>Selected Image</description>
<width>100%</width>
<height>100%</height>
<texture>Controls/check_mark.png</texture>
</control>
</focusedlayout>
<focusedlayout height='111' width='111'>
<control type='image'>
<description>Override Image</description>
<width>100%</width>
<height>100%</height>
<texture>$INFO[ListItem.Art(image)]</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='880082C2' border='2'>selection.png</texture>
</control>
<control type='image'>
<description>Focused</description>
<width>100%</width>
<height>100%</height>
<texture colordiffuse='550082C2'>white.png</texture>
</control>
<control type='image'>
<visible>String.IsEqual(ListItem.Property(selected), true)</visible>
<description>Selected Image</description>
<width>100%</width>
<height>100%</height>
<texture>Controls/check_mark.png</texture>
</control>
</focusedlayout>
</control>
<control type='grouplist'>
<top>565</top>
<left>20</left>
<orientation>horizontal</orientation>
<control type='button' id='21'>
<width>150</width>
<height>50</height>
<onup>11</onup>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse='FF0082C2'>white.png</texturefocus>
<texturenofocus colordiffuse='000082C2'>white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70007]</label>
</control>
<control type='button' id='22'>
<width>150</width>
<height>50</height>
<onup>11</onup>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse='FF0082C2'>white.png</texturefocus>
<texturenofocus colordiffuse='000082C2'>white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 707433]</label>
</control>
<control type='button' id='23'>
<width>150</width>
<height>50</height>
<onup>11</onup>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse='FF0082C2'>white.png</texturefocus>
<texturenofocus colordiffuse='000082C2'>white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70008]</label>
</control>
</control>
</control>
<control type="textbox" id="10000">
<top>30</top>
<left>20</left>
<height>60</height>
<width>560</width>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<wrapmultiline>true</wrapmultiline>
<align>center</align>
<label></label>
</control>
<control type="button" id="10002">
<top>565</top>
<left>75</left>
<width>150</width>
<height>50</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse="FF0082C2">white.png</texturefocus>
<texturenofocus colordiffuse="000082C2">white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70007]</label>
<onup>10011</onup>
<ondown>10005</ondown>
<onleft>10004</onleft>
<onright>10003</onright>
</control>
<control type="button" id="10003">
<top>565</top>
<left>225</left>
<width>150</width>
<height>50</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse="FF0082C2">white.png</texturefocus>
<texturenofocus colordiffuse="000082C2">white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 707433]</label>
<onup>10012</onup>
<ondown>10006</ondown>
<onleft>10002</onleft>
<onright>10004</onright>
</control>
<control type="button" id="10004">
<top>565</top>
<left>375</left>
<width>150</width>
<height>50</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<focusedcolor>FFFFFFFF</focusedcolor>
<texturefocus colordiffuse="FF0082C2">white.png</texturefocus>
<texturenofocus colordiffuse="000082C2">white.png</texturenofocus>
<align>center</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70008]</label>
<onup>10013</onup>
<ondown>10007</ondown>
<onleft>10003</onleft>
<onright>10002</onright>
</control>
<control type="image" id="10020">
<top>90</top>
<left>75</left>
<width>450</width>
<height>450</height>
</control>
</control>
</controls>
</window>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB