Esempio n. 1
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            video_id = re.search("""playvideo\.php\?id=(\d+)""", html)
            if video_id:
                video_url = 'http://%s/jwplayer/playvideo.php?id=%s' % (
                    host, video_id.group(1))
                headers.update({'Referer': web_url})
                _html = self.net.http_GET(video_url, headers=headers).content
                if _html:
                    try:
                        _html = jsunpack.unpack(_html)
                    except Exception as e:
                        raise ResolverError(e)
                    sources = helpers.scrape_sources(
                        _html,
                        patterns=['''file:\s*["'](?P<url>http[^"']+)'''])
                    if sources:
                        return helpers.pick_source(
                            sources) + helpers.append_headers(headers)

        raise ResolverError('File not found')
Esempio n. 2
0
 def __method5(self, response):
     ''' http://videobug.se/vid/pVobcNozEWmTkarNnwX06w
     '''
     html = response.content
     streams = []
     if jsunpack.detect(html):
         streams = self._extract_streams(jsunpack.unpack(html))
     return streams
 def __method5(self, response):
     ''' http://videobug.se/vid/pVobcNozEWmTkarNnwX06w
     '''
     html = response.content
     streams = []
     if jsunpack.detect(html):
         streams = self._extract_streams(jsunpack.unpack(html))
     return streams
def get_packed_data(html):
    packed_data = ''
    for match in re.finditer(r'(eval\s*\(function.*?)</script>', html,
                             re.DOTALL | re.I):
        if jsunpack.detect(match.group(1)):
            packed_data += jsunpack.unpack(match.group(1))

    return packed_data
Esempio n. 5
0
def get_packed_data(html):
    packed_data = ''
    for match in re.finditer(r'(eval\s*\(function.*?)</script>', html, re.DOTALL | re.I):
        try:
            js_data = jsunpack.unpack(match.group(1))
            js_data = js_data.replace('\\', '')
            packed_data += js_data
        except:
            pass

    return packed_data
Esempio n. 6
0
 def get_media_url(self, host, media_id):
     web_url = self.get_url(host, media_id)
     headers = {'User-Agent': common.RAND_UA, 'Referer': web_url}
     html = self.net.http_GET(web_url, headers=headers).content
     r = re.search(r"text/javascript'>(eval.*?)\s*</script>", html,
                   re.DOTALL)
     if r:
         html = jsunpack.unpack(r.group(1))
         src = re.search(r'file:"([^"]+)"', html)
         if src:
             return src.group(1) + helpers.append_headers(headers)
     raise ResolverError('Video cannot be located.')
Esempio n. 7
0
    def get_videos(self, url):
        videos = []
        if 'cinebix.com' in url:
            self.resolve_media(url, videos)
            return videos

        html = requests.get(url, headers=self.hdr).text

        try:
            linkcode = jsunpack.unpack(html).replace('\\', '')
            sources = json.loads(re.findall('sources:(.*?)\}\)', linkcode)[0])
            for source in sources:
                url = source['file'] + '|Referer=http://tamilgun.pro'
                url = urllib.quote_plus(url)
                videos.append(('tamilgun.pro | %s' % source['label'], url))
        except:
            pass

        mlink = SoupStrainer('div', {'id': 'videoframe'})
        videoclass = BeautifulSoup(html, parseOnlyThese=mlink)

        try:
            links = videoclass.findAll('iframe')
            for link in links:
                url = link.get('src')
                self.resolve_media(url, videos)
        except:
            pass

        mlink = SoupStrainer('div', {'class': 'entry-excerpt'})
        videoclass = BeautifulSoup(html, parseOnlyThese=mlink)

        try:
            links = videoclass.findAll('iframe')
            for link in links:
                if 'http' in str(link):
                    url = link.get('src')
                    self.resolve_media(url, videos)
        except:
            pass

        try:
            sources = json.loads(re.findall('vdf-data-json">(.*?)<', html)[0])
            url = 'https://www.youtube.com/watch?v=%s' % sources['videos'][0][
                'youtubeID']
            self.resolve_media(url, videos)
        except:
            pass

        return videos
Esempio n. 8
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA, 'Referer': web_url}
        html = self.net.http_GET(web_url, headers=headers).content

        r = re.findall(r'JuicyCodes\.Run\("([^)]+)"\)', html)

        if r:
            jc = r[-1].replace('"+"', '')
            jc = base64.b64decode(jc.encode('ascii'))
            jc = jsunpack.unpack(jc.decode('ascii'))
            sources = helpers.scrape_sources(jc)
            return helpers.pick_source(sources) + helpers.append_headers(
                headers)

        raise ResolverError('Video cannot be located.')
Esempio n. 9
0
    def _extract_streams(self, html):
        '''Return list of streams (tuples (url, label))
        '''
        streams = [] # list of tuples (url, label)

        if jsunpack.detect(html):
            urls = re.findall(r'file:\"(.+?)\"', jsunpack.unpack(html))
            for url in urls:
                if ".jpg" in url:
                    urls.remove(url)
            labels = []
            for i in range(len(urls)):
                labels.append('Stream ' + str(i + 1))
            streams = zip(urls, labels)

        return streams
Esempio n. 10
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {
            'User-Agent': common.IOS_USER_AGENT,
            'Referer': web_url
        }
        stream_url = ''
        new_host = urllib_parse.urlparse(web_url).netloc
        html = self.net.http_GET(web_url, headers=headers).content
        if 'videozoo' not in new_host:
            r = re.search(r'(?:playlist:|timer\s*=\s*null;).+?url\s*[:=]+\s*[\'"]+(.+?)[\'"]+', html, re.DOTALL)
        else:
            r = re.search(r'\*/\s+?(eval\(function\(p,a,c,k,e,d\).+)\s+?/\*', html)
            if r:
                try:
                    r = jsunpack.unpack(r.group(1))
                    if r:
                        r = re.search(r'\[{"url":"(.+?)"', r.replace('\\', ''))
                except:
                    if r:
                        re_src = re.search(r'urlResolvers\|2F(.+?)\|', r.group(1))
                        re_url = re.search(r'php\|3D(.+?)\|', r.group(1))
                        if re_src and re_url:
                            stream_url = 'http://%s/%s.php?url=%s' % (new_host, re_src.group(1), re_url.group(1))
                            stream_url = self._redirect_test(stream_url)
                        else:
                            raise ResolverError('File not found')
        if r:
            stream_url = urllib_parse.unquote_plus(r.group(1))
            if 'http' not in stream_url:
                stream_url = 'http://' + host + '/' + stream_url.replace('/gplus.php', 'gplus.php').replace('/picasa.php', 'picasa.php')
            stream_url = self._redirect_test(stream_url)

        if stream_url:
            if 'google' in stream_url:
                return HostedMediaFile(url=stream_url).resolve()
            else:
                return stream_url
        else:
            raise ResolverError('File not found')
Esempio n. 11
0
def resolve(url):
    try:
        headers = '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': url})

        url = url.replace('/embed-', '/')
        url = re.compile('//.+?/([\w]+)').findall(url)[0]
        url = 'http://vid.ag/embed-%s.html' % url

        result = client.request(url, mobile=True)

        result = re.compile('(eval.*?\)\)\))').findall(result)[-1]
        result = jsunpack.unpack(result)

        result = re.compile('sources *: *\[.+?\]').findall(result)[-1]
        result = re.compile('file *: *"(http.+?)"').findall(result)

        url = [i for i in result if '.m3u8' in i]
        if len(url) > 0: return url[0] + headers

        url = [i for i in result if not '.m3u8' in i]
        if len(url) > 0: return url[0] + headers
    except:
        return
Esempio n. 12
0
def JSunpack(src):
    #	import resolveurl
    #	from resolveurl.plugins.lib import jsunpack
    return jsunpack.unpack(src)
    def _extract_streams(self, html):
        '''Return list of streams (tuples (url, label))
        '''
        streams = [] # list of tuples (url, label)

        df = re.search(r"dF\(\\?'(.*)\\?'\)", html)
        if df:
            script_end = html.find('</script>', df.end())
            script_end = script_end + 9 if script_end > -1 else -1
            unobscured = ''
            result = False
            for key in range(1, 255):
                unobscured = self._unobscurify(df.group(1), key)
                result = bool(BeautifulSoup(unobscured, "html5lib").find('script'))
                if result:
                    break

            if not result:
                raise ResolverError('Videobug resolver: error unobscurifying dF()')

            html = html[:script_end] + unobscured + html[script_end:]
        else:
            raise ResolverError('Videobug resolver: no dF() found')

        # Allupload
        # http://videobug.se/vid-a/g2S5k34-MoC2293iUaa9Hw
        json_data = re.findall(r"json_data = '(.+)';", html)
        if json_data:
            strdecode_1 = lambda s: base64.b64decode(urllib.unquote(s)[::-1]) # no longer used?
            strdecode_2 = lambda s: base64.b64decode(urllib.unquote(s))
            try:
                hashes = json.loads(json_data[0])
                exclude = ['Subtitles', 'image', 'JS', 'ADV']
                videos = [h for h in hashes if h['s'] not in exclude]
                # try both decode methods
                try:
                    streams = [(strdecode_1(h['u']), h['s']) for h in videos]
                except Exception:
                    streams = [(strdecode_2(h['u']), h['s']) for h in videos]
            except Exception:
                pass

        # Picasaweb, Videobug
        # http://videobug.se/video/Wz3_oCoEYozRSbJFQo4fkjmuvR6LpsFHM-XZya5tuk6stTXWdUeyplq5vVvSm0Yr0MXPFUmLt2XqrbLMPnE_Mgz8NbhXMZ6XFDI4hj253Z7af95WQPPDlpizIuuUXavEJqB8-bXuKbx6HTCMb5p5FC90yg1kXJb6?
        if not streams:
            soup = BeautifulSoup(html, 'html5lib')
            player_func = re.compile(r'(player_[^\(]+)\(\);').match
            butts = soup.find_all('input', type='button', onclick=player_func)

            funcs = [player_func(b['onclick']).group(1) for b in butts]
            labels = [b['value'] for b in butts]

            try:
                func_bodies = [re.findall(r'%s\(\) *{(.+)};' % f, html)[0] for f in funcs]
                re_flash = re.compile(r"video *= *{[^:]+: *'(.*?)' *}")
                re_html5 = re.compile(r'<source.*?src=\"(.*?)\"')

                urls = [(re_flash.findall(fb) or re_html5.findall(fb))[0] for fb in func_bodies]
                streams = zip(urls, labels)
            except Exception:
                pass

        # http://videobug.se/vid-al/XNkjCT5pBx1YlndruYWdWg?&caption=-sgCv7BkuLZn41-ZxxJZhTsKYcZIDgJPGYNOuIpulC_4kcrZ9k3fGQabH5rDAKgiLMVJdesVZPs
        if not streams:
            vids = re.findall(r'''{ *file *: *strdecode\('(.+?)'\).*?label *: *"(.*?)"''', html)
            for cryptic_url, label in vids:
                url = base64.b64decode(urllib.unquote(cryptic_url)[::-1])
                streams.append((url, label))

        # http://videobug.se/vid/pVobcNozEWmTkarNnwX06w
        if not streams:
            if jsunpack.detect(html):
                streams = self._extract_streams(jsunpack.unpack(html))

        # remove this hardcoded youtube link
        streams = [(u, l) for u, l in streams if u != 'https://www.youtube.com/watch?v=niBTIQIYlv8']

        return streams
Esempio n. 14
0
def JSunpack(src):
	#	import resolveurl
	#	from resolveurl.plugins.lib import jsunpack
	return jsunpack.unpack(src)