Пример #1
0
 def makeListItem(self, replaceItems=False):
     colorItem = getSetting('item_default_color')
     colorPl = getSetting('item_section_color')
     label = self.get_label()
     image = self.get_image()
     owner = self.get_owner()
     url = self.make_url()
     if not self.is_my_playlist:
         label = '%s - %s' % (color(colorItem, owner), label)
     if self.b_is_current:
         fmt = getSetting('playlist_current_format')
         label = fmt % (color(colorPl, label))
     item = xbmcgui.ListItem(label,
                             owner,
                             image,
                             image,
                             url)
     if not item:
         warn(self, "Error: Cannot make xbmc list item")
         return None
     item.setPath(url)
     ctxMenu = contextMenu()
     self.attach_context_menu(item, ctxMenu)
     item.addContextMenuItems(ctxMenu.getTuples(), replaceItems)
     return item
Пример #2
0
 def __add_pagination_node(self, Dir, lvl=1, whiteFlag=Flag.NODE):
     """Helper/Called by build_down to add special node when pagination is
     required
     """
     if self.pagination_next:
         colorItem = getSetting('color_item')
         params = config.app.bootstrap.params
         params['offset'] = self.pagination_next_offset
         params['nid'] = self.nid
         node = getNode(self.nt, params)
         node.data = self.data
         label = self.get_label()
         if label is None:
             if self.label2 is not None:
                 label = self.label2
             elif self.parent is not None:
                 label = self.parent.get_label()
             else:
                 label = '[no-label]'
         nextLabel = u'[ {}  {} / {} ]'.format(color(colorItem, label),
                                             self.pagination_next_offset,
                                             self.pagination_total)
         node.label = nextLabel
         node.label2 = label
         self.add_child(node)
Пример #3
0
    def getTuples(self):
        menuItems = []

        def sectionSort(key):
            return self.data[key]["pos"]

        def itemSort(item):
            return item["pos"]

        for section in sorted(self.data, key=sectionSort):
            colorItem = self.color_section
            data = self.data[section]
            if "color" in data and data["color"]:
                colorItem = data["color"]
            label = self.format_section % (color(colorItem, data["label"]))
            # menuItems.append((label, data['cmd']))
            for item in sorted(data["childs"], key=itemSort):
                colorItem = self.color_default
                if "color" in item and item["color"]:
                    colorItem = item["color"]
                label = "%s" % (color(colorItem, item["label"]))
                menuItems.append((label, item["cmd"]))
        return menuItems
Пример #4
0
 def gui_remove(self, playlist_id=None):
     if not playlist_id:
         playlist_id = self.nid
     if not playlist_id:
         notify_error(dialogHeading,
                      'Invalid playlist %s' % (str(playlist_id)))
         return False
     login = getSetting('username')
     offset = 0
     limit = getSetting('pagination_limit')
     data = api.get('/playlist/get', playlist_id=playlist_id, limit=limit,
                    offset=offset)
     name = ''
     if 'name' in data:
         name = data['name']
     ok = xbmcgui.Dialog().yesno(lang(30166),
                                 lang(30054),
                                 color('FFFF0000', name))
     if not ok:
         info(self, "Deleting playlist aborted...")
         return False
     res = False
     if data['owner']['name'] == login:
         info(self, "Deleting playlist: " + str(playlist_id))
         res = api.playlist_delete(playlist_id=playlist_id)
     else:
         info(self, 'Unsuscribe playlist' + str(playlist_id))
         res = api.playlist_unsubscribe(playlist_id=playlist_id)
     if not res:
         warn(self, "Cannot delete playlist with id " + str(playlist_id))
         notify_error(lang(30183), lang(30186) + name)
         return False
     self.delete_cache(playlist_id)
     notify_log(lang(30183), (lang(30184) + "%s" + lang(30185)) % (name))
     url = self.make_url(nt=Flag.USERPLAYLISTS, mode=Mode.VIEW, nm='',
                         nid='')
     executeBuiltin(containerUpdate(url, True))
     return False
Пример #5
0
 def set_label(self, label):
     colorItem = getSetting('color_item')
     self.label = color(colorItem, label)