def resolve_movie(siteid, cls, movieid, linkid):
    '''
    Play movie
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Play movie')

    page_url = plugin.request.args['url'][0]
    url = api.resolve_redirect(page_url)

    print 'resolve video: {url}'.format(url=url)
    plugin.log.debug('resolve video: {url}'.format(url=url))

    if url:
        media = __resolve_item(url, movieid)
        print 'resolved to: {url}'.format(url=media)

        if __is_resolved(media):
            plugin.set_resolved_url(media)
        else:
            if media is False:
                msg = _('unresolvable_link')
            else:
                msg = str(media.msg)
            raise Exception(msg)

    else:
        msg = _('video_url_not_found')
        raise Exception(msg)
def index():
    '''
    Display sites
    '''
    plugin.log.debug('Get sites')

    items = [{
        'label': sc.LONG_NAME,
        'path': plugin.url_for(
            'get_category_menu', siteid=index,
            cls=sc.__name__),
        'thumbnail': util.get_image_path(sc.LOCAL_THUMB),
        'icon': util.get_image_path(sc.LOCAL_THUMB),
        } for index, sc in enumerate(BaseI4M.__subclasses__())]

    thumb = util.get_image_path('settings.png')
    items.append({
        'label': '[COLOR white]{txt}[/COLOR]'.format(
            txt=_('url_resolver_settings')),
        'path': plugin.url_for('get_urlresolver_settings'),
        'thumbnail': thumb,
        'icon': thumb
        })

    return items
Example #3
0
def index():
    '''
    Display sites
    '''
    plugin.log.debug('Get sites')

    items = [{
        'label':
        sc.LONG_NAME,
        'path':
        plugin.url_for('get_category_menu', siteid=index, cls=sc.__name__),
        'thumbnail':
        util.get_image_path(sc.LOCAL_THUMB),
        'icon':
        util.get_image_path(sc.LOCAL_THUMB),
    } for index, sc in enumerate(BaseI4M.__subclasses__())]

    thumb = util.get_image_path('settings.png')
    items.append({
        'label':
        '[COLOR white]{txt}[/COLOR]'.format(txt=_('url_resolver_settings')),
        'path':
        plugin.url_for('get_urlresolver_settings'),
        'thumbnail':
        thumb,
        'icon':
        thumb
    })

    return items
def search(siteid, cls):
    '''
    Search movies
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Search')

    query = get_args('input') or plugin.keyboard(
        heading='Search'
    )
    if query:
        enc = urllib.quote_plus(query)
        movies = api.search(enc)

        items = [{
            'label': item['label'],
            'thumbnail': item['thumb'],
            'icon': item['thumb'],
            'info': {
                'plot': item['info']
            },
            'path': plugin.url_for(
                'browse_movie', siteid=siteid, cls=cls,
                menuid=0, page=1,
                movieid=item.get('pk', '0'), url=item['url'])
        } for item in movies]

        return items

    else:
        msg = [_('no_search_terms')]
        plugin.log.error(msg[0])
        dialog = xbmcgui.Dialog()
        dialog.ok(api.LONG_NAME, *msg)
Example #5
0
def resolve_movie(siteid, cls, movieid, linkid):
    '''
    Play movie
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Play movie')

    page_url = plugin.request.args['url'][0]
    url = api.resolve_redirect(page_url)

    print 'resolve video: {url}'.format(url=url)
    plugin.log.debug('resolve video: {url}'.format(url=url))

    if url:
        media = __resolve_item(url, movieid)
        print 'resolved to: {url}'.format(url=media)

        if __is_resolved(media):
            plugin.set_resolved_url(media)
        else:
            if media is False:
                msg = _('unresolvable_link')
            else:
                msg = str(media.msg)
            raise Exception(msg)

    else:
        msg = _('video_url_not_found')
        raise Exception(msg)
Example #6
0
def browse_movie(siteid, cls, menuid, page, movieid):
    '''
    Get links for movie
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Get movie links')

    page_url = plugin.request.args['url'][0]
    links = api.get_movie_links(page_url)

    items = [{
        'label':
        item['label'],
        'is_playable':
        item['is_playable'],
        'path':
        plugin.url_for('resolve_movie',
                       siteid=siteid,
                       cls=cls,
                       movieid=movieid,
                       linkid=item.get('pk', '0'),
                       url=item['url'])
    } for item in links]

    return items
Example #7
0
def get_category_menu(siteid, cls):
    '''
    Get movie categories
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()

    plugin.log.debug('browse site: {site}'.format(site=cls))

    # check if site is available
    if api.BASE_URL:
        available = util.is_site_available(api.BASE_URL)

        if available:

            # search
            items = [{
                'label': "[B]** Search **[/B]",
                'path': plugin.url_for('search', siteid=siteid, cls=cls)
            }]

            # get categories
            plugin.log.debug('Get category menu')
            c = get_cached(api.get_menu_category, cls)
            if c:
                items.extend([{
                    'label':
                    item['label'],
                    'path':
                    plugin.url_for('browse_category',
                                   siteid=siteid,
                                   cls=cls,
                                   menuid=item.get('pk', '0'),
                                   page=1,
                                   url=item['url'])
                } for item in c])

            return items

        else:
            msg = [
                '[B][COLOR red]{txt}[/COLOR][/B]'.format(
                    txt=_('site_unavailable')),
                '{site} {txt}'.format(site=api.long_name,
                                      txt=_('is_unavailable')),
                _('try_again_later')
            ]
            plugin.log.error(msg[1])

            dialog = xbmcgui.Dialog()
            dialog.ok(api.long_name, *msg)
    else:
        msg = 'Base url not implemented'
        plugin.log.error(msg)
        raise Exception(msg)
def get_category_menu(siteid, cls):
    '''
    Get movie categories
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()

    plugin.log.debug('browse site: {site}'.format(site=cls))

    # check if site is available
    if api.BASE_URL:
        available = util.is_site_available(api.BASE_URL)

        if available:

            # search
            items = [{
                'label': "[B]** Search **[/B]",
                'path': plugin.url_for('search', siteid=siteid, cls=cls)
            }]

            # get categories
            plugin.log.debug('Get category menu')
            c = get_cached(api.get_menu_category, cls)
            if c:
                items.extend([{
                    'label': item['label'],
                    'path': plugin.url_for(
                        'browse_category', siteid=siteid, cls=cls,
                        menuid=item.get('pk', '0'), page=1, url=item['url'])
                } for item in c])

            return items

        else:
            msg = [
                '[B][COLOR red]{txt}[/COLOR][/B]'.format(
                    txt=_('site_unavailable')),
                '{site} {txt}'.format(
                    site=api.long_name, txt=_('is_unavailable')),
                _('try_again_later')]
            plugin.log.error(msg[1])

            dialog = xbmcgui.Dialog()
            dialog.ok(api.long_name, *msg)
    else:
        msg = 'Base url not implemented'
        plugin.log.error(msg)
        raise Exception(msg)
Example #9
0
def browse_category(siteid, cls, menuid, page='1'):
    '''
    Get list of movies from category
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Get movies menu')

    url = plugin.request.args['url'][0]
    movies = api.get_menu_movies(url)

    items = [{
        'label':
        item['label'],
        'thumbnail':
        item['thumb'],
        'icon':
        item['thumb'],
        'info': {
            'plot': item['info']
        },
        'path':
        plugin.url_for('browse_movie',
                       siteid=siteid,
                       cls=cls,
                       menuid=menuid,
                       page=page,
                       movieid=item.get('pk', '0'),
                       url=item['url'])
    } for item in movies]

    if len(items) > 1:
        # build next link
        next_link = api.get_next_link(url)
        if next_link:
            items.append({
                'label':
                next_link['label'],
                'path':
                plugin.url_for('browse_category',
                               siteid=siteid,
                               cls=cls,
                               menuid=item.get('pk', '0'),
                               page=next_link['pk'],
                               url=next_link['url'])
            })

    return items
def browse_movie(siteid, cls, menuid, page, movieid):
    '''
    Get links for movie
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Get movie links')

    page_url = plugin.request.args['url'][0]
    links = api.get_movie_links(page_url)

    items = [{
        'label': item['label'],
        'is_playable': item['is_playable'],
        'path': plugin.url_for(
            'resolve_movie', siteid=siteid, cls=cls,
            movieid=movieid, linkid=item.get('pk', '0'),
            url=item['url'])
    } for item in links]

    return items
Example #11
0
def search(siteid, cls):
    '''
    Search movies
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Search')

    query = get_args('input') or plugin.keyboard(heading='Search')
    if query:
        enc = urllib.quote_plus(query)
        movies = api.search(enc)

        items = [{
            'label':
            item['label'],
            'thumbnail':
            item['thumb'],
            'icon':
            item['thumb'],
            'info': {
                'plot': item['info']
            },
            'path':
            plugin.url_for('browse_movie',
                           siteid=siteid,
                           cls=cls,
                           menuid=0,
                           page=1,
                           movieid=item.get('pk', '0'),
                           url=item['url'])
        } for item in movies]

        return items

    else:
        msg = [_('no_search_terms')]
        plugin.log.error(msg[0])
        dialog = xbmcgui.Dialog()
        dialog.ok(api.LONG_NAME, *msg)
def browse_category(siteid, cls, menuid, page='1'):
    '''
    Get list of movies from category
    '''
    siteid = int(siteid)
    api = BaseI4M.__subclasses__()[siteid]()
    plugin.log.debug('Get movies menu')

    url = plugin.request.args['url'][0]
    movies = api.get_menu_movies(url)

    items = [{
        'label': item['label'],
        'thumbnail': item['thumb'],
        'icon': item['thumb'],
        'info': {
            'plot': item['info']
        },
        'path': plugin.url_for(
            'browse_movie', siteid=siteid, cls=cls,
            menuid=menuid, page=page,
            movieid=item.get('pk', '0'), url=item['url'])
    } for item in movies]

    if len(items) > 1:
        # build next link
        next_link = api.get_next_link(url)
        if next_link:
            items.append({
                'label': next_link['label'],
                'path': plugin.url_for(
                    'browse_category', siteid=siteid, cls=cls,
                    menuid=item.get('pk', '0'),
                    page=next_link['pk'], url=next_link['url'])
            })

    return items