Esempio n. 1
0
def req(url,post_data,headers):
    result = client.request(url, post=post_data,headers = headers)
    unpacked = ''
    packed = result.split('\n')
    for i in packed:
        try:
            unpacked += jsunpack.unpack(i)
        except:
            pass
    result += unpacked
    var = re.compile('var\s(.+?)\s*=\s*\'(.+?)\'').findall(result)
    vars = dict(var)
    result = re.sub('var.+?=.+?;','',result)
    for v in vars.keys():
        result = result.replace(v,vars[v])
    return result
Esempio n. 2
0
def resolve(url):
    try:
        try:
            referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
        except:
            referer=url
        id = urlparse.parse_qs(urlparse.urlparse(url).query)['u'][0]
        url = 'http://www.finecast.tv/embed4.php?u=%s&vw=640&vh=450'%id
        result = client.request(url, referer=referer)
        unpacked = ''
        packed = result.split('\n')
        for i in packed: 
            try: unpacked += jsunpack.unpack(i)
            except: pass
        result += unpacked
        result=result.replace('"+"','+').replace('+"','+').replace('"+','+')
        var = re.compile('var\s(.+?)\s*=\s*(?:\'|\"|\s*)(.+?)(?:\'|\"|\s*);').findall(result)
        result = re.sub(r"'(.+?)'", r'\1', result)

        rtmp=re.findall('file:\s*(.+?),',result)[0]
        m3u8=re.findall('file:\s*(.+?),',result)[1]
        
        #url = m3u8 + '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': referer})
        url = rtmp + ' swfUrl=http://www.finecast.tv/player6/jwplayer.flash.swf flashver=WIN\2019,0,0,185 live=1 timeout=14 swfVfy=1 pageUrl=http://www.finecast.tv/'

        for i in range(100):
            for v in var: result = result.replace('+%s+' % v[0], v[1])
            for v in var: result = result.replace('%s+' % v[0], v[1])
            for v in var: result = result.replace('+%s' % v[0], v[1])
        var = re.compile('var\s(.+?)\s*=\s*(?:\'|\"|\s*)(.+?)(?:\'|\"|\s*);').findall(result)
        for i in range(100):
            for v in var: url = url.replace('+%s+' % v[0], v[1])
            for v in var: url = url.replace('%s+' % v[0], v[1])
            for v in var: url = url.replace('+%s' % v[0], v[1])
        
        return url
    except:
        return
Esempio n. 3
0
def resolve(url):
    try:

        page = re.compile('//(.+?)/(?:embed|v)/([0-9a-zA-Z-_]+)').findall(url)[0]
        page = 'http://%s/embed/%s' % (page[0], page[1])
        try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
        except: referer = page
        try: host = urlparse.parse_qs(urlparse.urlparse(url).query)['host'][0]
        except: host = 'sawlive.tv'

        headers={'User-Agent': client.agent(),'Host': host, 'Referer': referer, 'Connection': 'keep-alive'}
        
        result = client.request(page, referer=referer)
        
        unpacked = ''
        packed = result.split('\n')
        for i in packed:
            try:
                unpacked += jsunpack.unpack(i)
            except:
                pass
        result += unpacked
        result = urllib.unquote_plus(result)
        rplcs = re.findall(';.+?=(.+?).replace\([\"\'](.+?)[\"\']\s*,\s*[\"\']([^\"\']*)[\"\']',result)
        url = client.parseDOM(result, 'iframe', ret='src')[-1]
        url = url.replace(' ', '').replace('+','')
        var = re.compile('var\s(.+?)\s*=\s*[\'\"](.+?)[\'\"]').findall(result)
        for i in range(100):
            for v in var: result = result.replace(" %s " % v[0], ' %s '%v[1])
        var = re.compile('var\s(.+?)\s*=\s*[\'\"](.+?)[\'\"]').findall(result)
        var_dict = dict(var)

        for v in var:
            if '+' in v[1]:
                ss = v[1].rstrip('+').replace('"+','').split('+')
                sg = v[1].rstrip('+').replace('"+','')
                for s in ss:
                    sg = sg.replace(s, var_dict[s])
                var_dict[v[0]]=sg.replace('+','')
                
        for i in range(100):
            for v in var_dict.keys(): url = url.replace("'%s'" % v, var_dict[v])
            for v in var_dict.keys(): url = url.replace("(%s)" % v, "(%s)" % var_dict[v])
        
        url = url.replace(' ', '').replace('+','').replace('"','').replace('\'','')
        for r in rplcs:
            url = url.replace(r[1],r[2])
        result = client.request(url, headers = headers, mobile=True)
        unpacked = ''
        packed = result.split('\n')
        for i in packed:
            try:
                unpacked += jsunpack.unpack(i)
            except:
                pass
        result += unpacked
        result = urllib.unquote_plus(result)
        var = re.compile('var\s(.+?)\s*=\s*[\'\"](.+?)[\'\"]').findall(result)
        rplcs = re.findall(';.+?=(.+?).replace\([\"\'](.+?)[\"\']\s*,\s*[\"\']([^\"\']*)[\"\']',result)
        var_dict = dict(var)       
        file = re.compile("'file'\s*(.+?)\)").findall(result)[0]
        file = file.replace('\'','')
            
        for v in var_dict.keys():
            file = file.replace(v,var_dict[v])
        file = file.replace('+','').replace(',','').strip().replace(' ', '')
        log("Sawlive: Found file url: " + file)
        if 'f4m' in file:
            return file
        try:
            log("Sawlive: Finding m3u8 link.")
            if not file.startswith('http'): raise Exception()
            url = client.request(file, output='geturl')
            if not '.m3u8' in url: raise Exception()
            url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': file})
            log("Sawlive: Found m3u8 link: " + url)
            return url
        except:
            log("Sawlive: m3u8 link not found, finding rtmp.")
            pass
        strm = re.compile("'streamer'\s*(.+?)\)").findall(result)[0]
        strm = strm.replace('\'','')
        for v in var_dict.keys():
            strm = strm.replace(v,var_dict[v])
        strm = strm.replace('+','').replace(',','').strip().replace(' ', '')
        swf = re.compile("SWFObject\('(.+?)'").findall(result)[0].replace(' ', '')

        url = '%s playpath=%s swfUrl=%s pageUrl=%s live=1 timeout=60' % (strm, file, swf, url)
        url = urllib.unquote(url).replace('unescape(','')

        for r in rplcs:
            url = url.replace(r[1],r[2])
        log("Sawlive: rtmp link found: " + url)
        return url
    except Exception as e:
        log("Sawlive exception:\n" + str(e))
        log("Sawlive: Resolver failed. Returning...")
        return
Esempio n. 4
0
def resolve(url):
    try:

        page = re.compile('//(.+?)/(?:embed|v)/([0-9a-zA-Z-_]+)').findall(url)[0]
        
        try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
        except: referer = page
        try: host = urlparse.parse_qs(urlparse.urlparse(url).query)['host'][0]
        except: host = 'www.sawlive.tv'
        page = 'http://sawlive.tv/embed/%s' % (page[1])
        headers={'User-Agent': client.agent(),'Host': host, 'Referer': referer, 'Connection': 'keep-alive'}
        result = client.request(page, referer=referer, headers = headers)
        
        unpacked = ''
        
        packed = result.split('\n')
        for i in packed:
            try:
                unpacked += jsunpack.unpack(i)
            except:
                pass
        result += unpacked
        result = urllib.unquote_plus(result)
        r2 = result
        resul = None
        try:
            url = client.parseDOM(result, 'iframe', ret='src')[-1]
        except:
            result = unpacked
            try:
                url = client.parseDOM(result, 'iframe', ret='src')[-1]
                var = re.compile('var\s(.+?)\s*=\s*[\'\"](.+?)[\'\"]').findall(result)
                var_dict = dict(var)       
                
                for v in var_dict.keys():
                    url = url.replace(v,var_dict[v])
                url = url.replace('\'','').replace('\"','').replace('+','').replace(' ','')
                resul = client.request(url, headers = headers)
            except:
                pass
        
        if resul is None:
            #aaa = r2.replace('var ','').replace('\' ','\' +').replace(' \'','+ \'')

            aaa = r2.replace('document.write(',' var result =').replace('\');','\'')
            aaa = aaa.replace('"\' +swidth+ \'"','')
            aaa = aaa.replace('"\' +sheight+ \'"','')
            aaa = re.sub('([^+\s])\s([^+\s])',r'\1+\2',aaa)
            aaa = aaa.replace('function+','function ')
            aaa = aaa.replace('var+','var ')
            aaa = aaa.replace('result+','result ')
            import js2py
            context = js2py.EvalJs()
            context.swidth = '400'
            context.sheight = '400'
            context.execute(aaa)
            result = context.result
            result = urllib.unquote_plus(result)
            url = client.parseDOM(result, 'iframe', ret='src')[-1]
            result = client.request(url, headers = headers)
        else:
            result = resul
        unpacked = ''
        packed = result.split('\n')
        for i in packed:
            try:
                unpacked += jsunpack.unpack(i)
            except:
                pass
        result += unpacked
        result = urllib.unquote_plus(result)
        var = re.compile('var\s(.+?)\s*=\s*[\'\"](.+?)[\'\"]').findall(result)
        rplcs = re.findall(';.+?=(.+?).replace\([\"\'](.+?)[\"\']\s*,\s*[\"\']([^\"\']*)[\"\']',result)
        var_dict = dict(var)       
        file = re.compile("'file'\s*(.+?)\)").findall(result)[0]
        file = file.replace('\'','')
            
        for v in var_dict.keys():
            file = file.replace(v,var_dict[v])
        file = file.replace('+','').replace(',','').strip().replace(' ', '')
        log("Sawlive: Found file url: " + file)
        if 'f4m' in file:
            return file
        try:
            log("Sawlive: Finding m3u8 link.")
            if not file.startswith('http'): raise Exception()
            url = client.request(file, output='geturl')
            if not '.m3u8' in url: raise Exception()
            url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': file})
            log("Sawlive: Found m3u8 link: " + url)
            return url
        except:
            log("Sawlive: m3u8 link not found, finding rtmp.")
            pass
        strm = re.compile("'streamer'\s*(.+?)\)").findall(result)[0]
        strm = strm.replace('\'','')
        for v in var_dict.keys():
            strm = strm.replace(v,var_dict[v])
        strm = strm.replace('+','').replace(',','').strip().replace(' ', '')
        swf = re.compile("SWFObject\('(.+?)'").findall(result)[0].replace(' ', '')

        url = '%s playpath=%s swfUrl=%s pageUrl=%s live=1 timeout=60' % (strm, file, swf, url)
        url = urllib.unquote(url).replace('unescape(','')

        for r in rplcs:
            url = url.replace(r[1],r[2])
        log("Sawlive: rtmp link found: " + url)
        return url
    except Exception as e:
        log("Sawlive exception:\n" + str(e))
        log("Sawlive: Resolver failed. Returning...")
        return
Esempio n. 5
0
def resolve(url):
    try:
        page = re.compile('//(.+?)/(?:embed|v)/([0-9a-zA-Z-_]+)').findall(url)[0]
        page = 'http://%s/embed/%s' % (page[0], page[1])
        try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
        except: referer = page

        try: host = urlparse.parse_qs(urlparse.urlparse(url).query)['host'][0]
        except: host = 'sawlive.tv'

        headers={'User-Agent': client.agent(),'Host': host, 'Referer': referer, 'Connection': 'keep-alive'}
        
        result = client.request(page, referer=referer)
        unpacked = ''
        packed = result.split('\n')
        for i in packed: 
            try: unpacked += jsunpack.unpack(i)
            except: pass
        result += unpacked
        result = urllib.unquote_plus(result)
        result = re.sub('\s\s+', ' ', result)
        url = client.parseDOM(result, 'iframe', ret='src')[-1]
        url = url.replace(' ', '')

        var = re.compile('var\s(.+?)\s*=\s*\'(.+?)\'').findall(result)
        for i in range(100):
            for v in var: url = url.replace("'%s'" % v[0], v[1])
            for v in var: url = url.replace("(%s)" % v[0], "(%s)" % v[1])

        url = re.sub(r"'unescape\((.+?)\)'", r'\1', url)
        url = re.sub(r"'(.+?)'", r'\1', url)

        #js functions replaced
        funcs = re.findall('function\s*(.+?)\((.+?)\){return\s*"?(.+?)\"?\;\}',result)
        params = re.findall(r"(un.+?)\((.+?)\)", url)
        funcs2 = re.findall('function\s*(.+?)\((.+?)\){var\s(.+?)\s*=\s*\'(.+?)\';return\s*"?(.+?)\"?\;\}',result)
        for p in params:
            for f in funcs:
                if p[0]==f[0]:
                    if 'unescape(' not in f[2]:
                        url = url.replace('%s(%s)'%(f[0],p[1]),f[2])
                    else:
                        url = url.replace('%s(%s)'%(p[0],p[1]),p[1])

            for f in funcs2:
                if p[0]==f[0]:
                    url = url.replace('%s(%s)'%(f[0],p[1]),f[3])
        result = client.request(url, headers=headers)
        file = re.compile("'file'.+?'(.+?)'").findall(result)[0]

        try:
            if not file.startswith('http'): raise Exception()
            url = client.request(file, output='geturl')
            if not '.m3u8' in url: raise Exception()
            url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': file})
            return url
        except:
            pass

        strm = re.compile("'streamer'.+?'(.+?)'").findall(result)[0]
        swf = re.compile("SWFObject\('(.+?)'").findall(result)[0]

        url = '%s playpath=%s swfUrl=%s pageUrl=%s live=1 timeout=30' % (strm, file, swf, url)
        return url
    except:
        return