def select_art(items, manual_select=False, art_type=""):
     """select the preferred image from the list"""
     image = None
     if manual_select:
         # show selectdialog to manually select the item
         results_list = []
         # add none and browse entries
         listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(231))
         listitem.setArt({'icon': "DefaultAddonNone.png"})
         results_list.append(listitem)
         listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(1030))
         listitem.setArt({'icon': "DefaultFolder.png"})
         results_list.append(listitem)
         for item in items:
             labels = [
                 item["contributedby"], item["dateadded"], item["language"],
                 item["source"]
             ]
             label = " / ".join(labels)
             listitem = xbmcgui.ListItem(label=label)
             listitem.setArt({'icon': item["thumb"]})
             results_list.append(listitem)
         if manual_select and results_list:
             dialog = DialogSelect("DialogSelect.xml",
                                   "",
                                   listing=results_list,
                                   window_title=art_type)
             dialog.doModal()
             selected_item = dialog.result
             del dialog
             if selected_item == 0:
                 image = ""
             if selected_item == 1:
                 # browse for image
                 dialog = xbmcgui.Dialog()
                 if sys.version_info.major == 3:
                     image = dialog.browse(2,
                                           xbmc.getLocalizedString(1030),
                                           'files',
                                           mask='.gif')
                 else:
                     image = dialog.browse(2,
                                           xbmc.getLocalizedString(1030),
                                           'files',
                                           mask='.gif').decode("utf-8")
                 del dialog
             elif selected_item > 1:
                 # user has selected an image from online results
                 image = items[selected_item - 2]["image"]
     elif items:
         # just grab the first item as best match
         image = items[0]["image"]
     return image
Example #2
0
 def select_art(items, manual_select=False, art_type=""):
     '''select the preferred image from the list'''
     image = None
     if manual_select:
         # show selectdialog to manually select the item
         results_list = []
         # add none and browse entries
         listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(231), iconImage="DefaultAddonNone.png")
         results_list.append(listitem)
         listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(1030), iconImage="DefaultFolder.png")
         results_list.append(listitem)
         for item in items:
             labels = [item["contributedby"], item["dateadded"], item["language"], item["source"]]
             label = " / ".join(labels)
             listitem = xbmcgui.ListItem(label=label, iconImage=item["thumb"])
             results_list.append(listitem)
         if manual_select and results_list:
             dialog = DialogSelect("DialogSelect.xml", "", listing=results_list, window_title=art_type)
             dialog.doModal()
             selected_item = dialog.result
             del dialog
             if selected_item == 0:
                 image = ""
             if selected_item == 1:
                 # browse for image
                 dialog = xbmcgui.Dialog()
                 image = dialog.browse(2, xbmc.getLocalizedString(1030), 'files', mask='.gif').decode("utf-8")
                 del dialog
             elif selected_item > 1:
                 # user has selected an image from online results
                 image = items[selected_item - 2]["image"]
     elif items:
         # just grab the first item as best match
         image = items[0]["image"]
     return image
Example #3
0
    def manual_set_pvr_artwork(self, title, channel, genre):
        '''manual override artwork options'''

        artwork = self.get_pvr_artwork(title, channel, genre)
        cache_str = artwork["cachestr"]

        # show dialogselect with all artwork options
        abort = False
        while not abort:
            listitems = []
            for arttype in ["thumb", "poster", "fanart", "banner", "clearart", "clearlogo",
                            "discart", "landscape", "characterart"]:
                listitem = xbmcgui.ListItem(label=arttype, iconImage=artwork["art"].get(arttype, ""))
                listitem.setProperty("icon", artwork["art"].get(arttype, ""))
                listitems.append(listitem)
            dialog = DialogSelect("DialogSelect.xml", "", listing=listitems,
                                  windowtitle=xbmc.getLocalizedString(13511), multiselect=False)
            dialog.doModal()
            selected_item = dialog.result
            del dialog
            if selected_item == -1:
                abort = True
            else:
                # show results for selected art type
                artoptions = []
                selected_item = listitems[selected_item]
                image = selected_item.getProperty("icon").decode("utf-8")
                label = selected_item.getLabel().decode("utf-8")
                heading = "%s: %s" % (xbmc.getLocalizedString(13511), label)
                if image:
                    # current image
                    listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(13512), iconImage=image)
                    listitem.setProperty("icon", image)
                    artoptions.append(listitem)
                    # none option
                    listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(231), iconImage="DefaultAddonNone.png")
                    listitem.setProperty("icon", "DefaultAddonNone.png")
                    artoptions.append(listitem)
                # browse option
                listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(1024), iconImage="DefaultFolder.png")
                listitem.setProperty("icon", "DefaultFolder.png")
                artoptions.append(listitem)

                # add remaining images as option
                allarts = artwork["art"].get(label + "s", [])
                if len(allarts) > 1:
                    for item in allarts:
                        listitem = xbmcgui.ListItem(label=item, iconImage=item)
                        listitem.setProperty("icon", item)
                        artoptions.append(listitem)

                dialog = DialogSelect("DialogSelect.xml", "", listing=artoptions, window_title=heading)
                dialog.doModal()
                selected_item = dialog.result
                del dialog
                if image and selected_item == 1:
                    artwork["art"][label] = ""
                elif image and selected_item > 2:
                    artwork["art"][label] = artoptions[selected_item].getProperty("icon").decode("utf-8")
                elif (image and selected_item == 2) or not image and selected_item == 0:
                    # manual browse...
                    dialog = xbmcgui.Dialog()
                    image = dialog.browse(2, xbmc.getLocalizedString(1030),
                                          'files', mask='.gif|.png|.jpg').decode("utf-8")
                    del dialog
                    if image:
                        artwork["art"][label] = image

        # save results in cache
        self.artutils.cache.set(cache_str, artwork, expiration=timedelta(days=120))