def initateSearch(self):

        self.setVisible(LOADING_SCREEN, True)

        inputText = self.getControl(SEARCH_INPUT).getText()

        if inputText and len(inputText) > 0:

            self.checkQueue()

            try:

                longList = funimationnow.getLongList('longlist/search/',
                                                     ('q=%s' % inputText))

                self.logger.debug(json.dumps(longList))

                if longList:

                    pagination = utils.parseValue(longList,
                                                  ['items', 'pagination'],
                                                  False)

                    self.logger.debug(json.dumps(pagination))

                    pPath = utils.parseValue(pagination, ['path'])
                    pParams = utils.parseValue(pagination, ['params'])
                    startPosition = utils.parseValue(
                        pagination, ['startPosition', 'param'])
                    maxCount = utils.parseValue(pagination,
                                                ['maxCount', 'param'])

                    pages = funimationnow.getPage(
                        pPath,
                        '%s&%s=0&%s=9999' % (pParams, startPosition, maxCount))

                    if pages:

                        self.logger.debug(json.dumps(pages))

                        self.setSearchDisplay(pages)

            except Exception as inst:
                self.logger.error(inst)

        self.setVisible(LOADING_SCREEN, False)
Esempio n. 2
0
    def about(self, controlID, results):

        try:

            title = utils.parseValue(results, ['title'])
            subtitle = utils.parseValue(results, ['subtitle'])

            tempImg = os.path.join(self.help_about,
                                   ('%s-%s.png' % (controlID, 0)))
            utils.text2Display(subtitle, 'RGB', (255, 255, 255), (0, 0, 0), 46,
                               'ExtraBold', tempImg, 1, True)

            helpList = self.getControl(LIST_DICT[controlID])
            listitem = xbmcgui.ListItem(title, subtitle, tempImg, tempImg)

            helpList.addItem(listitem)

        except Exception as inst:
            self.logger.error(inst)
Esempio n. 3
0
    def createButtons(self, pointers):

        if not isinstance(pointers, list):
            pointers = list([pointers])

        if len(pointers) >= 1:

            for idx, pointer in enumerate(pointers, 1):

                try:

                    tempTitle = utils.parseValue(pointer, ['title'])

                    self.menu.update({int('1102%02d' % idx): pointer})

                    utils.text2Button(tempTitle, 'RGB', [(61, 3, 136),
                                                         (68, 3, 151)],
                                      [(255, 255, 255), (255, 255, 255)], 58,
                                      'ExtraBold', (600, 90), (20, 4), [
                                          'menu-focus-button-1102%02d' % idx,
                                          'menu-no-focus-button-1102%02d' % idx
                                      ], True)

                except Exception as inst:
                    self.logger.error(inst)

        else:

            for idx in range(1, 6):

                try:

                    tempTitle = utils.lang(int('3053%d' % idx))

                    utils.text2Button(tempTitle, 'RGB', [(61, 3, 136),
                                                         (68, 3, 151)],
                                      [(255, 255, 255), (255, 255, 255)], 58,
                                      'ExtraBold', (600, 90), (20, 4), [
                                          'menu-focus-button-1102%02d' % idx,
                                          'menu-no-focus-button-1102%02d' % idx
                                      ], True)

                except Exception as inst:
                    self.logger.error(inst)
Esempio n. 4
0
    def setGenreDisplay(self, longList):

        gControl = self.getControl(PANEL_LIST);

        gControl.reset();

        items = utils.parseValue(longList, ['items', 'item'], False);

        if items:
            
            if not isinstance(items, list):
                items = list([items]);


            for item in items:

                try:

                    gTitle = utils.parseValue(item, ['analytics', 'click', 'label']);
                    gThumbnail = utils.parseValue(item, ['thumbnail', '#text']);
                    gThumbnail = funimationnow.formatImgUrl(gThumbnail, theme='genre');

                    gPath = utils.parseValue(item, ['pointer', 'path']);
                    gParams = utils.parseValue(item, ['pointer', 'params']);
                    gTarget = utils.parseValue(item, ['pointer', 'target']);

                    gListitem = xbmcgui.ListItem(gTitle, gTitle, gThumbnail, gThumbnail);

                    gListitem.setProperty('title', gTitle);
                    gListitem.setProperty('path', gPath);
                    gListitem.setProperty('params', gParams);
                    gListitem.setProperty('target', gTarget);

                    gControl.addItem(gListitem);


                except Exception as inst:
                    self.logger.error(inst);
Esempio n. 5
0
    def terms(self, controlID, results):

        try:

            contents = utils.parseValue(results,
                                        ['statictext', 'contents', 'content'],
                                        False)

            if not isinstance(contents, list):
                contents = list([contents])

            cidx = 0
            cih = 0
            ccontent = ''

            self.logger.debug(json.dumps(results))

            for idx, content in enumerate(contents, 0):

                if content is None:
                    content = ' ~~~_+_+_+_~~~'

                ccontent += content.replace(u"\u25cf", u"\u2022")
                ccontent += ' ~~~_+_+_+_~~~'

                cih = utils.text2HelpSize(ccontent,
                                          'RGB', (255, 255, 255), (0, 0, 0),
                                          36, (2560, 1340),
                                          140,
                                          'Regular',
                                          None,
                                          multiplier=1,
                                          sharpen=False,
                                          bgimage=None)

                if cih >= 1240:

                    tempImg = os.path.join(self.help_terms,
                                           ('%s-%s.png' % (controlID, cidx)))

                    utils.text2HelpWrap(ccontent,
                                        'RGB', (255, 255, 255), (0, 0, 0),
                                        36, (2560, 1340),
                                        140,
                                        'Regular',
                                        tempImg,
                                        multiplier=1,
                                        sharpen=False,
                                        bgimage=None)

                    content = content.encode('utf-8')

                    helpList = self.getControl(LIST_DICT[controlID])
                    listitem = xbmcgui.ListItem(content, content, tempImg,
                                                tempImg)

                    helpList.addItem(listitem)

                    cidx += 1
                    cih = 0
                    ccontent = ''

            if cih < 1240 and cih > 0:

                tempImg = os.path.join(self.help_terms,
                                       ('%s-%s.png' % (controlID, cidx)))

                utils.text2HelpWrap(ccontent,
                                    'RGB', (255, 255, 255), (0, 0, 0),
                                    36, (2560, 1340),
                                    140,
                                    'Regular',
                                    tempImg,
                                    multiplier=1,
                                    sharpen=False,
                                    bgimage=None)

                content = content.encode('utf-8')

                helpList = self.getControl(LIST_DICT[controlID])
                listitem = xbmcgui.ListItem(content, content, tempImg, tempImg)

                helpList.addItem(listitem)

        except Exception as inst:
            self.logger.error(inst)
Esempio n. 6
0
    def privacypolicy(self, controlID, results):

        try:

            properties = utils.parseValue(results,
                                          ['statictext', 'contents', 'p'],
                                          False)

            if not isinstance(properties, list):
                properties = list([properties])

            cidx = 0
            cih = 0

            bContent = list()
            nContent = list()

            tList = list()
            tdict = dict()

            for tidx, prop in enumerate(properties, 0):

                try:

                    if isinstance(prop, unicode):

                        if tidx < 1:
                            tdict.update({'name': ''})

                        tdict.update({
                            'value':
                            tdict.get('value', '') + '~~~~~~' + prop
                        })

                    elif prop is None:
                        pass

                    else:

                        if len(tdict) > 0:

                            tList.append(tdict)
                            tdict = dict()

                        tdict.update({'name': prop.get('strong', '')})

                except Exception as inst:
                    self.logger.error(inst)

            if len(tdict) > 0:
                tList.append(tdict)

            #self.logger.error(tList)

            for prop in tList:

                bcontent = list()

                try:

                    bcontent.append('_+_+_+_')
                    bcontent.append(prop.get('name', '_+_+_+_'))
                    bcontent.append('_+_+_+_')

                    bContent.append(bcontent)

                except:
                    pass

                try:

                    ncontent = list()

                    ncontent.append('_+_+_+_')

                    tmbValue = prop.get('value', '_+_+_+_')
                    tmbValue = tmbValue.replace(u"\u2022", u"~~~~~~\u2022")
                    tmbValues = tmbValue.split('~~~~~~')

                    for tvalue in tmbValues:
                        ncontent.append(tvalue)
                        ncontent.append('_+_+_+_')

                    ncontent.append('_+_+_+_')
                    ncontent.append('_+_+_+_')

                    nContent.append(ncontent)

                except:
                    pass

                #self.logger.error(list([bContent, nContent]))

                cih = utils.text2HelpMultiSize(list([bContent, nContent]),
                                               'RGB', (255, 255, 255),
                                               (0, 0, 0),
                                               36, (2560, 1200),
                                               140,
                                               list(['Bold', 'Regular']),
                                               None,
                                               multiplier=1,
                                               sharpen=False,
                                               bgimage='faq_list_border.png')

                if cih >= 975:

                    tempImg = os.path.join(self.help_privacy,
                                           ('%s-%s.png' % (controlID, cidx)))

                    utils.text2HelpMultiWrap(list([bContent, nContent]),
                                             'RGB', (255, 255, 255), (0, 0, 0),
                                             36, (2560, 1200),
                                             140,
                                             list(['Bold', 'Regular']),
                                             tempImg,
                                             multiplier=1,
                                             sharpen=False,
                                             bgimage='faq_list_border.png')

                    helpList = self.getControl(LIST_DICT[controlID])
                    listitem = xbmcgui.ListItem('NA', 'NA', tempImg, tempImg)

                    helpList.addItem(listitem)

                    cidx += 1
                    cih = 0

                    bContent = list()
                    nContent = list()

            if cih < 975 and cih > 0:

                tempImg = os.path.join(self.help_faq,
                                       ('%s-%s.png' % (controlID, cidx)))

                utils.text2HelpMultiWrap(list([bContent, nContent]),
                                         'RGB', (255, 255, 255), (0, 0, 0),
                                         36, (2560, 1200),
                                         140,
                                         list(['Bold', 'Regular']),
                                         tempImg,
                                         multiplier=1,
                                         sharpen=False,
                                         bgimage='faq_list_border.png')

                helpList = self.getControl(LIST_DICT[controlID])
                listitem = xbmcgui.ListItem('NA', 'NA', tempImg, tempImg)

                helpList.addItem(listitem)

        except Exception as inst:
            self.logger.error(inst)
Esempio n. 7
0
    def faq(self, controlID, results):

        try:

            properties = utils.parseValue(
                results, ['item', 'content', 'properties', 'property'], False)

            if not isinstance(properties, list):
                properties = list([properties])

            cidx = 0
            cih = 0

            bContent = list()
            nContent = list()

            for prop in properties:

                bcontent = list()

                bcontent.append('_+_+_+_')
                bcontent.append(prop.get('name', '_+_+_+_'))
                bcontent.append('_+_+_+_')

                bContent.append(bcontent)

                ncontent = list()

                ncontent.append('_+_+_+_')

                tmbValue = prop.get('value', '_+_+_+_')
                tmbValue = tmbValue.replace(u"\u2022", u"~~~~~~\u2022")
                tmbValues = tmbValue.split('~~~~~~')

                for tvalue in tmbValues:
                    ncontent.append(tvalue)

                ncontent.append('_+_+_+_')
                ncontent.append('_+_+_+_')

                nContent.append(ncontent)

                cih = utils.text2HelpMultiSize(list([bContent, nContent]),
                                               'RGB', (255, 255, 255),
                                               (0, 0, 0),
                                               36, (2560, 1200),
                                               140,
                                               list(['Bold', 'Regular']),
                                               None,
                                               multiplier=1,
                                               sharpen=False,
                                               bgimage='faq_list_border.png')

                if cih >= 975:

                    tempImg = os.path.join(self.help_faq,
                                           ('%s-%s.png' % (controlID, cidx)))

                    utils.text2HelpMultiWrap(list([bContent, nContent]),
                                             'RGB', (255, 255, 255), (0, 0, 0),
                                             36, (2560, 1200),
                                             140,
                                             list(['Bold', 'Regular']),
                                             tempImg,
                                             multiplier=1,
                                             sharpen=False,
                                             bgimage='faq_list_border.png')

                    helpList = self.getControl(LIST_DICT[controlID])
                    listitem = xbmcgui.ListItem('NA', 'NA', tempImg, tempImg)

                    helpList.addItem(listitem)

                    cidx += 1
                    cih = 0

                    bContent = list()
                    nContent = list()

            if cih < 975 and cih > 0:

                tempImg = os.path.join(self.help_faq,
                                       ('%s-%s.png' % (controlID, cidx)))

                utils.text2HelpMultiWrap(list([bContent, nContent]),
                                         'RGB', (255, 255, 255), (0, 0, 0),
                                         36, (2560, 1200),
                                         140,
                                         list(['Bold', 'Regular']),
                                         tempImg,
                                         multiplier=1,
                                         sharpen=False,
                                         bgimage='faq_list_border.png')

                helpList = self.getControl(LIST_DICT[controlID])
                listitem = xbmcgui.ListItem('NA', 'NA', tempImg, tempImg)

                helpList.addItem(listitem)

        except Exception as inst:
            self.logger.error(inst)
    def createButtons(self):

        filters = utils.parseValue(self.currentSet,
                                   ['longList', 'palette', 'filter'], False)
        buttons = utils.parseValue(filters, ['choices', 'button'], False)

        self.currentValue = utils.parseValue(filters, ['currentValue'])
        self.currentParam = utils.parseValue(filters, ['param'])

        if buttons:

            if not isinstance(buttons, list):
                buttons = list([buttons])

            for idx, button in enumerate(buttons, 0):

                tmpText = button.get('title')
                fileText = button.get('value')

                if self.currentValue == fileText:
                    self.currentChoice = idx

                tmpImgFocus = os.path.join(self.buttons,
                                           ('%s_on_focus.png' % fileText))
                tmpImgNoFocus = os.path.join(self.buttons,
                                             ('%s_on_nofocus.png' % fileText))

                #myqueue_on_focus
                #myqueue_on_nofocus
                #myqueue_off_focus
                #myqueue_off_nofocus

                utils.text2Display(tmpText,
                                   'RGB',
                                   None, (164, 68, 182),
                                   36,
                                   'Bold',
                                   tmpImgFocus,
                                   multiplier=1,
                                   sharpen=False,
                                   bgimage='watchlist_on_focus.png')
                utils.text2Display(tmpText,
                                   'RGB',
                                   None, (150, 39, 171),
                                   36,
                                   'Bold',
                                   tmpImgNoFocus,
                                   multiplier=1,
                                   sharpen=False,
                                   bgimage='watchlist_on_nofocus.png')

                tmpImgFocus = os.path.join(self.buttons,
                                           ('%s_off_focus.png' % fileText))
                tmpImgNoFocus = os.path.join(self.buttons,
                                             ('%s_off_nofocus.png' % fileText))

                #myqueue_on_focus
                #myqueue_on_nofocus
                #myqueue_off_focus
                #myqueue_off_nofocus

                utils.text2Display(tmpText,
                                   'RGB',
                                   None, (255, 255, 255),
                                   36,
                                   'Bold',
                                   tmpImgFocus,
                                   multiplier=1,
                                   sharpen=False,
                                   bgimage='watchlist_off_focus.png')
                utils.text2Display(tmpText,
                                   'RGB',
                                   None, (255, 255, 255),
                                   36,
                                   'Bold',
                                   tmpImgNoFocus,
                                   multiplier=1,
                                   sharpen=False,
                                   bgimage='watchlist_off_nofocus.png')
    def setSelectedContent(self):

        self.setVisible(LOADING_SCREEN, True)

        try:

            for panel in PANEL_LISTS:
                self.getControl(panel).reset()

            sBtns = utils.parseValue(
                self.currentSet,
                ['longList', 'palette', 'filter', 'choices', 'button'], False)
            sParams = sBtns[self.currentChoice].get('value', None)

            if sParams:

                import urlparse
                import urllib

                self.currentSet = None

                tmpParams = dict(
                    urlparse.parse_qsl(self.navigation.get('params')))

                tmpParams.update({'id': sParams})

                tmpParams = urllib.urlencode(tmpParams)

                self.navigation.update({'params': tmpParams})

                self.getCurrentSet()

                self.logger.debug(json.dumps(self.currentSet))

                watchlist = funimationnow.watchlist(self.currentValue)

                if watchlist and self.currentSet:

                    self.logger.debug(json.dumps(watchlist))

                    emptytext = None
                    emptythumb = None

                    items = utils.parseValue(self.currentSet,
                                             ['longList', 'watchlist', 'item'],
                                             False)

                    if not isinstance(items, list):
                        items = list([items])

                    for item in items:

                        if 'title' in item and 'thumbnail' in item:

                            emptytext = utils.parseValue(item, ['title'])
                            emptythumb = utils.parseValue(item, ['thumbnail'])

                    self.contentMaps.update({
                        watchlist[0]:
                        dict({
                            'items': watchlist[1],
                            'current': watchlist[2],
                            'config': watchlist[4],
                            'emptytext': emptytext,
                            'emptythumb': emptythumb
                        })
                    })

                    self.setListContent(watchlist[0])

                    #self.logger.debug(json.dumps(self.contentMaps));

                else:

                    for panel in PANEL_LISTS:
                        self.setVisible(panel, False)

            else:

                for panel in PANEL_LISTS:
                    self.setVisible(panel, False)

        except Exception as inst:
            self.logger.error(inst)

        self.setVisible(LOADING_SCREEN, False)
Esempio n. 10
0
    def setShows(self, longList):

        try:

            shControl = self.getControl(PANEL_LIST);
            shControl.reset();
            items = utils.parseValue(longList, ['items', 'item'], False);

            if items:

                if not isinstance(items, list):
                    items = list([items]);

                for idxxx, item in enumerate(items):

                    try:

                        button = None;
                        plPath = None;
                        plParams = None;

                        if self.myQueue is None:
                            self.myQueue = dict();

                        shTitle = utils.parseValue(item, ['title']);
                        shPath = utils.parseValue(item, ['pointer', 'path']);
                        shParams = utils.parseValue(item, ['pointer', 'params']);
                        #shThumbnail = utils.parseValue(item, ['thumbnail', 'alternate'], True, ['parseAlternateImg', '@platforms', 'xbox360']);
                        shThumbnail = utils.parseValue(item, ['thumbnail', 'alternate'], True, ['parseAlternateImg', '@platforms', 'firetv']);
                        shThumbnail = shThumbnail if shThumbnail is not None else utils.parseValue(item, ['thumbnail', '#text']);
                        #shThumbnail = utils.parseValue(item, ['thumbnail', '#text']);
                        shThumbnail = funimationnow.formatImgUrl(shThumbnail, theme='show');
                        
                        shStarRating = utils.parseValue(item, ['starRating', 'rating']);
                        shTitleimg = os.path.join(self.shows_list_title, ('s_%s.png' % shParams));
                        shRecentContentItem = utils.parseValue(item, ['content', 'metadata', 'recentContentItem']);
                        shRecentlyAdded = utils.parseValue(item, ['content', 'metadata', 'recentlyAdded']);
                        buttons = utils.parseValue(item, ['legend', 'button'], False);


                        if buttons:

                            if not isinstance(buttons, list):
                                buttons = list([buttons]);

                            for btn in buttons:

                                bTarget = utils.parseValue(btn, ['pointer'], False);

                                if utils.parseValue(bTarget, ['target']) == 'togglewatchlist':

                                    button = btn;

                                elif utils.parseValue(bTarget, ['target']) == 'player':

                                    plPath = utils.parseValue(bTarget, ['path']);
                                    plParams = utils.parseValue(bTarget, ['params']);


                        shToggleParams = utils.parseValue(button, ['pointer', 'toggle', 'data', 'params']);
                        shMyQueuePath = utils.parseValue(self.myQueue, [shToggleParams, 'myQueuePath']);
                        shTogglePath = utils.parseValue(btn, ['pointer', 'toggle', 'data', 'path']);
                        shToggleParams = shToggleParams;
                        shMyQueuePath = shMyQueuePath;
                        shMyQueueParams = utils.parseValue(self.myQueue, [shToggleParams, 'myQueueParams']);
                        shInQueue = str((0 if shMyQueuePath is not None else 1));

                        shListitem = xbmcgui.ListItem(shTitle, '', shThumbnail, shThumbnail);

                        titles = [shTitle];

                        shTitleimg = utils.text2Title(list(titles), self.details_home_title, shTitleimg);

                        if shTitleimg:
                            shListitem.setProperty('ctitle', shTitleimg);

                        if shInQueue is not None:
                            shListitem.setProperty('qtexture', str(shInQueue));

                        if shRecentContentItem:

                            if shRecentContentItem == 'Episode':
                                shRecentContentItem = 'Movie';

                            tempImg = os.path.join(self.shows_list_subtitle, ('%s.png' % re.sub(r'[^\w\d]+', '_', shRecentContentItem, re.I)));

                            if not os.path.isfile(tempImg):
                                utils.text2Display(shRecentContentItem, 'RGB', (255, 255, 255), (0, 0, 0), 26, 'Regular', tempImg, multiplier=1, sharpen=False, bgimage=None);

                            shListitem.setProperty('subtitle', tempImg);


                        if shRecentlyAdded:

                            tfname = re.sub(r'[^\d]+', '', shRecentlyAdded, re.I);
                            ttname = 'added 0d ago';

                            try:

                                import time;
                                import dateutil.parser;

                                from time import mktime;
                                from datetime import datetime;

                                ttdate = datetime.fromtimestamp(mktime(time.gmtime(float(tfname))));
                                ttday = (datetime.utcnow() - ttdate).days;

                                if ttday >= 365:
                                    ttname = 'added %sy ago' % int(round(float(ttday) / 365));

                                elif ttday >= 1:
                                    ttname = 'added %sd ago' % ttday;

                                else:

                                    ttday = (datetime.utcnow() - ttdate).total_seconds();

                                    if(ttday / 60) <= 59:
                                        ttname = 'added %sm ago' % int(round(float(ttday) / 60));

                                    else:
                                        ttname = 'added %sh ago' % int(round((float(ttday) / 60) / 60));

                            except Exception as inst:
                                self.logger.error(inst);
                                ttname = 'added 0d ago';


                            tempImg = os.path.join(self.shows_list_added, ('%s.png' % tfname));

                            #if not os.path.isfile(tempImg):
                            utils.text2Display(ttname, 'RGB', (255, 255, 255), (0, 0, 0), 26, 'Italic', tempImg, multiplier=1, sharpen=False, bgimage=None);

                            shListitem.setProperty('addedon', tempImg);


                        if shStarRating:

                            shStarRating = str(utils.roundQuarter(str(shStarRating)));
                            shListitem.setProperty('starrating', shStarRating);

                        else:
                            shListitem.setProperty('starrating', '0.0');


                        shListitem.setProperty('title', shTitle);
                        shListitem.setProperty('thumbnail', shThumbnail);
                        shListitem.setProperty('path', shPath);
                        shListitem.setProperty('params', shParams);
                        shListitem.setProperty('titleimg', shTitleimg);
                        shListitem.setProperty('recentContentItem', shRecentContentItem);
                        #shListitem.setProperty('recentlyAdded', shRecentlyAdded);
                        shListitem.setProperty('togglePath', shTogglePath);
                        shListitem.setProperty('toggleParams', shToggleParams);
                        shListitem.setProperty('myQueuePath', shMyQueuePath);
                        shListitem.setProperty('myQueueParams', shMyQueueParams);
                        shListitem.setProperty('inQueue', shInQueue);
                        #shListitem.setProperty('starRating', shStarRating);

                        shControl.addItem(shListitem);


                    except Exception as inst:
                        self.logger.error(inst);


        except Exception as inst:
            self.logger.error(inst);
Esempio n. 11
0
    def setupGenreSelect(self, genres):

        self.genredata = genres;
        
        longList = utils.parseValue(genres, ['longList'], False);
        filters = utils.parseValue(longList, ['palette', 'filter'], False);
        items = utils.parseValue(longList, ['items'], False);

        self.navtitle = utils.parseValue(longList, ['title']);
        self.navpath = utils.parseValue(longList, ['items', 'pagination', 'path']);
        self.navparams = utils.parseValue(longList, ['items', 'pagination', 'params']);

        if filters:

            if not isinstance(filters, list):
                filters = list([filters]);

            try:

                self.navmenu = dict();

                for oIdx, ftlr in enumerate(filters, 0):

                    fname = utils.parseValue(ftlr, ['name']);
                    fparam = utils.parseValue(ftlr, ['param']);
                    fvalue = utils.parseValue(ftlr, ['currentValue']);
                    fidx = 0;
                    fchoices = dict();

                    self.navmenu.update({
                        fname: dict()
                    });

                    buttons = utils.parseValue(ftlr, ['choices', 'button'], False);

                    if not isinstance(buttons, list):
                        buttons = list([buttons]);

                    for idx, button in enumerate(buttons, 0):

                        btitle = utils.parseValue(button, ['title']);
                        bvalue = utils.parseValue(button, ['value']);

                        fchoices.update({
                            idx: dict({
                                'title': btitle,
                                'value': bvalue
                            })
                        });

                        if bvalue == fvalue:
                            fidx = idx;

                    self.navmenu[fname].update({
                        'fname': fname,
                        'fparam': fparam,
                        'fvalue': fvalue,
                        'fidx': fidx,
                        'fchoices': fchoices
                    });


            except Exception as inst:
                self.logger.error(inst);


            if self.navmenu and len(self.navmenu) >= 1:
                self.setNavigationIndex();

            else:
                #throw an error
                pass;

        try:

            self.setVisible(LOADING_SCREEN, True);

            addOffset = False;

            import urlparse;
            import urllib;

            self.navparams = dict(urlparse.parse_qsl(self.navparams));

            if 'territory' in self.navparams:
                self.navparams.pop('territory');

            if 'subfilter' in self.navparams:
                self.navparams.pop('subfilter');

            self.navparams = urllib.urlencode(self.navparams);


            ceParams = self.navparams;

            if addOffset:
                ceParams = '%s&offset=0&limit=144' % ceParams;

            longList = funimationnow.getPage(self.navpath, ceParams);

            if longList:
                self.setShows(longList);


        except Exception as inst:
            self.logger.error(inst);
    def setupGenreSelect(self, genres):

        self.genredata = genres

        longList = utils.parseValue(genres, ['longList'], False)
        filters = utils.parseValue(longList, ['palette', 'filter'], False)
        items = utils.parseValue(longList, ['items'], False)

        self.navtitle = utils.parseValue(longList, ['title'])
        self.navpath = utils.parseValue(longList,
                                        ['items', 'pagination', 'path'])
        self.navparams = utils.parseValue(longList,
                                          ['items', 'pagination', 'params'])

        if filters:

            if not isinstance(filters, list):
                filters = list([filters])

            try:

                self.logger.debug(json.dumps(filters))

                self.navmenu = dict()

                for oIdx, ftlr in enumerate(filters, 0):

                    fplatform = utils.parseValue(ftlr, ['@platforms'])

                    if fplatform != 'appletv':

                        fname = utils.parseValue(ftlr, ['name'])
                        fparam = utils.parseValue(ftlr, ['param'])
                        fvalue = utils.parseValue(ftlr, ['currentValue'])
                        fidx = 0
                        fchoices = dict()

                        self.navmenu.update({fname: dict()})

                        buttons = utils.parseValue(ftlr, ['choices', 'button'],
                                                   False)

                        if not isinstance(buttons, list):
                            buttons = list([buttons])

                        #if oIdx == 0:
                        if fname == 'GENRE':

                            buttons.append(
                                dict({
                                    'title': 'RECENTLY ADDED',
                                    'value': 'recent'
                                }))

                            if self.navitemcurrent == 'recent':
                                fvalue = 'recent'

                            buttons = sorted(buttons, key=lambda k: k['title'])

                        for idx, button in enumerate(buttons, 0):

                            btitle = utils.parseValue(button, ['title'])
                            bvalue = utils.parseValue(button, ['value'])

                            if self.navitemcurrent == '%s-shows-web' % bvalue:

                                fvalue = bvalue
                                self.navitemcurrent = bvalue

                            fchoices.update({
                                idx:
                                dict({
                                    'title': btitle,
                                    'value': bvalue
                                })
                            })

                            if bvalue == fvalue:
                                fidx = idx

                        self.navmenu[fname].update({
                            'fname': fname,
                            'fparam': fparam,
                            'fvalue': fvalue,
                            'fidx': fidx,
                            'fchoices': fchoices
                        })

            except Exception as inst:
                self.logger.error(inst)

            if self.navmenu and len(self.navmenu) >= 1:
                self.setNavigationIndex()

            else:
                #throw an error
                pass

        try:

            self.setVisible(LOADING_SCREEN, True)

            addOffset = False

            if 'subfilter' in self.navmenuparams:

                import urlparse
                import urllib

                self.navparams = dict(urlparse.parse_qsl(self.navparams))

                for idx, menu in enumerate(self.navmenu, 0):

                    plItem = self.navmenu[menu]
                    plIdx = plItem.get('fidx', 0)
                    plParam = plItem.get('fparam', None)
                    plValue = plItem['fchoices'][plIdx].get('value', '')

                    if plValue == 'recent':
                        addOffset = True

                    if plParam:
                        self.navparams.update({plParam: plValue})

                if self.navparams.get(
                        'id',
                        None) == 'recent' and 'subfilter' in self.navparams:
                    self.navparams.pop('subfilter')

                if 'title' in self.navparams:
                    self.navparams.update({
                        'title':
                        re.sub(r'(Genre(%3A|:)(%20|[+ ]+))+', 'Genre: ',
                               self.navparams.get('title', ''), re.I)
                    })

                #self.navparams.update({'sort_direction': self.sortdirection[self.getControl(SORT_DIRECTION_BTN).isSelected()]});

                self.navparams = urllib.urlencode(self.navparams)

            else:
                addOffset = True

            ceParams = self.navparams

            if addOffset:
                ceParams = '%s&offset=0&limit=144' % ceParams

            longList = funimationnow.getPage(self.navpath, ceParams)

            if longList:
                self.setShows(longList)

        except Exception as inst:
            self.logger.error(inst)
    def setHomeScreenItems(self, pointers):

        #20000 - 20009
        #20500 - 20509

        utils.lock()
        #UI Locking is bad we want some kind of non locking notification for the main gui

        self.resetListContents()

        self.logger.debug('SETTING HOMESCREEN ITEMS')

        #sysaddon = sys.argv[0];
        #syshandle = int(sys.argv[1]);

        threads = []
        idx = 0

        for tidx, pointer in enumerate(pointers, 0):

            try:

                itemset = None
                longList = None
                navmenu = None

                #processes = [];

                mid = int('200%02d' % idx)
                lid = int('205%02d' % idx)
                qid = int('206%02d' % idx)

                if 'themes' in pointer:

                    if 'funType' in pointer:  #API Keeps changing, it appears they are adding device specific content in a poor fashion

                        funType = utils.parseValue(pointer, ['funType'])

                        #if funType == 'carousel_hero mobile-spotlight':
                        if funType == 'carousel_hero mobile-spotlight-android':
                            itemset = funimationnow.contentCarousel(
                                pointer, idx)

                        else:
                            continue

                elif 'longList' in pointer:

                    longList = pointer['longList']

                    if 'watchlist' in longList:
                        itemset = funimationnow.watchlist(pointer=pointer,
                                                          idx=idx)

                        if itemset and len(itemset) >= 4:

                            if itemset[2]:

                                mid = int('200%02d' % idx)

                                self.menus.update({mid: itemset[2]})

                                self.mkeys.update({itemset[0]: mid})

                                self.updates.update({mid: itemset[4]})

                            self.navigation.update({
                                mid:
                                dict({
                                    'navset': itemset[3],
                                    'navtype': 'watchlist'
                                })
                            })

                    else:

                        if 'themes' in longList:

                            dset = self.menus.get(
                                self.mkeys.get('history', None), None)
                            itemset = funimationnow.episode(
                                pointer, idx, dset)

                        else:

                            dset = self.menus.get(
                                self.mkeys.get('myqueue', None), None)
                            itemset = funimationnow.show(pointer, idx, dset)

                        if itemset:

                            if bool(
                                    re.compile(r'.*showGenres=true.*',
                                               re.I).match(itemset[2].get(
                                                   'params', ''))):
                                navType = 'genres'

                            else:
                                navType = 'dateadded'

                            self.navigation.update({
                                mid:
                                dict({
                                    'navset': itemset[2],
                                    'navtype': navType
                                })
                            })

                            #success = ['shows', shows, navigation];

                if itemset:
                    self.formatItemSet(threads, itemset, mid, lid, qid)

                try:

                    vset = [[
                        int('200%02d' % idx),
                        int('220%02d' % idx),
                        int('205%02d' % idx)
                    ], [int('900%02d' % idx)]]

                    self.setLoadingStates(vset, False)

                except Exception as inst:
                    self.logger.error(inst)

            except Exception as inst:
                self.logger.error(inst)

            idx += 1

        #See Line 696 & 812.  This is assigned to something, and should not be marked as an error
        [i.start() for i in threads]
        #[i.join() for i in threads];

        utils.unlock()

        self.logger.debug(self.navigation)