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

    It is usually as simple as::

        import resolveurl
        media_url = resolveurl.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:`resolveurl` 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):
    url = url.encode('utf8')
    url = quote(url, ':/')

    # import the resolvers so that resolveurls pick them up
    import lib.resolvers
    hmf = HostedMediaFile(url)
    if hmf:
        return hmf.resolve()
    else:
        return ""
예제 #3
0
def resolve(url):
    # import the resolvers so that resolveurl pick them up
    import lib.resolvers

    if type(url) is unicode:
        url = url.encode('utf8')
    url = quote(url, ':/')

    hmf = HostedMediaFile(url)
    try:
        return hmf.resolve()
    except AttributeError:
        return False