Ejemplo n.º 1
0
def get_video_url(page_url,
                  premium=False,
                  user="",
                  password="",
                  video_password=""):
    global data
    logger.info("url=" + page_url)

    video_urls = list()
    host = "https://dood.to"
    label = scrapertools.find_single_match(data, 'type:\s*"video/([^"]+)"')

    js_code = scrapertools.find_single_match(data,
                                             ("(function makePlay.*?;})"))
    js_code = re.sub(r"\+Date.now\(\)", '', js_code)
    js = js2py.eval_js(js_code)
    makeplay = js() + str(int(time.time() * 1000))

    base_url = scrapertools.find_single_match(data, r"\$.get\('(/pass[^']+)'")
    data = httptools.downloadpage("%s%s" % (host, base_url),
                                  headers={
                                      "referer": page_url
                                  }).data
    data = re.sub(r'\s+', '', data)

    url = data + makeplay + "|Referer=%s" % page_url
    video_urls.append(['%s [doodstream]' % label, url])

    return video_urls
Ejemplo n.º 2
0
def get_video_url(page_url,
                  premium=False,
                  user="",
                  password="",
                  video_password=""):
    global data
    logger.info("url=" + page_url)
    video_urls = list()
    label = scrapertools.find_single_match(data, r'type:\s*"video/([^"]+)"')
    js_code = scrapertools.find_single_match(data,
                                             ("(function\s?makePlay.*?;})"))

    js_code = re.sub(r"\+Date.now\(\)", '', js_code)
    js = js2py.eval_js(js_code)
    makeplay = js() + str(int(time.time() * 1000))

    base_url = scrapertools.find_single_match(data, r"\$.get\('(/pass[^']+)'")

    new_data = httptools.downloadpage("%s%s" % (host, base_url),
                                      add_referer=True).data
    retries = 0
    while "We are checking your browser" in new_data and retries < 3:
        new_data = httptools.downloadpage("%s%s" % (host, base_url),
                                          add_referer=True).data
        retries += 1
    if retries > 3:
        return video_urls

    new_data = re.sub(r'\s+', '', new_data)
    url = new_data + makeplay + "|Referer=%s" % page_url
    video_urls.append(['%s [doodstream]' % label, url])

    return video_urls
Ejemplo n.º 3
0
    def solve_challenge(self, body, domain):
        try:
            js = re.search(r"setTimeout\(function\(\){\s+(var "
                        "s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n", body).group(1)
        except Exception:
            raise ValueError("Unable to identify Cloudflare IUAM Javascript on website. %s" % BUG_REPORT)

        js = re.sub(r"a\.value = (.+ \+ t\.length).+", r"\1", js)
        js = re.sub(r"\s{3,}[a-z](?: = |\.).+", "", js).replace("t.length", str(len(domain)))

        # Strip characters that could be used to exit the string context
        # These characters are not currently used in Cloudflare's arithmetic snippet
        js = re.sub(r"[\n\\']", "", js)

        if "toFixed" not in js:
            raise ValueError("Error parsing Cloudflare IUAM Javascript challenge. %s" % BUG_REPORT)

        try:
            result = js2py.eval_js(js)
        except Exception:
            logging.error("Error executing Cloudflare IUAM Javascript. %s" % BUG_REPORT)
            raise

        try:
            float(result)
        except Exception:
            raise ValueError("Cloudflare IUAM challenge returned unexpected answer. %s" % BUG_REPORT)

        return result
Ejemplo n.º 4
0
def get_video_url(page_url, premium=False, user="", password="", video_password=""):
    logger.info("(page_url='%s')" % page_url)
    video_urls = []
    global page_data
    dec = scrapertools.find_single_match(page_data, '(\$=~\[\];.*?\(\)\))\(\);')
    # needed to increase recursion
    import sys
    sys.setrecursionlimit(10000)

    deObfCode = js2py.eval_js(dec)

    video_urls.append(['mp4 [mystream]', scrapertools.find_single_match(str(deObfCode), "'src',\s*'([^']+)")])
    return video_urls
Ejemplo n.º 5
0
def get_video_url(page_url, premium=False, user="", password="", video_password=""):
    logger.info("url=" + page_url)

    video_urls = []
    # Code taken from Kodi On Demand (KOD)
    # https://github.com/kodiondemand/addon/blob/master/servers/streamtape.py
    find_url = scrapertools.find_multiple_matches(data, 'innerHTML = ([^;]+)')[-1]
    possible_url = js2py.eval_js(find_url)
    url = "https:" + possible_url
    url = httptools.downloadpage(url, follow_redirects=False, only_headers=True).headers.get("location", "")

    video_urls.append(['MP4 [streamtape]', "{}|{}".format(url, "User-Agent=%s" % httptools.get_user_agent())])

    return video_urls
Ejemplo n.º 6
0
def get_video_url(page_url,
                  premium=False,
                  user="",
                  password="",
                  video_password=""):
    logger.debug("url=" + page_url)
    video_urls = []
    find_url = match(data, patron=r'innerHTML = ([^;]+)').matches[-1]
    possible_url = js2py.eval_js(find_url)
    url = "https:" + possible_url
    url = httptools.downloadpage(url,
                                 follow_redirects=False,
                                 only_headers=True).headers.get(
                                     "location", "")
    video_urls.append(['MP4 [Streamtape]', url])
    return video_urls
Ejemplo n.º 7
0
def get_data(item, head=[]):
    global headers
    jstr = ''
    for h in head:
        headers[h[0]] = h[1]
    if not item.count: item.count = 0
    if not config.get_setting('key', item.channel):
        matches = support.match(
            item,
            patron=r'<script>(.*?location.href=".*?(http[^"]+)";)</').match
        if matches:
            jstr, location = matches
            item.url = support.re.sub(r':\d+', '',
                                      location).replace('http://', 'https://')
        if jstr:
            jshe = 'var document = {}, location = {}'
            aesjs = str(support.match(host + '/aes.min.js').data)
            js_fix = 'window.toHex = window.toHex || function(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}'
            jsret = 'return document.cookie'
            key_data = js2py.eval_js('function (){ ' + jshe + '\n' + aesjs +
                                     '\n' + js_fix + '\n' + jstr + '\n' +
                                     jsret + '}')()
            key = key_data.split(';')[0]

            # save Key in settings
            config.set_setting('key', key, item.channel)

    # set cookie
    headers['cookie'] = config.get_setting('key', item.channel)
    res = support.match(item,
                        headers=headers,
                        patron=r';\s*location.href=".*?(http[^"]+)"')
    if res.match:
        item.url = res.match.replace('http://', 'https://')
        data = support.match(item, headers=headers).data
    else:
        data = res.data

    #check that the key is still valid
    if 'document.cookie=' in data and item.count < 3:
        item.count += 1
        config.set_setting('key', '', item.channel)
        return get_data(item)
    return data
Ejemplo n.º 8
0
    def solve_challenge(self, body, domain):
        try:
            js = re.search(
                r"setTimeout\(function\(\){\s+(var "
                "s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n",
                body).group(1)
        except Exception:
            raise ValueError(
                "Unable to identify Cloudflare IUAM Javascript on website. %s"
                % BUG_REPORT)

        js = re.sub(r"a\.value = (.+ \+ t\.length).+", r"\1", js)
        js = re.sub(r"\s{3,}[a-z](?: = |\.).+", "",
                    js).replace("t.length", str(len(domain)))

        # Strip characters that could be used to exit the string context
        # These characters are not currently used in Cloudflare's arithmetic snippet
        js = re.sub(r"[\n\\']", "", js)

        if "toFixed" not in js:
            raise ValueError(
                "Error parsing Cloudflare IUAM Javascript challenge. %s" %
                BUG_REPORT)

        try:
            result = js2py.eval_js(js)
        except Exception:
            logging.error("Error executing Cloudflare IUAM Javascript. %s" %
                          BUG_REPORT)
            raise

        try:
            float(result)
        except Exception:
            raise ValueError(
                "Cloudflare IUAM challenge returned unexpected answer. %s" %
                BUG_REPORT)

        return result
Ejemplo n.º 9
0
def unpack(source):
    fun, data = re.match("""eval\((function\(p,a,c,k,e,d\){.*?})\((['"].*?)\)\)$""", source.strip(), re.MULTILINE).groups()
    funPy = js2py.eval_js(fun)
    return eval('funPy(' + data + ')')