Exemple #1
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)
Exemple #2
0
def get_category_menu(siteid, cls):
    siteid = int(siteid)
    api = BaseForum.__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:
            frameitems = []
            categoryitems = []

            # get frames
            f = api.get_frame_menu()
            if f:
                frameitems = [{
                    'label': item['label'],
                    'path': plugin.url_for(
                        'browse_frame', siteid=siteid, cls=cls,
                        frameid=index, url=item['url'])
                } for index, item in enumerate(f)]

            # get categories
            c = api.get_category_menu()
            if c:
                categoryitems = [{
                    'label': '[B]{item}[/B]'.format(item=item['label']),
                    'path': plugin.url_for(
                        'browse_category', siteid=siteid, cls=cls,
                        categoryid=item['categoryid'])
                } for item in c]

            by_label = itemgetter('label')
            items = frameitems + sorted(categoryitems, key=by_label)
            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_season_menu(siteid, cls):
    siteid = int(siteid)
    api = BaseForum.__subclasses__()[siteid]()
    lang = LANG.get(api.short_name, '')

    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:
            items = []

            # siteid provides unique key for cache
            # as lang not always present
            data = get_cached(api.get_season_menu, siteid, lang)

            if data:
                items = [{
                    'label': item['label'].encode('utf-8'),
                    'path': plugin.url_for(
                        'get_show_menu', siteid=siteid, cls=cls,
                        seasonid=item['pk'], url=item['url'])
                } for item in data]

                return __add_listitem(groupname=api.short_name, items=items)

            else:
                msg = '[B][COLOR red]{txt}[/COLOR][/B]'.format(
                    txt=_('no_seasons'))
                plugin.log.error(msg)
                dialog = xbmcgui.Dialog()
                dialog.ok(api.long_name, msg)

        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)
def get_category_menu(siteid, cls):
    siteid = int(siteid)
    api = BaseForum.__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:
            frameitems = []
            categoryitems = []

            # get frames
            f = api.get_frame_menu()
            if f:
                frameitems = [{
                    'label':
                    item['label'],
                    'path':
                    plugin.url_for('browse_frame',
                                   siteid=siteid,
                                   cls=cls,
                                   frameid=index,
                                   url=item['url'])
                } for index, item in enumerate(f)]

            # get categories
            c = api.get_category_menu()
            if c:
                categoryitems = [{
                    'label':
                    '[B]{item}[/B]'.format(item=item['label']),
                    'path':
                    plugin.url_for('browse_category',
                                   siteid=siteid,
                                   cls=cls,
                                   categoryid=item['categoryid'])
                } for item in c]

            by_label = itemgetter('label')
            items = frameitems + sorted(categoryitems, key=by_label)
            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)