Пример #1
0
class VidToDoResolver(UrlResolver):
    name = 'Vidtodo'
    domains = ['vidtodoo.com', 'vidotodo.com', 'vidtodo.com', 'vidtodo.me']
    pattern = '(?://|\.)((?:vidtodo[o]?|vidotodo)\.(?:com|me))/(?:embed-)?([0-9a-zA-Z]+)'

    def __init__(self):
        self.net = Net()
        self.userAgent = RAND_UA
        self.net.set_user_agent(self.userAgent)
        self.desktopHeaders = {
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'en-US,en;q=0.5',
            'Upgrade-Insecure-Requests': '1',
            'DNT': '1'
        }

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        r = self.net.http_GET(web_url, headers=self.desktopHeaders)

        if r._response.code == 200:
            sources = helpers.scrape_sources(
                r.content,
                generic_patterns=False,
                patterns=
                ('''sources.*?\[['"](?P<url>.*?)['"]''',
                 '''sources.*?file:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?''',
                 '''updateSrc.*?src:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?'''
                 ))
            if sources:
                # Headers for requesting media (copied from Firefox).
                parsedUrl = urlparse(r.get_url())
                kodiHeaders = {
                    'User-Agent':
                    self.userAgent,
                    'Accept':
                    'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
                    'Referer':
                    '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc),
                    'Cookie':
                    '; '.join(cookie.name + '=' + cookie.value
                              for cookie in self.net._cj)
                }
                return helpers.pick_source(sources) + helpers.append_headers(
                    kodiHeaders)
        raise ResolverError('Unable to locate video')

    def get_url(self, host, media_id):
        return self._default_get_url(host,
                                     media_id,
                                     template='https://{host}/{media_id}')
Пример #2
0
class FastplayResolver(UrlResolver):
    name = 'fastplay.sx'
    domains = ['fastplay.sx', 'fastplay.cc', 'fastplay.to']
    pattern = '(?://|\.)(fastplay\.(?:sx|cc|to))/(?:flash-|embed-)?([0-9a-zA-Z]+)'

    def __init__(self):
        self.net = Net()
        self.userAgent = RAND_UA
        self.net.set_user_agent(self.userAgent)
        self.desktopHeaders = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'en-US,en;q=0.5',
            'Upgrade-Insecure-Requests': '1',
            'DNT': '1'
        }

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        r = self.net.http_GET(web_url, headers=self.desktopHeaders)

        sources = helpers.scrape_sources(
            r.content,
            generic_patterns=False,
            patterns=['''file:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?''']
        )
        if sources:

            # Headers for requesting media (copied from Firefox).
            parsedUrl = urlparse(r.get_url())
            kodiHeaders = {
                'User-Agent': self.userAgent,
                'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
                'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc),
                'Cookie': '; '.join(cookie.name + '=' + cookie.value for cookie in self.net._cj)
            }

            sources = helpers.sort_sources_list(sources)
            return helpers.pick_source(sources) + helpers.append_headers(kodiHeaders)

        raise ResolverError('Unable to locate video')


    def get_url(self, host, media_id):
        return self._default_get_url(host, media_id, template='http://fastplay.to/embed-{media_id}.html')
Пример #3
0
class VidToDoResolver(UrlResolver):
    name = 'Vidtodo'
    domains = ['vidotodo.com', 'vidtodo.com', 'vidtodo.me']
    pattern = '(?://|\.)((?:vidtodo|vidotodo)\.(?:com|me))/(?:embed-)?([0-9a-zA-Z]+)'

    def __init__(self):
        self.net = Net()
        self.net.set_user_agent(RAND_UA)
        self.desktopHeaders = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'en-US,en;q=0.5',
            'Upgrade-Insecure-Requests': '1',
            'DNT': '1'
        }
        

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        r = self.net.http_GET(web_url, headers=self.desktopHeaders)
        
        if r._response.code == 200:
            sources = helpers.scrape_sources(
                r.content, generic_patterns=False, patterns=['''sources.*?\[['"](?P<url>.*?)['"]''']
            )
            if sources:
                # Headers for requesting media (copied from Firefox).
                parsedUrl = urlparse(r.get_url())
                kodiHeaders = {
                    'User-Agent': self.net.get_user_agent(),
                    'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
                    'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc),
                    'Cookie': '; '.join(
                        header.replace('Set-Cookie: ', '').split(';', 1)[0]
                        for header in r.get_headers() if header.startswith('Set-Cookie')
                    )
                }
                return helpers.pick_source(sources) + helpers.append_headers(kodiHeaders)
        raise ResolverError('Unable to locate video')
        

    def get_url(self, host, media_id):
        return self._default_get_url(host, media_id, template='https://{host}/{media_id}')
Пример #4
0
class SpeedVidResolver(UrlResolver):
    name = "SpeedVid"
    domains = ['speedvid.net']
    pattern = '(?://|\.)(speedvid\.net)/(?:embed-|p-)?(\w+)'

    def __init__(self):
        self.net = Net()
        self.desktopHeaders = {
            'User-Agent': RAND_UA,
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Language': 'en-US,en;q=0.5',
            'DNT': '1'
        }

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)

        try:
            r = self.net.http_GET(web_url, headers=self.desktopHeaders)
            content = r.content
        except HTTPError as e:
            r = HttpResponse(e)
            content = r.content
            if cfsolver.test_cloudflare(
                    r, content):  # Test if there's a Cloudflare challenge.
                submitURL = cfsolver.solve_cf_challenge(
                    r, content)  # Get the solution URL.
                if not submitURL:
                    return None
                # Get redirected to the proper page.
                self.desktopHeaders['Referer'] = r.get_url() + '/'
                r = self.net.http_GET(submitURL, headers=self.desktopHeaders)
                content = r.content

        if r._response.code == 200:
            source = None
            pattern = re.compile('(eval\(function\(p,a,c,k.*?)\s*?</script>',
                                 re.DOTALL)
            for match in pattern.finditer(content):
                unpackedData = jsunpack.unpack(match.group(1)).replace(
                    "\\\'", "'")
                tempURL = re.search('''(?:file|src):.*?['"](?P<url>.*?)['"]''',
                                    unpackedData, re.DOTALL).group(1)
                # Some of the links might be broken, so only use working ones.
                try:
                    if self.net.http_HEAD(
                            tempURL,
                            headers=self.desktopHeaders)._response.code < 400:
                        source = tempURL
                        break
                except:
                    pass  # HTTPError caused by a broken link.

            if source:
                # Headers for requesting media (copied from Firefox).
                parsedUrl = urlparse(r.get_url())
                kodiHeaders = {
                    'User-Agent':
                    self.net.get_user_agent(),
                    'Accept':
                    'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5',
                    'Referer':
                    '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc),
                    'Accept-Language':
                    'en-US,en;q=0.5',
                    'Cookie':
                    '; '.join(cookie.name + '=' + cookie.value
                              for cookie in self.net._cj)
                }
                return source + helpers.append_headers(kodiHeaders)
        raise ResolverError('Unable to locate video')

    def get_url(self, host, media_id):
        return self._default_get_url(host,
                                     media_id,
                                     template='http://www.{host}/{media_id}')