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
Esempio n. 2
0
    def get_media_url(self, host, media_id):
        try:

            url = self.get_url(host, media_id)

            #Show dialog box so user knows something is happening
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving BillionUploads Link...')
            dialog.update(0)

            common.addon.log(self.name + '  - Requesting GET URL: %s' % url)

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

            if dialog.iscanceled(): return None
            dialog.update(25)

            #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

            if dialog.iscanceled(): return None

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

            if dialog.iscanceled(): return None
            dialog.update(50)

            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)

            if dialog.iscanceled(): return None
            dialog.update(75)

            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:
                    common.addon.log(self.name + ' - No Video File Found')
                    raise Exception('Unable to resolve - No Video File Found')

            if dialog.iscanceled(): return None
            dialog.update(100)

            return dl

        except Exception, e:
            common.addon.log_error(self.name + ' - Exception: %s' % e)
            return self.unresolvable(code=0, msg='Exception: %s' % e)
Esempio n. 3
0
def Captcha_Get_Reponse(img, cookie):

    # on telecharge l'image
    # PathCache = xbmc.translatePath(xbmcaddon.Addon("plugin.video.mando").getAddonInfo("profile"))
    # filename  = os.path.join(PathCache, "Captcha.raw").decode("utf-8")
    filename = "special://home/userdata/addon_data/plugin.video.mando/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.mando"
            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
Esempio n. 4
0
    elif param.startswith('cachename='):
        CacheName = arg[10:]

    elif param.startswith('images='):
        ImagesStr = arg[7:]

    elif param.startswith('separator='):
        Separator = arg[10:]

    elif param == 'window':
        Window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
    elif param.startswith('window='):
        Window = xbmcgui.Window(int(arg[7:]))
    elif param == 'dialog':
        Window = xbmcgui.WindowDialog(xbmcgui.getCurrentWindowDialogId())
    elif param.startswith('dialog='):
        test = int(arg[7:])
        Window = xbmcgui.WindowDialog(int(arg[7:]))

    elif param.startswith('force='):
        if param[6:] == 'true':
            OnlyIfMoreThanOne = False

    elif param.startswith('debug='):
        if param[6:] == 'true':
            DEBUG_ENABLED = True

if Window == None:
    Window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
Esempio n. 5
0
def handle_captchas(url, html, data, dialog):

    headers = {'Referer': url}

    puzzle_img = os.path.join(datapath, "solve_puzzle.png")

    #Check for type of captcha used
    solvemedia = re.search('<iframe src="(http://api.solvemedia.com.+?)"',
                           html)
    recaptcha = re.search(
        '<script type="text/javascript" src="(http://www.google.com.+?)">',
        html)
    numeric_captcha = re.compile(
        "left:(\d+)px;padding-top:\d+px;'>&#(.+?);<").findall(html)

    #SolveMedia captcha
    if solvemedia:
        dialog.close()
        html = net.http_GET(solvemedia.group(1), headers=headers).content
        hugekey = re.search('id="adcopy_challenge" value="(.+?)">',
                            html).group(1)

        #Check for alternate puzzle type - stored in a div
        alt_puzzle = re.search('<div><iframe src="(/papi/media.+?)"', html)
        if alt_puzzle:
            open(puzzle_img, 'wb').write(
                net.http_GET("http://api.solvemedia.com%s" %
                             alt_puzzle.group(1)).content)
        else:
            open(puzzle_img, 'wb').write(
                net.http_GET("http://api.solvemedia.com%s" % re.search(
                    '<img src="(/papi/media.+?)"', html).group(1)).content)

        img = xbmcgui.ControlImage(450, 15, 400, 130, puzzle_img)
        wdlg = xbmcgui.WindowDialog()
        wdlg.addControl(img)
        wdlg.show()

        xbmc.sleep(3000)

        kb = xbmc.Keyboard('', 'Type the letters in the image', False)
        kb.doModal()
        capcode = kb.getText()

        if (kb.isConfirmed()):
            userInput = kb.getText()
            if userInput != '':
                solution = kb.getText()
            elif userInput == '':
                raise Exception(
                    'You must enter text in the image to access video')
        else:
            wdlg.close()
            raise Exception('Captcha Error')
        wdlg.close()
        data.update({'adcopy_challenge': hugekey, 'adcopy_response': solution})

    #Google Recaptcha
    elif recaptcha:
        dialog.close()
        html = net.http_GET(recaptcha.group(1), headers=headers).content
        part = re.search("challenge \: \\'(.+?)\\'", html)
        captchaimg = 'http://www.google.com/recaptcha/api/image?c=' + part.group(
            1)
        img = xbmcgui.ControlImage(450, 15, 400, 130, captchaimg)
        wdlg = xbmcgui.WindowDialog()
        wdlg.addControl(img)
        wdlg.show()

        xbmc.sleep(3000)

        kb = xbmc.Keyboard('', 'Type the letters in the image', False)
        kb.doModal()
        capcode = kb.getText()

        if (kb.isConfirmed()):
            userInput = kb.getText()
            if userInput != '':
                solution = kb.getText()
            elif userInput == '':
                raise Exception(
                    'You must enter text in the image to access video')
        else:
            wdlg.close()
            raise Exception('Captcha Error')
        wdlg.close()
        data.update({
            'recaptcha_challenge_field': part.group(1),
            'recaptcha_response_field': solution
        })

    #Numeric captcha - we can programmatically figure this out
    elif numeric_captcha:
        result = sorted(numeric_captcha, key=lambda ltr: int(ltr[0]))
        solution = ''.join(str(int(num[1]) - 48) for num in result)
        data.update({'code': solution})

    return data
Esempio n. 6
0
    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 = urlparse.urlparse(self.base_url).hostname
        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 = urlparse.urlparse(self.base_url).hostname
                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 = urlparse.urlparse(self.base_url).hostname
                    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
Esempio n. 7
0
def get_response(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',
        '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 (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', 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
Esempio n. 8
0
    def getMovieLinkFromXML(self, url):
        try:
            IMAGEFILE = os.path.join(self.control.dataPath, 'efilmytv.jpg')
            cookie = self.s.get(urlparse.urljoin(mainUrl, url), verify=False).cookies.get_dict()
            for i in cookie:
                cookie = i + '=' + cookie[i]
            HEADER = {'Referer': urlparse.urljoin(mainUrl, url),
                      'Cookie':cookie,
                      'User-Agent': self.cache.get(self.control.randomagent, 1)}
            result = self.s.get(urlparse.urljoin(mainUrl, url), headers=HEADER).text
            myfile1 = re.compile(
                '<div id="(.*?)" alt="n" class="embedbg"><img src="(.*?)"/></div><div class="versionholder">').findall(
                result)
            if 'serial' in url:
                myurl = 'http://www.efilmy.tv/seriale.php?cmd=show_player&id=' + myfile1[0][0]
            else:
                #        http://www.efilmy.tv//filmy.php?cmd=show_player&id=87787
                myurl = 'http://www.efilmy.tv//filmy.php?cmd=show_player&id='+ myfile1[0][0]
            self.control.log("url %s " % myurl)
            link2 = self.request(urlparse.urljoin(mainUrl, myurl), headers=HEADER)

            if '<p><strong>Zabezpieczenie przeciwko robotom</strong></p>' in link2:
                mymatch = re.compile(
                    '<input type="hidden" name="id" value=(\d+) />\r\n<input type="hidden" name="mode" value=(\w+) />').findall(
                    link2)
                self.control.log("mymatch %s" % str(mymatch))
                link20 =  self.s.get('http://www.efilmy.tv//mirrory.php?cmd=generate_captcha&time=' + str(random.randint(1, 1000)), stream=True)
                if link20.status_code == 200:
                    with open(IMAGEFILE, 'wb') as f:
                        for chunk in link20:
                            f.write(chunk)

                img = xbmcgui.ControlImage(450, 0, 400, 130, IMAGEFILE)
                wdlg = xbmcgui.WindowDialog()
                wdlg.addControl(img)
                wdlg.show()
                kb = xbmc.Keyboard('', '[CR][CR]Przepisz litery z obrazka', False)
                kb.doModal()
                if (kb.isConfirmed()):
                    solution = kb.getText()
                    if solution == '':
                        raise Exception('You must enter text in the image to access video')
                else:
                    dialog = xbmcgui.Dialog()
                    dialog.ok(" Problem", " Nie wprowadzono kodu Captcha")
                    return ''
                xbmc.sleep(2 * 1000)

                postdata = {'captcha': solution, "id": str(mymatch[0][0]), "mode": str(mymatch[0][1])}
                HEADER['Referer'] = myurl
                #http://www.efilmy.tv//mirrory.php?cmd=check_captcha
                r = self.s.post("http://www.efilmy.tv//mirrory.php?cmd=check_captcha", data=postdata, headers=HEADER)
                link2 = r.text

            # myfile2 = re.compile('Base64.decode\("(.*?)"\)').findall(link2)
            myfile2 = re.search('(eval\(function\(p,a,c,k,e,d\).+)\s+?', link2)
            self.control.log("m2 %s " % myfile2.group(1))
            if myfile2:
                r = unpackstd.unpack(myfile2.group(1))
                r = r.decode('string-escape')
                self.control.log("m3 %s " % r)

                r1 = re.compile('Base64.decode\("(.*?)"\)').findall(r)
                r1 = r1[0]
                # r1 =r1.replace('\\\\','\\')

                import base64
                self.control.log("m4 %s " % r1)
                r = ''
                for byte in r1.split('\\x'):
                    if byte:  # to get rid of empties
                        r += chr(int(byte, 16))

                decode = base64.b64decode(r)
                # decode =decode.replace('\\\\','\\')
                r2 = self.client.parseDOM(decode.lower(), 'iframe', ret='src')[0]
                self.control.log("m2 %s " % r2)
                return self.urlresolve(r2)
            return

        except Exception as e:
            self.control.log('ERROR %s' % e)
            return None
Esempio n. 9
0
    def get_media_url(self, host, media_id):
        try:
            url = 'http://' + host + '/' + media_id
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving BillionUploads Link...')
            dialog.update(0)

            html = net.http_GET(url).content
            if re.search('File Not Found', html):
                common.addon.log_error('BillionUploads - File Not Found')
                raise Exception('File Not Found or removed')
            common.addon.show_countdown(3,
                                        title='BillionUploads',
                                        text='Loading Video...')

            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)

            html = net.http_POST(url, data).content
            dialog.update(100)
            link = re.search('&product_download_url=(.+?)"', html).group(1)
            link = link + "|referer=" + url
            dialog.close()
            mediaurl = link

            return mediaurl

        except Exception, e:
            common.addon.log_error('**** BillionUploads Error occured: %s' % e)
            common.addon.show_small_popup(
                title='[B][COLOR white]BILLIONUPLOADS[/COLOR][/B]',
                msg='[COLOR red]%s[/COLOR]' % e,
                delay=5000,
                image=error_logo)
            return False
			else:
				xbmcgui.Dialog().ok(addonname, "Video grabber has been detected but video0 does not exist. Please install drivers or use different disto")
		else:
			xbmcgui.Dialog().ok(addonname, "We have not detected the grabber. Grabber-v4l2 section will not be added to the config file.")
			
	xbmcgui.Dialog().ok(addonname, "That's all! Now we will attempt to restart hyperion...")
	hyperion_configuration.save_config_file(hyperion_configuration.create_config(),new_hyperion_config_path)	
	hyperion_configuration.restart_hyperion(new_hyperion_config_path)

	if not xbmcgui.Dialog().yesno(addonname, "Have you seen the rainbow swirl? (sometimes it does not appear, if you're sure that correct led type is selected, answer YES anyway, save config as default and reboot)"):
		xbmcgui.Dialog().ok(addonname, "Something went wrong... Please try running hyperion from command line to see the error... ("+run_command+")")
		sys.exit()
	else:
		xbmcgui.Dialog().ok(addonname, "For the next 10 seconds you will see test image and leds should adjust to that image. Check if the leds are showing the right colors in the right places."+
			" If not, start this wizard again and provide correct numbers of leds horizontally and vertically.")
		okno = xbmcgui.WindowDialog(xbmcgui.getCurrentWindowId())
		obrazek = xbmcgui.ControlImage(0,0,1280,720,addon_dir+"/test_picture.png")
		okno.addControl(obrazek)
		okno.show()
		obrazek.setVisible(True)
		hyperion_configuration.show_test_image(addon_dir+"/test_picture.png")
		time.sleep(10)
		okno.close()
		hyperion_configuration.clear_leds()

	if xbmcgui.Dialog().yesno(addonname, "Do you want to save this config as your default one?","(if No, changes will be lost after hyperion/system restart)"):
		hyperion_configuration.overwrite_default_config()
	elif xbmcgui.Dialog().yesno(addonname, "Hyperion is now running with the newly created config. Would you like to restart hyperion with previous config?"):
		hyperion_configuration.restart_hyperion(default_config_path)

	xbmcgui.Dialog().ok(addonname, "That\'s all Folks! :) . Enjoy!", "If you'd like to fine tune advanced parameters, please modify addon settings before running it","You may need to restart your system...")
Esempio n. 11
0
    def get_media_url(self, host, media_id):
        try:
            url = self.get_url(host, media_id)
            html = self.net.http_GET(url).content
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving Clicktoview Link...')
            dialog.update(0)

            data = {}
            r = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)">',
                           html)
            for name, value in r:
                data[name] = value
                data.update({'method_free': 'Create Streaming Link'})

            html = net.http_POST(url, data).content
            r = re.findall(r'type="hidden" name="(.+?)" value="(.+?)">', html)
            for name, value in r:
                data[name] = value
            captchaimg = re.search(
                '<script type="text/javascript" src="(http://www.google.com.+?)">',
                html)

            if captchaimg:
                dialog.close()
                html = self.net.http_GET(captchaimg.group(1)).content
                part = re.search("challenge \: \\'(.+?)\\'", html)
                captchaimg = 'http://www.google.com/recaptcha/api/image?c=' + part.group(
                    1)
                img = xbmcgui.ControlImage(450, 15, 400, 130, captchaimg)
                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 != '':
                        solution = kb.getText()
                    elif userInput == '':
                        Notify(
                            'big', 'No text entered',
                            'You must enter text in the image to access video',
                            '')
                        return False
                else:
                    return False
                wdlg.close()
                dialog.close()
                dialog.create('Resolving', 'Resolving Clicktoview Link...')
                dialog.update(50)
                data.update({
                    'recaptcha_challenge_field': part.group(1),
                    'recaptcha_response_field': solution
                })

            else:
                captcha = re.compile(
                    "left:(\d+)px;padding-top:\d+px;'>&#(.+?);<").findall(html)
                result = sorted(captcha, key=lambda ltr: int(ltr[0]))
                solution = ''.join(str(int(num[1]) - 48) for num in result)
                data.update({'code': solution})

            html = net.http_POST(url, data).content

            sPattern = '<script type=(?:"|\')text/javascript(?:"|\')>(eval\('
            sPattern += 'function\(p,a,c,k,e,d\)(?!.+player_ads.+).+np_vid.+?)'
            sPattern += '\s+?</script>'
            r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
            if r:
                sJavascript = r.group(1)
                sUnpacked = jsunpack.unpack(sJavascript)
                sPattern = '<embed id="np_vid"type="video/divx"src="(.+?)'
                sPattern += '"custommode='
                r = re.search(sPattern, sUnpacked)
                if r:
                    dialog.update(100)
                    dialog.close()
                    return r.group(1)

            else:
                pre = 'http://shmatka.wmff.org:182/d/'
                preb = re.compile('\|(.+?)\|video\|(.+?)\|').findall(html)
                for ext, link in preb:
                    r = pre + link + '/video.' + ext
                    dialog.update(100)
                    dialog.close()
                    return r

        except Exception, e:
            common.addon.log('**** Clicktoview Error occured: %s' % e)
            common.addon.show_small_popup('Error', str(e), 5000, '')
            return False
Esempio n. 12
0
    def get_media_url(self, host, media_id):
        try:
            url = 'http://'+host+'/'+media_id
            #Show dialog box so user knows something is happening
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving BillionUploads Link...')       
            dialog.update(0)
        
            print 'BillionUploads - Requesting GET URL: %s' %url
            html = net.http_GET(url).content
               
            #Check page for any error msgs
            if re.search('This server is in maintenance mode', html):
                print '***** BillionUploads - Site reported maintenance mode'
                raise Exception('File is currently unavailable on the host')

            #Captcha
            captchaimg = re.search('<img src="((http://)?[bB]illion[uU]ploads.com/captchas/.+?)"', html).group(1)
        
            dialog.close()
        
            #Grab Image and display it
            img = xbmcgui.ControlImage(550,15,240,100,captchaimg)
            wdlg = xbmcgui.WindowDialog()
            wdlg.addControl(img)
            wdlg.show()
        
            #Small wait to let user see image
            time.sleep(3)
        
            #Prompt keyboard for user input
            kb = xbmc.Keyboard('', 'Type the letters in the image', False)
            kb.doModal()
            capcode = kb.getText()
        
            #Check input
            if (kb.isConfirmed()):
              userInput = kb.getText()
              if userInput != '':
                  capcode = kb.getText()
              elif userInput == '':
                   Notify('big', 'No text entered', 'You must enter text in the image to access video', '')
                   return None
            else:
                return None
            wdlg.close()

            #They need to wait for the link to activate in order to get the proper 2nd page
            dialog.close()
            #do_wait('Waiting on link to activate', '', 3)
            time.sleep(3)  
            dialog.create('Resolving', 'Resolving BillionUploads Link...') 
            dialog.update(50)
        
            #Set POST data values
            op = 'download2'
            rand = re.search('<input type="hidden" name="rand" value="(.+?)">', html).group(1)
            postid = re.search('<input type="hidden" name="id" value="(.+?)">', html).group(1)
            method_free = re.search('<input type="hidden" name="method_free" value="(.*?)">', html).group(1)
            down_direct = re.search('<input type="hidden" name="down_direct" value="(.+?)">', html).group(1)
                
            data = {'op': op, 'rand': rand, 'id': postid, 'referer': url, 'method_free': method_free, 'down_direct': down_direct, 'code': capcode}
        
            print 'BillionUploads - Requesting POST URL: %s DATA: %s' % (url, data)
            html = net.http_POST(url, data).content
            dialog.update(100)
            link = re.search('&product_download_url=(.+?)"', html).group(1)
            link = link + "|referer=" + url
            dialog.close()
            mediaurl = link
        
            return mediaurl

        except Exception, e:
            print '**** BillionUploads Error occured: %s' % e
            raise
Esempio n. 13
0
    def get_media_url(self, host, media_id):
        print '180upload: in get_media_url %s %s' % (host, media_id)
        web_url = self.get_url(host, media_id)
        try:
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving 180Upload Link...')
            dialog.update(0)
        
            puzzle_img = os.path.join(datapath, "180_puzzle.png")
        
            print '180Upload - Requesting GET URL: %s' % web_url
            html = net.http_GET(web_url).content

            dialog.update(50)
                
            data = {}
            r = re.findall(r'type="hidden" name="(.+?)" value="(.+?)">', html)

            if r:
                for name, value in r:
                    data[name] = value
            else:
                raise Exception('Unable to resolve 180Upload Link')
        
            #Check for SolveMedia Captcha image
            solvemedia = re.search('<iframe src="(http://api.solvemedia.com.+?)"', html)

            if solvemedia:
                dialog.close()
                html = net.http_GET(solvemedia.group(1)).content
                hugekey=re.search('id="adcopy_challenge" value="(.+?)">', html).group(1)
                open(puzzle_img, 'wb').write(net.http_GET("http://api.solvemedia.com%s" % re.search('<img src="(.+?)"', html).group(1)).content)
                img = xbmcgui.ControlImage(450,15,400,130, puzzle_img)
                wdlg = xbmcgui.WindowDialog()
                wdlg.addControl(img)
                wdlg.show()
        
                xbmc.sleep(3000)

                kb = xbmc.Keyboard('', 'Type the letters in the image', False)
                kb.doModal()
                capcode = kb.getText()
   
                if (kb.isConfirmed()):
                    userInput = kb.getText()
                    if userInput != '':
                        solution = kb.getText()
                    elif userInput == '':
                        Notify('big', 'No text entered', 'You must enter text in the image to access video', '')
                        return False
                else:
                    return False
               
                wdlg.close()
                dialog.create('Resolving', 'Resolving 180Upload Link...') 
                dialog.update(50)
                if solution:
                    data.update({'adcopy_challenge': hugekey,'adcopy_response': solution})

            print '180Upload - Requesting POST URL: %s' % web_url
            html = net.http_POST(web_url, data).content
            dialog.update(100)
        
            link = re.search('<a href="(.+?)" onclick="thanks\(\)">Download now!</a>', html)
            if link:
                print '180Upload Link Found: %s' % link.group(1)
                return link.group(1)
            else:
                raise Exception('Unable to resolve 180Upload Link')

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 5000, error_logo)
            return False
Esempio n. 14
0
AddonTitle = addon.getAddonInfo('name')

addon_id = addon.getAddonInfo('id')

ADDON = xbmcaddon.Addon(id=addon_id)

execute = xbmc.executebuiltin

addonInfo = xbmcaddon.Addon().getAddonInfo

dialog = xbmcgui.Dialog()

progressDialog = xbmcgui.DialogProgress()

windowDialog = xbmcgui.WindowDialog()

artwork = xbmcvfs.translatePath(
    os.path.join(
        'special://home', 'addons', addon_id,
        'art/')) if sys.version_info >= (3, 0, 0) else xbmc.translatePath(
            os.path.join('special://home', 'addons', addon_id, 'art/'))

fanart = artwork + 'fanart.jpg'

level = xbmc.LOGINFO if sys.version_info >= (3, 0, 0) else xbmc.LOGNOTICE


def get_path():
    return addon.getAddonInfo('path')
    def get_media_url(self, host, media_id):
        try:
            url = self.get_url(host, media_id)
            html = self.net.http_GET(url).content
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving Megarelease Link...')
            dialog.update(0)

            data = {}
            r = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)">',
                           html)
            for name, value in r:
                data[name] = value
                data.update({'plugins_are_not_allowed_plus_ban': 2})
            captchaimg = re.search(
                '<script type="text/javascript" src="(http://www.google.com.+?)">',
                html)

            if captchaimg:
                dialog.close()
                html = self.net.http_GET(captchaimg.group(1)).content
                part = re.search("challenge \: \\'(.+?)\\'", html)
                captchaimg = 'http://www.google.com/recaptcha/api/image?c=' + part.group(
                    1)
                img = xbmcgui.ControlImage(450, 15, 400, 130, captchaimg)
                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 != '':
                        solution = kb.getText()
                    elif userInput == '':
                        Notify(
                            'big', 'No text entered',
                            'You must enter text in the image to access video',
                            '')
                        return False
                else:
                    return False
                wdlg.close()
                dialog.close()
                dialog.create('Resolving', 'Resolving Clicktoview Link...')
                dialog.update(50)
                data.update({
                    'recaptcha_challenge_field': part.group(1),
                    'recaptcha_response_field': solution
                })

            html = net.http_POST(url, data).content
            dialog.update(50)

            sPattern = '<script type=(?:"|\')text/javascript(?:"|\')>(eval\('
            sPattern += 'function\(p,a,c,k,e,d\)(?!.+player_ads.+).+np_vid.+?)'
            sPattern += '\s+?</script>'
            r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
            if r:
                sJavascript = r.group(1)
                sUnpacked = jsunpack.unpack(sJavascript)
                sPattern = '<embed id="np_vid"type="video/divx"src="(.+?)'
                sPattern += '"custommode='
                r = re.search(sPattern, sUnpacked)
                if r:
                    dialog.update(100)
                    dialog.close()
                    return r.group(1)
            else:
                num = re.compile(
                    'false\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|divx').findall(html)
                print 'NUM' + str(num)
                for u1, u2, u3, u4 in num:
                    urlz = u4 + '.' + u3 + '.' + u2 + '.' + u1
                pre = 'http://' + urlz + ':182/d/'
                preb = re.compile('custommode\|(.+?)\|(.+?)\|182').findall(
                    html)
                for ext, link in preb:
                    r = pre + link + '/video.' + ext
                    dialog.update(100)
                    dialog.close()
                    return r

        except urllib2.URLError, e:
            common.addon.log_error(self.name +
                                   ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error', 'Http error: ' + str(e),
                                          8000, error_logo)
            return False
Esempio n. 16
0
    def get_media_url(self, host, media_id):
        try:
            url = self.get_url(host, media_id)
            puzzle_img = os.path.join(common.profile_path, "hugefiles_puzzle.png")

            #Show dialog box so user knows something is happening
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving HugeFiles Link...')       
            dialog.update(0)
            
            common.addon.log('HugeFiles - Requesting GET URL: %s' % url)
            html = self.net.http_GET(url).content
            r = re.findall('File Not Found',html)
            if r:
                raise Exception ('File Not Found or removed')
                            
            dialog.update(50)
            
            #Check page for any error msgs
            if re.search('<b>File Not Found</b>', html):
                common.addon.log('***** HugeFiles - File Not Found')
                raise Exception('File Not Found')
    
            #Set POST data values
            data = {}
            r = re.findall(r'type="hidden" name="(.+?)" value="(.+?)">', html)
            
            if r:
                for name, value in r:
                    data[name] = value
            else:
                common.addon.log('***** HugeFiles - Cannot find data values')
                raise Exception('Unable to resolve HugeFiles Link')
            
            data['method_free'] = 'Free Download'
            file_name = data['fname']
    
            #Check for SolveMedia Captcha image
            solvemedia = re.search('<iframe src="(http://api.solvemedia.com.+?)"', html)
            recaptcha = re.search('<script type="text/javascript" src="(http://www.google.com.+?)">', html)
    
            if solvemedia:
               dialog.close()
               html = self.net.http_GET(solvemedia.group(1)).content
               hugekey=re.search('id="adcopy_challenge" value="(.+?)">', html).group(1)
               open(puzzle_img, 'wb').write(net.http_GET("http://api.solvemedia.com%s" % re.search('<img src="(.+?)"', html).group(1)).content)
               img = xbmcgui.ControlImage(450,15,400,130, puzzle_img)
               wdlg = xbmcgui.WindowDialog()
               wdlg.addControl(img)
               wdlg.show()
            
               xbmc.sleep(3000)
    
               kb = xbmc.Keyboard('', 'Type the letters in the image', False)
               kb.doModal()
               capcode = kb.getText()
       
               if (kb.isConfirmed()):
                   userInput = kb.getText()
                   if userInput != '':
                       solution = kb.getText()
                   elif userInput == '':
                       Notify('big', 'No text entered', 'You must enter text in the image to access video', '')
                       return False
               else:
                   return False
                   
               wdlg.close()
               dialog.create('Resolving', 'Resolving HugeFiles Link...') 
               dialog.update(50)
               if solution:
                   data.update({'adcopy_challenge': hugekey,'adcopy_response': solution})

            elif recaptcha:
                dialog.close()
                html = self.net.http_GET(recaptcha.group(1)).content
                part = re.search("challenge \: \\'(.+?)\\'", html)
                captchaimg = 'http://www.google.com/recaptcha/api/image?c='+part.group(1)
                img = xbmcgui.ControlImage(450,15,400,130,captchaimg)
                wdlg = xbmcgui.WindowDialog()
                wdlg.addControl(img)
                wdlg.show()
        
                xbmc.sleep(3000)
        
                kb = xbmc.Keyboard('', 'Type the letters in the image', False)
                kb.doModal()
                capcode = kb.getText()
        
                if (kb.isConfirmed()):
                    userInput = kb.getText()
                    if userInput != '':
                        solution = kb.getText()
                    elif userInput == '':
                        raise Exception ('You must enter text in the image to access video')
                else:
                    raise Exception ('Captcha Error')
                wdlg.close()
                dialog.close() 
                dialog.create('Resolving', 'Resolving HugeFiles Link...') 
                dialog.update(50)
                data.update({'recaptcha_challenge_field':part.group(1),'recaptcha_response_field':solution})

            else:
                captcha = re.compile("left:(\d+)px;padding-top:\d+px;'>&#(.+?);<").findall(html)
                result = sorted(captcha, key=lambda ltr: int(ltr[0]))
                solution = ''.join(str(int(num[1])-48) for num in result)
                data.update({'code':solution})

            common.addon.log('HugeFiles - Requesting POST URL: %s DATA: %s' % (url, data))
            html = net.http_POST(url, data).content
            
            #Get download link
            dialog.update(100)
    
            sPattern = '''<div id="player_code">.*?<script type='text/javascript'>(eval.+?)</script>'''
            r = re.findall(sPattern, html, re.DOTALL|re.I)
            if r:
                sUnpacked = jsunpack.unpack(r[0])
                sUnpacked = sUnpacked.replace("\\'","")
                r = re.findall('file,(.+?)\)\;s1',sUnpacked)
                if not r:
                   r = re.findall('name="src"[0-9]*="(.+?)"/><embed',sUnpacked)
                if not r:
                    r = re.findall('<param name="src"value="(.+?)"/>', sUnpacked)
                return r[0]
            else:
                common.addon.log('***** HugeFiles - Cannot find final link')
                raise Exception('Unable to resolve HugeFiles Link')
        

        except urllib2.HTTPError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 5000, error_logo)
            return self.unresolvable(code=3, msg=e)
Esempio n. 17
0
def notify():
    wdlg = xbmcgui.WindowDialog()
    img = xbmcgui.ControlImage(0, 0, 1280, 720, template)
    wdlg.addControl(img)
    wdlg.doModal()