Пример #1
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
        html = html.encode('utf-8') if helpers.PY2 else html
        aa_text = re.search(r"""(゚ω゚ノ\s*=\s*/`m´\s*)\s*ノ.+?;)\s*</script""", html, re.I)

        if aa_text:
            aa_decoded = aadecode.decode(aa_text.group(1))
            sources = helpers.scrape_sources(aa_decoded)
        else:
            sources = helpers.scrape_sources(html, patterns=[r'''sources:\s*\[{src:\s*"(?P<url>[^"]+)'''])

        if sources:
            headers.update({'Referer': web_url})
            return helpers.pick_source(sources) + helpers.append_headers(headers)

        raise ResolverError('Video not found')
Пример #2
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'Referer': web_url, 'User-Agent': common.FF_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        try:
            html = html.encode('utf-8')
        except:
            pass
        if "This video doesn't exist." in html:
            raise ResolverError('The requested video was not found.')

        match = re.search(r"split\('\|'\)\)\)\s*(.*?)</script>", html)
        if match:
            aa_text = aadecode.decode(match.group(1))
            match = re.search("'([^']+)", aa_text)
            if match:
                stream_url = match.group(1)
                return stream_url + helpers.append_headers(
                    {'User-Agent': common.FF_USER_AGENT})

        raise ResolverError('Video Link Not Found')