Ejemplo n.º 1
0
    def run(self, url):
        try:
            urls = self.yify(url)
            # urls = cache(self.yify, url)
            if urls is None:
                raise Exception()

            if getSetting("autoplay") == 'false' and len(urls) > 1:
                mirrors = list()
                for url in urls:
                    mirrors.extend([url[1].replace('Download', 'Stream')])

                dialog = xbmcgui.Dialog()
                src = dialog.select('Choose a Source', mirrors)

                if src == -1:
                    return

                url = HostedMediaFile(url=urls[src][0]).resolve()
                Player().run(url)
                return url
            else:
                url = HostedMediaFile(url=urls[0][0]).resolve()
                Player().run(url)
                return url
        except:
            if not Index().getProperty('PseudoTVRunning') == 'True':
                Index().infoDialog(language(30318).encode("utf-8"))
            return
Ejemplo n.º 2
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()
Ejemplo n.º 3
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 ""
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
 def youtube(url):
     try:
         # video_id = url.split("?v=")[-1].split("/")[-1].split("?")[0].split("&")[0]
         # url = 'plugin://plugin.video.youtube/play/?video_id=%s' % video_id
         if not url.lower().startswith('http'):
             url = 'https://www.youtube.com/watch?v=%s' % url
         url = HostedMediaFile(url=url).resolve()
         return url
     except:
         return None
Ejemplo n.º 7
0
def scrape_supported(html, regex=None, host_only=False):
    """
    returns a list of links scraped from the html that are supported by resolveurl

    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
Ejemplo n.º 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')
Ejemplo n.º 9
0
def conditionals(url):

    add_plugin_dirs(control.transPath(PLUGINS_PATH))

    def yt(uri):

        if uri.startswith('plugin://'):
            return uri

        if len(uri) == 11:

            uri = YT_URL + uri

        try:
            return youtube.wrapper(uri)
        except YouTubeException as exp:
            log_debug('Youtube resolver failure, reason: ' + repr(exp))
            return

    if 'youtu' in url or len(url) == 11:

        log_debug('Resolving with youtube addon...')

        return yt(url)

    elif HOSTS(url) and HostedMediaFile(url).valid_url():

        try:
            stream = resolve_url(url)
            log_debug('Resolving with Resolveurl...')
        except HTTPError:
            return url

        return stream

    elif HostedMediaFile(url).valid_url():

        if control.setting('show_alt_vod') == 'true':

            try:
                stream = resolve_url(url)
                log_debug('Resolving with Resolveurl...')
            except ResolverError:
                return
            except HTTPError:
                return url

            return stream

        else:

            control.okDialog('AliveGR', control.lang(30354))
            return 'https://static.adman.gr/inpage/blank.mp4'

    elif GM_BASE in url:

        sources = gm_source_maker(url)
        stream = mini_picker(sources['links'])

        return conditionals(stream)

    elif urlparse(GK_BASE).netloc in url:

        streams = gk_source_maker(url)
        stream = mini_picker(streams['links'])

        if control.setting('check_streams') == 'true':
            return stream
        else:
            return conditionals(stream)

    else:

        log_debug('Passing direct link...')

        return url
Ejemplo n.º 10
0
def conditionals(url, params):
    def yt_conditional(uri):

        if uri.startswith('plugin://'):
            return uri

        if len(uri) == 11:

            uri = yt_url + uri

        try:
            return youtube.wrapper(uri)
        except YouTubeException as exp:
            log_debug('Youtube resolver failure, reason: ' + repr(exp))
            return

    if 'youtu' in url:

        log_debug('Resolved with youtube addon')

        return yt_conditional(url)

    elif 'greek-movies.com' in url:

        sources = cache.get(gm_source_maker, 6, url)

        if any(['music' in sources[0], 'view' in sources[0]]):

            stream = youtube.wrapper(sources[1])

            return stream

        else:

            link = mini_picker(sources[1], sources[2], params)

            if link is None:
                control.execute('Dialog.Close(all)')
            else:
                stream = conditionals(link, params)

                try:
                    return stream, sources[3]
                except IndexError:
                    return stream

    elif stream_link.sl_hosts(url):

        log_debug('Resolved with streamlink')

        stream = stream_link.sl_session(url)

        if 'kineskop' in url:

            from tulip.user_agents import spoofer
            return stream + spoofer()

        return stream

    elif HostedMediaFile(url).valid_url():

        log_debug('Resolved with resolveurl')

        stream = resolve_url(url)
        return stream

    elif 'antenna' in url and not '/live' in url.lower():
        return 'plugin://plugin.video.antenna.gr/?action=play&url={}'.format(
            url)
    elif 'alphatv' in url and not 'live' in url:
        return 'plugin://plugin.video.alphatv.gr/?action=play&url={}'.format(
            url)
    elif 'ert.gr' in url and not 'ipinfo-geo' in url and not 'ertworld' in url:
        return 'plugin://plugin.video.ert.gr/?action=play&url={}'.format(url)
    elif 'skaitv.gr' in url and not 'live' in url.lower():
        return 'plugin://plugin.video.skai.gr/?action=play&url={}'.format(url)
    elif 'star.gr' in url and not 'live' in url.lower():
        return 'plugin://plugin.video.star.gr/?action=play&url={}'.format(url)

    # elif 'antenna.gr' in url:
    #
    #     stream = cache.get(various.ant1gr, 12, url)
    #
    #     return stream

    # elif 'ant1.com.cy/web-tv-live' in url:
    #
    #     stream = cache.get(various.ant1cy, 1, url)
    #
    #     return stream
    #
    # elif 'omegatv.com.cy/live/' in url:
    #
    #     stream = various.omegacy(url)
    #
    #     return stream

    elif 'webtv.ert.gr' in url:

        link = cache.get(various.ert, 12, url)

        if '.m3u8' in link:
            return link
        else:
            return yt_conditional(link)

    # elif 'star.gr' in url:
    #
    #     return cache.get(various.stargr, 6, url)

    elif 'skaitv.gr' in url:

        vid = cache.get(various.skai, 3, url)
        stream = youtube.wrapper(vid)
        return stream

    elif 'alphatv.gr/live' in url or 'alphacyprus.com.cy' in url:

        stream = cache.get(various.alphatv, 12, url)
        return stream

    elif 'euronews.com' in url and 'watchlive.json' in url:

        stream = cache.get(various.euronews, 6, url)
        return stream

    elif 'periscope' in url and 'search' in url:

        stream = stream_link.sl_session(
            cache.get(various.periscope_search, 6, url))

        return stream

    elif 'rise.gr' in url:

        link = cache.get(various.risegr, 24, url)

        stream = stream_link.sl_session(link)

        return stream

    else:

        return url
Ejemplo n.º 11
0
def conditionals(url):

    add_plugin_dirs(control.transPath(PLUGINS_PATH))

    def yt(uri):

        if uri.startswith('plugin://'):
            return uri

        if len(uri) == 11:

            uri = YT_URL + uri

        try:
            return youtube.wrapper(uri)
        except YouTubeException as exp:
            log_debug('Youtube resolver failure, reason: ' + repr(exp))
            return

    if 'youtu' in url:

        log_debug('Resolved with youtube addon')

        return yt(url)

    elif url.startswith('iptv://'):

        try:
            if CACHE_DEBUG:
                hosts, urls = common.iptv(urlsplit(url).netloc)
            else:
                hosts, urls = cache.get(common.iptv, 2, urlsplit(url).netloc)
        except Exception:
            return

        stream = mini_picker(hosts, urls, dont_check=True)

        return stream

    elif HOSTS(url) and HostedMediaFile(url).valid_url():

        try:
            stream = resolve_url(url)
        except urllib2.HTTPError:
            return url

        return stream

    elif HostedMediaFile(url).valid_url():

        if control.setting('show_alt_vod') == 'true':

            try:
                stream = resolve_url(url)
            except urllib2.HTTPError:
                return url

            return stream

        else:

            control.okDialog('AliveGR', control.lang(30354))
            return 'https://static.adman.gr/inpage/blank.mp4'

    elif GM_BASE in url:

        if CACHE_DEBUG:
            sources = source_maker(url)
        else:
            sources = cache.get(source_maker, 6, url)
            if not sources:
                return

        link = mini_picker(sources['hosts'], sources['links'])

        if not link:
            return

        stream = conditionals(link)
        return stream

    elif GK_BASE in url:

        if CACHE_DEBUG:
            stream = gk_debris(url)
        else:
            stream = cache.get(gk_debris, 48, url)
        if not stream:
            return
        else:
            return stream

    else:

        return url