示例#1
0
def resolve(web_url):
    """
    Resolve a web page to a media stream.

    It is usually as simple as::

        import urlresolver
        media_url = urlresolver.resolve(web_url)

    where ``web_url`` is the address of a web page which is associated with a
    media file and ``media_url`` is the direct URL to the media.

    Behind the scenes, :mod:`urlresolver` will check each of the available
    resolver plugins to see if they accept the ``web_url`` in priority order
    (lowest priotity number first). When it finds a plugin willing to resolve
    the URL, it passes the ``web_url`` to the plugin and returns the direct URL
    to the media file, or ``False`` if it was not possible to resolve.

    .. seealso::

        :class:`HostedMediaFile`

    Args:
        web_url (str): A URL to a web page associated with a piece of media
        content.

    Returns:
        If the ``web_url`` could be resolved, a string containing the direct
        URL to the media file, if not, returns ``False``.
    """
    source = HostedMediaFile(url=web_url)
    return source.resolve()
示例#2
0
def resolve(url):
    # import the resolvers so that urlresolvers pick them up
    import resources.lib.resolvers
    hmf = HostedMediaFile(url)
    try:
        return hmf.resolve()
    except AttributeError:
        return False
def resolve(url):
    # import the resolvers so that urlresolvers pick them up
    import lib.resolvers
    hmf = HostedMediaFile(url)
    try:
        return hmf.resolve()
    except AttributeError:
        return False
示例#4
0
def resolve(url):
    if type(url) is unicode:
        url = url.encode('utf8')
    url = quote(url, ':/')

    # import the resolvers so that urlresolvers pick them up
    import lib.resolvers
    hmf = HostedMediaFile(url)
    try:
        return hmf.resolve()
    except AttributeError:
        return False
示例#5
0
def resolve(url):
    if type(url) is unicode:
        url = url.encode('utf8')
    url = quote(url, ':/')
    
    # import the resolvers so that urlresolvers pick them up
    import lib.resolvers
    hmf = HostedMediaFile(url)
    try:
        return hmf.resolve()
    except AttributeError:
        return False
示例#6
0
    def livetv(self, url):
        try:
            result = getUrl(url, timeout='30').result
            result = result.replace('\n', '')
            result = re.sub(r'<script.+?</script>',
                            '',
                            result,
                            flags=re.DOTALL)

            try:
                url = re.search("data-config\s*=\s*(?:\'|\")(.+?)(?:\'|\")",
                                result).groups()[0]
            except:
                url = common.parseDOM(result, "iframe", ret="src")[0]

            if '=http' in url:
                url = re.search("=(https?://.+)", url).groups()[0]
            elif url.startswith("//"):
                url = 'http:%s' % url

            if 'video.nhl.com' in url: url = self.nhl(url)
            else: url = HostedMediaFile(url=url).resolve()
            return url
        except:
            return
def scrape_supported(html, regex=None, host_only=False):
    """
    returns a list of links scraped from the html that are supported by urlresolver

    args:
        html: the html to be scraped
        regex: an optional argument to override the default regex which is: href *= *["']([^'"]+
        host_only: an optional argument if true to do only host validation vs full url validation (default False)

    Returns:
        a list of links scraped from the html that passed validation

    """
    if regex is None:
        regex = r'''href\s*=\s*['"]([^'"]+)'''
    links = []
    for match in re.finditer(regex, html):
        stream_url = match.group(1)
        host = urllib_parse.urlparse(stream_url).hostname
        if host_only:
            if host is None:
                continue

            if host in host_cache:
                if host_cache[host]:
                    links.append(stream_url)
                continue
            else:
                hmf = HostedMediaFile(
                    host=host, media_id='dummy'
                )  # use dummy media_id to allow host validation
        else:
            hmf = HostedMediaFile(url=stream_url)

        is_valid = hmf.valid_url()
        host_cache[host] = is_valid
        if is_valid:
            links.append(stream_url)
    return links
示例#8
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 = urlparse(web_url).netloc
        html = self.net.http_GET(web_url, headers=headers).content
        if 'videozoo' not in new_host:
            r = re.search(
                '(?:playlist:|timer\s*=\s*null;).+?url\s*[:=]+\s*[\'"]+(.+?)[\'"]+',
                html, re.DOTALL)
        else:
            r = re.search('\*/\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('\[{"url":"(.+?)"', r.replace('\\', ''))
                except:
                    if r:
                        re_src = re.search('urlResolvers\|2F(.+?)\|',
                                           r.group(1))
                        re_url = re.search('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.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')
示例#9
0
def resolveVideo(url):
    import resolvers
    hmf = HostedMediaFile(url)
    vidurl = hmf.resolve()
    playVideo(vidurl)
示例#10
0
#o=107984:d6409c8683f029ee9a82629175a972b5
#o=107991:58c49f51a3049f43be326cf7b8107415

import random, string, sys

sys.path.append('/home/mrknow/Dokumenty/praca/kodi/filmkodi/plugin.video.mrknow/mylib/')
sys.path.append('/home/mrknow/Dokumenty/praca/kodi/filmkodi/plugin.video.mrknow/lib/')

print ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase) for _ in range(25))


web_url = 'http://embed.nowvideo.sx/embed/?v=27e41183d1328'
web_url = 'http://videomega.tv/iframe.php?width=720&height=400&ref=98vnW2gQtGGtQg2Wnv89'
web_url = 'http://vidto.me/embed-hthii6ksp7uz-730x411.html'
web_url = 'http://openload.co/embed/XfsaMfvMRNo'


from urlresolver.hmf import HostedMediaFile

alina = HostedMediaFile(url=web_url).resolve()
print(alina)

import  mrknow_pCommon
mrknow_pCommon.mystat(url='http://aso.pl')