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
        html = helpers.get_packed_data(html)
        r = re.search(r"op:\s*'([^']+)',\s*file_code:\s*'([^']+)',\s*hash:\s*'([^']+)'", html)
        if r:
            url = 'https://playtube.ws/dl'
            data = {'op': r.group(1),
                    'file_code': r.group(2),
                    'hash': r.group(3)}
            headers.update({'Referer': url[:-2],
                            'Origin': url[:-3]})

            vfile = seed = None
            tries = 0
            while tries < 3 and vfile is None and seed is None:
                resp = self.net.http_POST(url, form_data=data, headers=headers).content
                resp = json.loads(resp)[0]
                vfile = resp.get('file')
                seed = resp.get('seed')
                tries += 1
            source = helpers.tear_decode(vfile, seed)
            if source:
                return source + helpers.append_headers(headers)
        raise ResolverError('File not found')
예제 #2
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        headers.update({'Referer': web_url})

        if 'sorry' in html:
            raise ResolverError("Video Deleted")

        r = re.search(r"redirect_vid\('([^']+)','([^']+)','([^']+)'", html)
        if r:
            surl = 'https://{0}/dl?op=download_orig&id={1}&mode={2}&hash={3}'.format(
                host, r.group(1), r.group(2), r.group(3)
            )
            dhtml = self.net.http_GET(surl, headers=headers).content
            s = re.search('href="([^"]+)">Direct', dhtml)
            if s:
                return s.group(1) + helpers.append_headers(headers)

        html += helpers.get_packed_data(html)
        sources = helpers.scrape_sources(html,
                                         patterns=[r'''sources:\s*\[(?:{file:)?\s*"(?P<url>[^"]+)'''],
                                         generic_patterns=False)
        if sources:
            return helpers.pick_source(sources) + helpers.append_headers(headers)

        raise ResolverError("Video not found")
예제 #3
0
    def get_media_url(self, host, media_id):
        if '$$' in media_id:
            media_id, referer = media_id.split('$$')
            referer = urllib_parse.urljoin(referer, '/')
        else:
            referer = False

        web_url = self.get_url(host, media_id)
        if not referer:
            referer = urllib_parse.urljoin(web_url, '/')

        headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': referer}

        html = self.net.http_GET(web_url, headers=headers).content
        if 'Please Wait' in html:
            raise ResolverError('Please Wait Video Uploading.')

        html = helpers.get_packed_data(html)
        sources = re.findall(
            r"label':\s*'(?P<label>[^']+).+?file':\s*'(?P<url>[^']+)", html)
        if sources:
            source = helpers.pick_source(sorted(sources, reverse=True))
            if source.startswith('/'):
                source = urllib_parse.urljoin(web_url, source)
            return source + helpers.append_headers(headers)

        raise ResolverError('No playable video found.')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        blurl = 'https://{0}/api/assets/userload/js/form.framework.js'.format(
            host)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content
        html = helpers.get_packed_data(html)
        headers.update({'Referer': web_url})
        bl = self.net.http_GET(blurl, headers=headers).content
        if jsunhunt.detect(bl):
            bl = jsunhunt.unhunt(bl)
        b1 = re.search(r'url:\s*"([^"]+)', bl)
        b2 = re.search(r'data:\s*{([^}]+)', bl)
        if b1 and b2:
            bd = re.findall(r'"([^"]+)":\s*([^,\s]+)', b2.group(1))
            data = {}
            for key, var in bd:
                r = re.search(r'{0}\s*=\s*"([^"]+)'.format(var), html)
                if r:
                    data.update({key: r.group(1)})

            if data:
                api_url = 'https://{0}{1}'.format(host, b1.group(1))
                headers.update({
                    'X-Requested-With': 'XMLHttpRequest',
                    'Origin': 'https://{0}'.format(host)
                })
                stream_url = self.net.http_POST(api_url, data,
                                                headers=headers).content
                headers.pop('X-Requested-With')
                stream_url = helpers.get_redirect_url(stream_url, headers)
                return stream_url + helpers.append_headers(headers)

        raise ResolverError('File not found')
예제 #5
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.FF_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content

        html = helpers.get_packed_data(html)
        sources = re.search(r'sources:\s*(\[[^]]+])', html)
        if sources:
            sources = json.loads(sources.group(1))
            sources = [(x.get('label'), x.get('file')) for x in sources]
            source = helpers.pick_source(sorted(sources, reverse=True))
            return source + helpers.append_headers(headers)

        raise ResolverError('No playable video found.')
예제 #6
0
    def get_media_url(self, host, media_id):

        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content

        html += helpers.get_packed_data(html)
        sources = helpers.scrape_sources(html)

        if sources:
            headers.update({'Referer': web_url})
            return self._redirect_test(
                helpers.pick_source(sources)) + helpers.append_headers(headers)
        else:
            raise ResolverError("Video not found")
예제 #7
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'Origin': 'https://{}'.format(host),
                   'Referer': 'https://{}/'.format(host),
                   'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if '(p,a,c,k,e,d)' in html:
            html = helpers.get_packed_data(html)
        r = re.search(r'(?:vsr|wurl|surl)[^=]*=\s*"([^"]+)', html)
        if r:
            headers = {'User-Agent': common.RAND_UA, 'Referer': web_url}
            return "https:" + r.group(1) + helpers.append_headers(headers)

        raise ResolverError("Video not found")
예제 #8
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.FF_USER_AGENT}
        r = self.net.http_GET(web_url, headers=headers)
        cookie = ''
        for item in r.get_headers(as_dict=True)['Set-Cookie'].split('GMT,'):
            cookie += item.split('path')[0]
        headers.update({'Cookie': cookie + 'sugamun=1; invn=1; pfm=1'})

        html = self.net.http_GET(web_url, headers=headers).content
        html += helpers.get_packed_data(html)
        source = re.search(r'''file:\s*["'](?P<url>http[^"']+)["']''', html)
        headers.pop('Cookie')
        if source:
            return source.group(1) + helpers.append_headers(headers)

        raise ResolverError('Video not found')
    def get_media_url(self, host, media_id):

        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content

        html += helpers.get_packed_data(html)
        sources = helpers.scrape_sources(html)

        if sources:
            headers.update({'Referer': web_url})
            vurl = helpers.pick_source(sources)
            vurl = re.sub('get[a-zA-Z]{4}-', 'getlink-', vurl)
            return helpers.get_redirect_url(
                vurl, headers) + helpers.append_headers(headers)

        raise ResolverError("Video not found")
예제 #10
0
    def get_media_url(self, host, media_id):

        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content

        if '<b>File not found, sorry!</b>' not in html:
            html += helpers.get_packed_data(html)
            v = re.search(r"player\s*=\s*.*?'([^']+)", html)
            if v:
                vurl = re.search(
                    r'''{0}".+?src:\s*'([^']+)'''.format(v.group(1)), html)
                if vurl:
                    return helpers.get_redirect_url(
                        vurl.group(1),
                        headers) + helpers.append_headers(headers)

        raise ResolverError('Video not found or removed')
예제 #11
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 'p,a,c,k,e' in html:
            html = helpers.get_packed_data(html)

        _srcs = re.search(r'sources\s*:\s*\[(.+?)\]', html)
        if _srcs:
            sources = helpers.scrape_sources(
                _srcs.group(1),
                patterns=['''["'](?P<url>http[^"']+)'''],
                result_blacklist=['.m3u8'])
            if sources:
                headers.update({'Referer': web_url})
                return helpers.pick_source(sources) + helpers.append_headers(
                    headers)

        raise ResolverError('File not found')
예제 #12
0
def _scrape(url):
    unresolved_source_list = []
    result = __get_html_and_headers(url)
    if add_packed_data is not None:
        html = add_packed_data(result['contents'])
    else:
        html = result['contents'] + get_packed_data(result['contents'])

    def _to_list(items):
        for lstitem in items:
            if not any(lstitem['url'] == t['url'] for t in unresolved_source_list):
                unresolved_source_list.append(lstitem)
            else:
                if lstitem['label'] not in lstitem['url']:
                    for idx, itm in enumerate(unresolved_source_list):
                        if (lstitem['url'] == itm['url']) and (itm['label'] in itm['url']):
                            unresolved_source_list[idx] = lstitem
                            break

    log_utils.log('Scraping for iframes', log_utils.LOGDEBUG)
    _to_list(scrape_supported(url, html, '''iframe src\s*=\s*['"]([^'"]+)(?:[^>]+(?:title|alt)\s*=\s*['"]([^'"]+))?'''))
    log_utils.log('Scraping for hrefs', log_utils.LOGDEBUG)
    _to_list(scrape_supported(url, html, '''href\s*=\s*['"]([^'"]+)[^>]+(?:(?:(?:data-title|title)\s*=\s*['"]([^'"]+))?(?:[^>]*>([^<]+))?)'''))
    log_utils.log('Scraping for data-hrefs', log_utils.LOGDEBUG)
    _to_list(scrape_supported(url, html, '''data-href-url\s*=\s*['"]([^'"]+)[^>]+(?:(?:(?:data-title|title)\s*=\s*['"]([^'"]+))?(?:[^>]*>([^<]+))?)'''))
    log_utils.log('Scraping for data-lazy-srcs', log_utils.LOGDEBUG)
    _to_list(scrape_supported(url, html, '''data-lazy-src\s*=\s*['"]([^'"]+)(?:[^>]+(?:title|alt)\s*=\s*['"]([^'"]+))?'''))
    log_utils.log('Scraping for srcs', log_utils.LOGDEBUG)
    _to_list(scrape_supported(url, html, '''src(?<!iframe\s)\s*=\s*['"]([^'"]+)(?:[^>]+(?:title|alt)\s*=\s*['"]([^'"]+))?'''))

    title = ''
    match = re.search('title>\s*(.+?)\s*</title', html)
    if match:
        title = match.group(1)
        try:
            title = HTMLParser().unescape(title)
        except:
            pass
    result_list = []
    for item in unresolved_source_list:
        if item['content_type'] != 'text':
            result_list.append(item)
    return {'results': result_list, 'title': title, 'headers': result['headers']}