Exemplo n.º 1
0
    def createOptionList(self):

        selectList = self.getControl(20);
        items = self.listset['fchoices'].items();
        fidx = self.listset['fidx'];

        selectList.setPosition(self.sX, self.sY);


        for idx, listData in items:

            listTitle = listData.get('title', '');
            listFile = re.sub(r'[/]+', '_', listTitle, re.I);

            listImg = os.path.join(self.select_list, ('%s.png' % listFile));

            if not os.path.isfile(listImg):
                utils.text2Display(listTitle, 'RGB', (242, 242, 242), (0, 0, 0), 28, 'Bold', listImg, multiplier=1, sharpen=True, bgimage=None);

            listitem = xbmcgui.ListItem('', '', listImg, listImg);

            selectList.addItem(listitem);

        try:
            xbmc.executebuiltin('Control.SetFocus(20, %s)' % fidx);

        except:
            pass;
    def makeDetails(self, details):

        for detail in details:

            if detail[0]:
                utils.text2Display(detail[0],
                                   'RGB', (164, 164, 164), (255, 255, 255),
                                   detail[1],
                                   'ExtraBold',
                                   detail[2],
                                   multiplier=1,
                                   sharpen=False,
                                   bgimage=None)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def createDialofTextImgs(self):

        try:

            #lang = utils.addon.getLocalizedString;

            dialogTitle = utils.lang(30900).encode('utf-8')
            tempImg = os.path.join(self.dialog_content, 'title_rating.png')

            utils.text2Display(dialogTitle,
                               'RGB', (255, 255, 255), (0, 0, 0),
                               36,
                               'Regular',
                               tempImg,
                               multiplier=1,
                               sharpen=False,
                               bgimage=None)

            dialogBtn = utils.lang(30901).encode('utf-8')
            tempImgFocus = os.path.join(self.dialog_content,
                                        'focus_rating.png')
            tempImgNoFocus = os.path.join(self.dialog_content,
                                          'nofocus_rating.png')

            utils.text2Display(dialogBtn,
                               'RGB',
                               None, (255, 255, 255),
                               36,
                               'Bold',
                               tempImgFocus,
                               multiplier=1,
                               sharpen=False,
                               bgimage='rating_cancel_focus.png')
            utils.text2Display(dialogBtn,
                               'RGB',
                               None, (150, 39, 171),
                               36,
                               'Bold',
                               tempImgNoFocus,
                               multiplier=1,
                               sharpen=False,
                               bgimage='rating_cancel_no_focus.png')

        except:
            pass
    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 setListContent(self, viewType):

        try:

            cData = self.contentMaps.get(viewType, None)

            if cData:

                for idx, panel in enumerate(PANEL_LISTS, 0):

                    if self.currentChoice == idx:
                        self.setVisible(panel, True)

                    else:
                        self.setVisible(panel, False)

                lcontrol = self.getControl(PANEL_LISTS[self.currentChoice])

                lItems = cData.get('items', None)

                if (lItems is None or len(lItems) < 1):

                    self.isEmpty = True

                    lItems = self.contentMaps[viewType]

                    titles = [lItems['emptytext']]
                    listitem = None
                    listitem = xbmcgui.ListItem(titles[0], titles[0],
                                                lItems['emptythumb'],
                                                lItems['emptythumb'])

                    titleimg = utils.text2Title(list(titles),
                                                self.details_home_title,
                                                'emptytext_%s.png' % viewType)

                    if titleimg:
                        listitem.setProperty('ctitle', titleimg)

                    lcontrol.addItem(listitem)

                else:

                    self.isEmpty = False

                    for sIdx, item in enumerate(cData.get('items'), 0):

                        titles = []
                        listitem = None
                        listitem = xbmcgui.ListItem(item.get('title', ''),
                                                    item.get('subtitle', ''),
                                                    item.get('thumbnail', ''),
                                                    item.get('thumbnail', ''))

                        if self.currentChoice == 0:
                            titles = [item.get('title', '')]

                        else:
                            titles = [
                                item.get('title', ''),
                                item.get('subtitle', '')
                            ]

                        titleimg = utils.text2Title(list(titles),
                                                    self.details_home_title,
                                                    item.get('titleimg', ''))

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

                        try:

                            listitem.setProperty('viewtype', str(viewType))

                            for attr, val in item.items():

                                listitem.setProperty(attr, str(val))

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

                        if 'progress' in item:

                            cprogress = item.get('progress', 0)

                            listitem.setProperty('cprogress', str(cprogress))

                        if 'inQueue' in item:

                            inQueue = item.get('inQueue', None)

                            if inQueue is not None:

                                listitem.setProperty('qtexture', str(inQueue))

                        if 'quality' in item:

                            quality = item.get('quality', None)

                            if quality is not None:

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

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

                                listitem.setProperty('quality', tempImg)

                        if 'releaseYear' in item:

                            releaseYear = item.get('releaseYear', None)

                            if releaseYear is not None:

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

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

                                listitem.setProperty('releaseYear', tempImg)

                        if 'starRating' in item:

                            starRating = item.get('starRating', 0)
                            starRating = str(
                                utils.roundQuarter(str(starRating)))
                            listitem.setProperty('starrating', starRating)

                        if titleimg:
                            listitem.setProperty('ctitle', titleimg)

                        lcontrol.addItem(listitem)

            else:

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

        except Exception as inst:
            self.logger.error(inst)
Exemplo n.º 7
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);