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"
            #path = cConfig().getAddonPath().decode("utf-8")
            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
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        self.cptloc = kwargs.get('captcha')
        i = 0
        u = 0
        pos = []

        bg_image = 'special://home/addons/plugin.video.vstream/resources/art/background.png'
        check_image = 'special://home/addons/plugin.video.vstream/resources/art/trans_checked.png'

        self.ctrlBackground = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image)
        self.cancelled = False
        self.addControl(self.ctrlBackground)

        self.img = [0] * 6
        for img in self.cptloc:
            self.img[i] = xbmcgui.ControlImage(u, 400, 250, 200, img)
            self.addControl(self.img[i])
            i = i + 1
            pos.append(u)
            u = u + 250

        self.img[5] = xbmcgui.ControlImage(500, 0, 300, 400,
                                           kwargs.get('challenge'))
        self.addControl(self.img[5])

        self.chk = [0] * 5
        self.chkbutton = [0] * 5
        self.chkstate = [False] * 5

        i = 0
        while i < 5:
            if 1 == 2:
                self.chk[i] = xbmcgui.ControlCheckMark(
                    pos[i],
                    400,
                    250,
                    200,
                    str(i + 1),
                    font='font14',
                    focusTexture=check_image,
                    checkWidth=260,
                    checkHeight=166)

            else:
                self.chk[i] = xbmcgui.ControlImage(pos[i], 400, 250, 200,
                                                   check_image)

                self.chkbutton[i] = xbmcgui.ControlButton(pos[i],
                                                          400,
                                                          250,
                                                          200,
                                                          str(i + 1),
                                                          font='font1')

            i = i + 1

        for obj in self.chk:
            self.addControl(obj)
            obj.setVisible(False)
        for obj in self.chkbutton:
            self.addControl(obj)

        self.cancelbutton = xbmcgui.ControlButton(250 + 260 - 70,
                                                  620,
                                                  140,
                                                  50,
                                                  'Cancel',
                                                  alignment=2)
        self.okbutton = xbmcgui.ControlButton(250 + 520 - 50,
                                              620,
                                              100,
                                              50,
                                              'OK',
                                              alignment=2)
        self.addControl(self.okbutton)
        self.addControl(self.cancelbutton)

        self.chkbutton[0].controlDown(self.cancelbutton)
        self.cancelbutton.controlUp(self.chkbutton[0])
        self.chkbutton[1].controlDown(self.cancelbutton)
        self.okbutton.controlUp(self.chkbutton[4])
        self.chkbutton[2].controlDown(self.okbutton)
        self.chkbutton[3].controlDown(self.okbutton)
        self.chkbutton[4].controlDown(self.okbutton)

        self.chkbutton[0].controlLeft(self.chkbutton[4])
        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[3])
        self.chkbutton[3].controlLeft(self.chkbutton[2])
        self.chkbutton[3].controlRight(self.chkbutton[4])
        self.chkbutton[4].controlLeft(self.chkbutton[3])
        self.chkbutton[4].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[4])
        self.okbutton.controlUp(self.chkbutton[4])
        self.cancelbutton.controlDown(self.chkbutton[0])
        self.cancelbutton.controlUp(self.chkbutton[0])
Beispiel #3
0
    def __init__(self, *args, **kwargs):

        self.cptloc = kwargs.get('captcha')
        # self.img = xbmcgui.ControlImage(250, 110, 780, 499, '')
        # xbmc.sleep(500)
        self.img = xbmcgui.ControlImage(250, 110, 780, 499, self.cptloc)
        xbmc.sleep(500)

        bg_image = os.path.join( __addon__.getAddonInfo('path'), 'resources/art/' ) + 'background.png'
        check_image = os.path.join( __addon__.getAddonInfo('path'), 'resources/art/' ) + 'trans_checked.png'

        self.ctrlBackgound = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image)
        self.cancelled = False
        self.addControl (self.ctrlBackgound)

        self.strActionInfo = xbmcgui.ControlLabel(250, 20, 724, 400, 'Veuillez sélectionnez les images correspondants au thème.\nIl devrait y en avoir 3 ou 4 à sélectionner.', 'font40', '0xFFFF00FF')
        self.addControl(self.strActionInfo)

        self.msg = kwargs.get('msg')
        self.roundnum = kwargs.get('roundnum')
        self.strActionInfo = xbmcgui.ControlLabel(250, 70, 700, 300, 'Le thème est: ' + self.msg, 'font13', '0xFFFF00FF')
        self.addControl(self.strActionInfo)

        self.addControl(self.img)

        self.chk = [0]*9
        self.chkbutton = [0]*9
        self.chkstate = [False]*9

        if 1 == 2:
            self.chk[0]= xbmcgui.ControlCheckMark(250, 110, 260, 166, '1', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[1]= xbmcgui.ControlCheckMark(250 + 260, 110, 260, 166, '2', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[2]= xbmcgui.ControlCheckMark(250 + 520, 110, 260, 166, '3', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)

            self.chk[3]= xbmcgui.ControlCheckMark(250, 110 + 166, 260, 166, '4', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[4]= xbmcgui.ControlCheckMark(250 + 260, 110 + 166, 260, 166, '5', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[5]= xbmcgui.ControlCheckMark(250 + 520, 110 + 166, 260, 166, '6', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)

            self.chk[6]= xbmcgui.ControlCheckMark(250, 110 + 332, 260, 166, '7', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[7]= xbmcgui.ControlCheckMark(250 + 260, 110 + 332, 260, 166, '8', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)
            self.chk[8]= xbmcgui.ControlCheckMark(250 + 520, 110 + 332, 260, 166, '9', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166)

        else:
            self.chk[0]= xbmcgui.ControlImage(250, 110, 260, 166, check_image)
            self.chk[1]= xbmcgui.ControlImage(250 + 260, 110, 260, 166, check_image)
            self.chk[2]= xbmcgui.ControlImage(250 + 520, 110, 260, 166, check_image)

            self.chk[3]= xbmcgui.ControlImage(250, 110 + 166, 260, 166, check_image)
            self.chk[4]= xbmcgui.ControlImage(250 + 260, 110 + 166, 260, 166, check_image)
            self.chk[5]= xbmcgui.ControlImage(250 + 520, 110 + 166, 260, 166, check_image)

            self.chk[6]= xbmcgui.ControlImage(250, 110 + 332, 260, 166, check_image)
            self.chk[7]= xbmcgui.ControlImage(250 + 260, 110 + 332, 260, 166, check_image)
            self.chk[8]= xbmcgui.ControlImage(250 + 520, 110 + 332, 260, 166, check_image)

            self.chkbutton[0]= xbmcgui.ControlButton(250, 110, 260, 166, '1', font = 'font1');
            self.chkbutton[1]= xbmcgui.ControlButton(250 + 260, 110, 260, 166, '2', font = 'font1');
            self.chkbutton[2]= xbmcgui.ControlButton(250 + 520, 110, 260, 166, '3', font = 'font1');

            self.chkbutton[3]= xbmcgui.ControlButton(250, 110 + 166, 260, 166, '4', font = 'font1');
            self.chkbutton[4]= xbmcgui.ControlButton(250 + 260, 110 + 166, 260, 166, '5', font = 'font1');
            self.chkbutton[5]= xbmcgui.ControlButton(250 + 520, 110 + 166, 260, 166, '6', font = 'font1');

            self.chkbutton[6]= xbmcgui.ControlButton(250, 110 + 332, 260, 166, '7', font = 'font1');
            self.chkbutton[7]= xbmcgui.ControlButton(250 + 260, 110 + 332, 260, 166, '8', font = 'font1');
            self.chkbutton[8]= xbmcgui.ControlButton(250 + 520, 110 + 332, 260, 166, '9', font = 'font1');

        for obj in self.chk:
            self.addControl(obj)
            obj.setVisible(False)
        for obj in self.chkbutton:
            self.addControl(obj)

        self.cancelbutton = xbmcgui.ControlButton(250 + 260 - 70, 620, 140, 50, 'Cancel', alignment = 2)
        self.okbutton = xbmcgui.ControlButton(250 + 520 - 50, 620, 100, 50, '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]);
Beispiel #4
0
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")
    filename = "special://home/userdata/addon_data/plugin.video.vstream/Captcha.raw"

    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 = xbmcvfs.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()

            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
Beispiel #5
0
    def __init__(self, *args, **kwargs):

        self.cptloc = kwargs.get('captcha')
        self.img = xbmcgui.ControlImage(335, 200, 624, 400, "")
        xbmc.sleep(500)
        self.img = xbmcgui.ControlImage(335, 200, 624, 400, self.cptloc)
        xbmc.sleep(500)

        bg_image = os.path.join(__addon__.getAddonInfo('path'),
                                'resources/art/') + "background.png"
        check_image = os.path.join(__addon__.getAddonInfo('path'),
                                   'resources/art/') + "trans_checked.png"

        self.ctrlBackgound = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image)
        self.cancelled = False
        self.addControl(self.ctrlBackgound)
        self.msg = kwargs.get(
            'msg') + '\nNormalement il devrai y avoir en 3 ou 4 selection'
        self.roundnum = kwargs.get('roundnum')
        self.strActionInfo = xbmcgui.ControlLabel(335, 120, 700, 300,
                                                  "Le theme est : " + self.msg,
                                                  'font13', '0xFFFF00FF')
        self.addControl(self.strActionInfo)

        self.strActionInfo = xbmcgui.ControlLabel(
            335, 20, 724, 400,
            'Veuillez selectionnez les images correpondants au themes',
            'font40', '0xFFFF00FF')
        self.addControl(self.strActionInfo)

        self.addControl(self.img)

        self.chk = [0] * 9
        self.chkbutton = [0] * 9
        self.chkstate = [False] * 9

        if 1 == 2:
            self.chk[0] = xbmcgui.ControlCheckMark(335,
                                                   190,
                                                   220,
                                                   150,
                                                   '1',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[1] = xbmcgui.ControlCheckMark(335 + 200,
                                                   190,
                                                   220,
                                                   150,
                                                   '2',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[2] = xbmcgui.ControlCheckMark(335 + 400,
                                                   190,
                                                   220,
                                                   150,
                                                   '3',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)

            self.chk[3] = xbmcgui.ControlCheckMark(335,
                                                   190 + 130,
                                                   220,
                                                   150,
                                                   '4',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[4] = xbmcgui.ControlCheckMark(335 + 200,
                                                   190 + 130,
                                                   220,
                                                   150,
                                                   '5',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[5] = xbmcgui.ControlCheckMark(335 + 400,
                                                   190 + 130,
                                                   220,
                                                   150,
                                                   '6',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)

            self.chk[6] = xbmcgui.ControlCheckMark(335,
                                                   190 + 260,
                                                   220,
                                                   150,
                                                   '7',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[7] = xbmcgui.ControlCheckMark(335 + 200,
                                                   190 + 260,
                                                   220,
                                                   150,
                                                   '8',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
            self.chk[8] = xbmcgui.ControlCheckMark(335 + 400,
                                                   190 + 260,
                                                   220,
                                                   150,
                                                   '9',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=220,
                                                   checkHeight=150)
        else:

            self.chk[0] = xbmcgui.ControlImage(335, 190, 220, 150, check_image)
            self.chk[1] = xbmcgui.ControlImage(335 + 200, 190, 220, 150,
                                               check_image)
            self.chk[2] = xbmcgui.ControlImage(335 + 400, 190, 220, 150,
                                               check_image)

            self.chk[3] = xbmcgui.ControlImage(335, 190 + 130, 220, 150,
                                               check_image)
            self.chk[4] = xbmcgui.ControlImage(335 + 200, 190 + 130, 220, 150,
                                               check_image)
            self.chk[5] = xbmcgui.ControlImage(335 + 400, 190 + 130, 220, 150,
                                               check_image)

            self.chk[6] = xbmcgui.ControlImage(335, 190 + 260, 220, 150,
                                               check_image)
            self.chk[7] = xbmcgui.ControlImage(335 + 200, 190 + 260, 220, 150,
                                               check_image)
            self.chk[8] = xbmcgui.ControlImage(335 + 400, 190 + 260, 220, 150,
                                               check_image)

            self.chkbutton[0] = xbmcgui.ControlButton(335,
                                                      190,
                                                      210,
                                                      150,
                                                      '1',
                                                      font='font1')
            self.chkbutton[1] = xbmcgui.ControlButton(335 + 200,
                                                      190,
                                                      220,
                                                      150,
                                                      '2',
                                                      font='font1')
            self.chkbutton[2] = xbmcgui.ControlButton(335 + 400,
                                                      190,
                                                      220,
                                                      150,
                                                      '3',
                                                      font='font1')

            self.chkbutton[3] = xbmcgui.ControlButton(335,
                                                      190 + 130,
                                                      210,
                                                      150,
                                                      '4',
                                                      font='font1')
            self.chkbutton[4] = xbmcgui.ControlButton(335 + 200,
                                                      190 + 130,
                                                      220,
                                                      150,
                                                      '5',
                                                      font='font1')
            self.chkbutton[5] = xbmcgui.ControlButton(335 + 400,
                                                      190 + 130,
                                                      220,
                                                      150,
                                                      '6',
                                                      font='font1')

            self.chkbutton[6] = xbmcgui.ControlButton(335,
                                                      190 + 260,
                                                      210,
                                                      150,
                                                      '7',
                                                      font='font1')
            self.chkbutton[7] = xbmcgui.ControlButton(335 + 200,
                                                      190 + 260,
                                                      220,
                                                      150,
                                                      '8',
                                                      font='font1')
            self.chkbutton[8] = xbmcgui.ControlButton(335 + 400,
                                                      190 + 260,
                                                      220,
                                                      150,
                                                      '9',
                                                      font='font1')

        for obj in self.chk:
            self.addControl(obj)
            obj.setVisible(False)
        for obj in self.chkbutton:
            self.addControl(obj)

        self.cancelbutton = xbmcgui.ControlButton(335 + 312 - 100,
                                                  610,
                                                  100,
                                                  40,
                                                  'Cancel',
                                                  alignment=2)
        self.okbutton = xbmcgui.ControlButton(335 + 312 + 50,
                                              610,
                                              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 __init__(self, *args, **kwargs):
        self.cptloc = kwargs.get('captcha')
        i = 0
        u = 0
        pos = []

        bg_image = 'special://home/addons/plugin.video.vstream/resources/art/background.png'
        check_image = 'special://home/addons/plugin.video.vstream/resources/art/trans_checked.png'

        self.ctrlBackground = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image)
        self.cancelled = False
        self.addControl(self.ctrlBackground)

        self.img = [0] * 10

        self.strActionInfo = xbmcgui.ControlLabel(
            250, 20, 724, 400,
            'Veuillez sélectionnez l\'image qui ressemble le plus \n a l\'image qui se trouve le plus a gauche.',
            'font40', '0xFFFF00FF')
        self.addControl(self.strActionInfo)

        self.img[0] = xbmcgui.ControlImage(450, 110, 260, 166, self.cptloc[0])
        self.addControl(self.img[0])

        self.img[1] = xbmcgui.ControlImage(450 + 260, 110, 260, 166,
                                           self.cptloc[1])
        self.addControl(self.img[1])

        self.img[2] = xbmcgui.ControlImage(450 + 520, 110, 260, 166,
                                           self.cptloc[2])
        self.addControl(self.img[2])

        self.img[3] = xbmcgui.ControlImage(450, 110 + 166, 260, 166,
                                           self.cptloc[3])
        self.addControl(self.img[3])

        self.img[4] = xbmcgui.ControlImage(450 + 260, 110 + 166, 260, 166,
                                           self.cptloc[4])
        self.addControl(self.img[4])

        self.img[5] = xbmcgui.ControlImage(450 + 520, 110 + 166, 260, 166,
                                           self.cptloc[5])
        self.addControl(self.img[5])

        self.img[6] = xbmcgui.ControlImage(450, 110 + 332, 260, 166,
                                           self.cptloc[6])
        self.addControl(self.img[6])

        self.img[7] = xbmcgui.ControlImage(450 + 260, 110 + 332, 260, 166,
                                           self.cptloc[7])
        self.addControl(self.img[7])

        self.img[8] = xbmcgui.ControlImage(450 + 520, 110 + 332, 260, 166,
                                           self.cptloc[8])
        self.addControl(self.img[8])

        self.img[9] = xbmcgui.ControlImage(100, 80, 260, 166,
                                           kwargs.get('challenge'))
        self.addControl(self.img[9])

        self.chk = [0] * 9
        self.chkbutton = [0] * 9
        self.chkstate = [False] * 9

        if 1 == 2:
            self.chk[0] = xbmcgui.ControlCheckMark(450,
                                                   110,
                                                   260,
                                                   166,
                                                   '1',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[1] = xbmcgui.ControlCheckMark(450 + 260,
                                                   110,
                                                   260,
                                                   166,
                                                   '2',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[2] = xbmcgui.ControlCheckMark(450 + 520,
                                                   110,
                                                   260,
                                                   166,
                                                   '3',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)

            self.chk[3] = xbmcgui.ControlCheckMark(450,
                                                   110 + 166,
                                                   260,
                                                   166,
                                                   '4',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[4] = xbmcgui.ControlCheckMark(450 + 260,
                                                   110 + 166,
                                                   260,
                                                   166,
                                                   '5',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[5] = xbmcgui.ControlCheckMark(450 + 520,
                                                   110 + 166,
                                                   260,
                                                   166,
                                                   '6',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)

            self.chk[6] = xbmcgui.ControlCheckMark(450,
                                                   110 + 332,
                                                   260,
                                                   166,
                                                   '7',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[7] = xbmcgui.ControlCheckMark(450 + 260,
                                                   110 + 332,
                                                   260,
                                                   166,
                                                   '8',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)
            self.chk[8] = xbmcgui.ControlCheckMark(450 + 520,
                                                   110 + 332,
                                                   260,
                                                   166,
                                                   '9',
                                                   font='font14',
                                                   focusTexture=check_image,
                                                   checkWidth=260,
                                                   checkHeight=166)

        else:
            self.chk[0] = xbmcgui.ControlImage(450, 110, 260, 166, check_image)
            self.chk[1] = xbmcgui.ControlImage(450 + 260, 110, 260, 166,
                                               check_image)
            self.chk[2] = xbmcgui.ControlImage(450 + 520, 110, 260, 166,
                                               check_image)

            self.chk[3] = xbmcgui.ControlImage(450, 110 + 166, 260, 166,
                                               check_image)
            self.chk[4] = xbmcgui.ControlImage(450 + 260, 110 + 166, 260, 166,
                                               check_image)
            self.chk[5] = xbmcgui.ControlImage(450 + 520, 110 + 166, 260, 166,
                                               check_image)

            self.chk[6] = xbmcgui.ControlImage(450, 110 + 332, 260, 166,
                                               check_image)
            self.chk[7] = xbmcgui.ControlImage(450 + 260, 110 + 332, 260, 166,
                                               check_image)
            self.chk[8] = xbmcgui.ControlImage(450 + 520, 110 + 332, 260, 166,
                                               check_image)

            self.chkbutton[0] = xbmcgui.ControlButton(450,
                                                      110,
                                                      260,
                                                      166,
                                                      '1',
                                                      font='font1')
            self.chkbutton[1] = xbmcgui.ControlButton(450 + 260,
                                                      110,
                                                      260,
                                                      166,
                                                      '2',
                                                      font='font1')
            self.chkbutton[2] = xbmcgui.ControlButton(450 + 520,
                                                      110,
                                                      260,
                                                      166,
                                                      '3',
                                                      font='font1')

            self.chkbutton[3] = xbmcgui.ControlButton(450,
                                                      110 + 166,
                                                      260,
                                                      166,
                                                      '4',
                                                      font='font1')
            self.chkbutton[4] = xbmcgui.ControlButton(450 + 260,
                                                      110 + 166,
                                                      260,
                                                      166,
                                                      '5',
                                                      font='font1')
            self.chkbutton[5] = xbmcgui.ControlButton(450 + 520,
                                                      110 + 166,
                                                      260,
                                                      166,
                                                      '6',
                                                      font='font1')

            self.chkbutton[6] = xbmcgui.ControlButton(450,
                                                      110 + 332,
                                                      260,
                                                      166,
                                                      '7',
                                                      font='font1')
            self.chkbutton[7] = xbmcgui.ControlButton(450 + 260,
                                                      110 + 332,
                                                      260,
                                                      166,
                                                      '8',
                                                      font='font1')
            self.chkbutton[8] = xbmcgui.ControlButton(450 + 520,
                                                      110 + 332,
                                                      260,
                                                      166,
                                                      '9',
                                                      font='font1')

        for obj in self.chk:
            self.addControl(obj)
            obj.setVisible(False)
        for obj in self.chkbutton:
            self.addControl(obj)

        self.cancelbutton = xbmcgui.ControlButton(250 + 260 - 70,
                                                  620,
                                                  140,
                                                  50,
                                                  'Cancel',
                                                  alignment=2)
        self.okbutton = xbmcgui.ControlButton(250 + 520 - 50,
                                              620,
                                              100,
                                              50,
                                              '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])