Exemplo n.º 1
0
 def get_slider(self):
     if xbmc.skinHasImage("settings/slider_back.png"):
         statusSlider = xbmcgui.ControlSlider(
             self.x + 30,
             self.y + 130,
             310,
             15,
             textureback="settings/slider_back.png",
             texture="settings/orb_nofo.png",
             texturefocus="settings/orb_fo.png",
         )
         return statusSlider
     elif xbmc.skinHasImage("slider.png"):
         statusSlider = xbmcgui.ControlSlider(
             self.x + 80,
             self.y + 130,
             240,
             20,
             textureback="slider.png",
             texture="osd_slider_nibNF.png",
             texturefocus="osd_slider_nib.png",
         )
         return statusSlider
     else:
         statusSlider = xbmcgui.ControlSlider(
             self.x + 80,
             self.y + 130,
             240,
             20,
             textureback=sliderbarImg,
             texture=sliderNibImgNF,
             texturefocus=sliderNibImg,
         )
         return statusSlider
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        self.focusRow = 0
        self.focusIndex = 0
        self.focusTime = 0
        self.focusEndTime = 0
        self.shownTime = 0
        self.centerChannel = 0
        self.rowCount = 6
        self.channelButtons = [None] * self.rowCount
        self.buttonCache = []
        self.buttonCount = 0
        self.actionSemaphore = threading.BoundedSemaphore()
        self.lastActionTime = time.time()
        self.channelLogos = ''
        self.textcolor = "FFFFFFFF"
        self.focusedcolor = "FF7d7d7d"
        self.clockMode = 0
        self.textfont  = "font14"

        # Decide whether to use the current skin or the default skin.  If the current skin has the proper
        # image, then it should work.
        if os.path.exists(xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media'))):
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media')) + '/'
        elif os.path.exists(xbmc.translatePath('special://skin/media/' + ADDON_ID + '/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath('special://skin/media/' + ADDON_ID + '/')
        elif os.path.exists(xbmc.translatePath('special://skin/media/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath('special://skin/media/')
        elif xbmc.skinHasImage(xbmc.translatePath(ADDON_ID + '/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath(ADDON_ID + '/')
        elif xbmc.skinHasImage(TIME_BAR):
            self.mediaPath = ''
        else:
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', 'default', 'media')) + '/'

        self.log('Media Path is ' + self.mediaPath)

        # Use the given focus and non-focus textures if they exist.  Otherwise use the defaults.
        if os.path.exists(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        elif xbmc.skinHasImage(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        else:
            self.textureButtonFocus = 'button-focus.png'

        if os.path.exists(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        elif xbmc.skinHasImage(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        else:
            self.textureButtonNoFocus = 'button-nofocus.png'

        for i in range(self.rowCount):
            self.channelButtons[i] = []

        self.clockMode = ADDON_SETTINGS.getSetting("ClockMode")
        self.toRemove = []
Exemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        self.focusRow = 0
        self.focusIndex = 0
        self.focusTime = 0
        self.focusEndTime = 0
        self.shownTime = 0
        self.centerChannel = 0
        self.rowCount = 6
        self.channelButtons = [None] * self.rowCount
        self.buttonCache = []
        self.buttonCount = 0
        self.actionSemaphore = threading.BoundedSemaphore()
        self.lastActionTime = time.time()
        self.channelLogos = ''
        self.textcolor = "FFFFFFFF"
        self.focusedcolor = "FF7d7d7d"
        self.clockMode = 0

        # Decide whether to use the current skin or the default skin.  If the current skin has the proper
        # image, then it should work.
        if os.path.exists(xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media'))):
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media')) + '/'
        elif os.path.exists(xbmc.translatePath('special://skin/media/' + ADDON_ID + '/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath('special://skin/media/' + ADDON_ID + '/')
        elif os.path.exists(xbmc.translatePath('special://skin/media/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath('special://skin/media/')
        elif xbmc.skinHasImage(xbmc.translatePath(ADDON_ID + '/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath(ADDON_ID + '/')
        elif xbmc.skinHasImage(TIME_BAR):
            self.mediaPath = ''
        else:
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', 'default', 'media')) + '/'

        self.log('Media Path is ' + self.mediaPath)

        # Use the given focus and non-focus textures if they exist.  Otherwise use the defaults.
        if os.path.exists(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        elif xbmc.skinHasImage(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        else:
            self.textureButtonFocus = 'button-focus.png'

        if os.path.exists(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        elif xbmc.skinHasImage(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        else:
            self.textureButtonNoFocus = 'button-nofocus.png'

        for i in range(self.rowCount):
            self.channelButtons[i] = []

        self.clockMode = ADDON_SETTINGS.getSetting("ClockMode")
Exemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        self.focusRow = 0
        self.focusIndex = 0
        self.focusTime = 0
        self.focusEndTime = 0
        self.shownTime = 0
        self.centerChannel = 0
        self.rowCount = 6
        self.channelButtons = [None] * self.rowCount
        self.buttonCache = []
        self.actionSemaphore = threading.BoundedSemaphore()
        self.lastActionTime = time.time()
        self.channelLogos = ''
        self.textcolor = "FFFFFFFF"
        self.focusedcolor = "FF7d7d7d"
        self.clockMode = 0
        self.textfont = "font13"

        # Set media path.
        if os.path.exists(
                xbmc.translatePath(
                    os.path.join(CWD, 'resources', 'skins', xbmc.getSkinDir(),
                                 'media'))):
            self.mediaPath = xbmc.translatePath(
                os.path.join(CWD, 'resources', 'skins', xbmc.getSkinDir(),
                             'media' + '/'))
        else:
            self.mediaPath = xbmc.translatePath(
                os.path.join(CWD, 'resources', 'skins', 'default',
                             'media' + '/'))

        self.log('Media Path is ' + self.mediaPath)

        # Use the given focus and non-focus textures if they exist.  Otherwise use the defaults.
        if xbmc.skinHasImage(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        else:
            self.textureButtonFocus = 'button-focus.png'

        if xbmc.skinHasImage(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        else:
            self.textureButtonNoFocus = 'button-nofocus.png'

        for i in range(self.rowCount):
            self.channelButtons[i] = []

        self.clockMode = ADDON_SETTINGS.getSetting("ClockMode")
        self.toRemove = []
Exemplo n.º 5
0
def getTexture( texture ):
    if not xbmc.skinHasImage( texture ):
        if os.path.isfile( os.path.join( MEDIA_PATH, texture ) ):
            texture = os.path.join( MEDIA_PATH, texture )
        else:
            texture = ""
    return texture
Exemplo n.º 6
0
def getTexture(texture):
    if not xbmc.skinHasImage(texture):
        if os.path.isfile(os.path.join(MEDIA_PATH, texture)):
            texture = os.path.join(MEDIA_PATH, texture)
        else:
            texture = ""
    return texture
Exemplo n.º 7
0
 def _get_icon_overrides( self, tree, icon, group, labelID, setToDefault = True ):
     # This function will get any icon overrides based on labelID or group
     if icon is None:
         return
     oldicon = None
     newicon = icon
     
     # Check for overrides
     if tree is not None:
         for elem in tree.findall( "icon" ):
             if oldicon is None:
                 if ("labelID" in elem.attrib and elem.attrib.get( "labelID" ) == labelID) or ("image" in elem.attrib and elem.attrib.get( "image" ) == icon):
                     # LabelID matched
                     if "group" in elem.attrib:
                         if elem.attrib.get( "group" ) == group:
                             # Group also matches - change icon
                             oldicon = icon
                             newicon = elem.text
                             
                     elif "grouping" not in elem.attrib:
                         # No group - change icon
                         oldicon = icon
                         newicon = elem.text
     
     if not xbmc.skinHasImage( newicon ) and setToDefault == True:
         newicon = self._get_icon_overrides( tree, "DefaultShortcut.png", group, labelID, False )
     return newicon
 def _set_fanart( self, fanart ):
     # if user passed fanart tuple (path, method,)
     if ( fanart is not None ):
         # if skin has fanart image use it
         fanart_image = os.path.join( sys.modules[ "__main__" ].__plugin__, fanart[ 1 ] + "-fanart.png" )
         if ( xbmc.skinHasImage( fanart_image ) ):
             xbmcplugin.setPluginFanart( handle=self.m_handle, image=fanart_image )
         # set our fanart from user setting
         elif ( fanart[ 0 ] ):
             xbmcplugin.setPluginFanart( handle=self.m_handle, image=fanart[ 0 ] )
Exemplo n.º 9
0
 def _get_thumbnail( self, title ):
     # create the full thumbnail path for skins directory
     thumbnail = os.path.join( sys.modules[ "__main__" ].__plugin__, title + ".png" )
     # use a plugin custom thumbnail if a custom skin thumbnail does not exists
     if ( not xbmc.skinHasImage( thumbnail ) ):
         # create the full thumbnail path for plugin directory
         thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, title + ".png" )
         # use a default thumbnail if a custom thumbnail does not exists
         if ( not os.path.isfile( thumbnail ) ):
             thumbnail = "DefaultFolder.png"
     return thumbnail
Exemplo n.º 10
0
 def _get_thumbnail( self, title ):
     # create the full thumbnail path for skins directory
     thumbnail = os.path.join( sys.modules[ "__main__" ].__plugin__, title + ".png" )
     # use a plugin custom thumbnail if a custom skin thumbnail does not exists
     if ( not xbmc.skinHasImage( thumbnail ) ):
         # create the full thumbnail path for plugin directory
         thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, title + ".png" )
         # use a default thumbnail if a custom thumbnail does not exists
         if ( not os.path.isfile( thumbnail ) ):
             thumbnail = "DefaultFolder.png"
     return thumbnail
def _openimage(image, targetpath, filename):
    """ Open image helper with thanks to sualfred """
    # some paths require unquoting to get a valid cached thumb hash
    cached_image_path = urllib.unquote(image.replace('image://', ''))
    if cached_image_path.endswith('/'):
        cached_image_path = cached_image_path[:-1]

    cached_files = []
    for path in [xbmc.getCacheThumbName(cached_image_path), xbmc.getCacheThumbName(image)]:
        cached_files.append(os.path.join('special://profile/Thumbnails/', path[0], path[:-4] + '.jpg'))
        cached_files.append(os.path.join('special://profile/Thumbnails/', path[0], path[:-4] + '.png'))
        cached_files.append(os.path.join('special://profile/Thumbnails/Video/', path[0], path))

    for i in range(1, 4):
        try:
            ''' Try to get cached image at first
            '''
            for cache in cached_files:
                if xbmcvfs.exists(cache):
                    try:
                        img = Image.open(xbmc.translatePath(cache))
                        return img

                    except Exception as error:
                        utils.kodi_log('Image error: Could not open cached image --> %s' % error, 2)

            ''' Skin images will be tried to be accessed directly. For all other ones
                the source will be copied to the addon_data folder to get access.
            '''
            if xbmc.skinHasImage(image):
                if not image.startswith('special://skin'):
                    image = os.path.join('special://skin/media/', image)

                try:  # in case image is packed in textures.xbt
                    img = Image.open(xbmc.translatePath(image))
                    return img

                except Exception:
                    return ''

            else:
                targetfile = os.path.join(targetpath, filename)
                if not xbmcvfs.exists(targetfile):
                    xbmcvfs.copy(image, targetfile)

                img = Image.open(targetfile)
                return img

        except Exception as error:
            utils.kodi_log('Image error: Could not get image for %s (try %d) -> %s' % (image, i, error), 2)
            xbmc.sleep(500)
            pass

    return ''
Exemplo n.º 12
0
	def getThumbnail(self, title):
		if (not title):
			title = "DefaultFolder.png"

		thumbnail = os.path.join(sys.modules[ "__main__" ].__plugin__, title + ".png")

		if (not xbmc.skinHasImage(thumbnail)):
			thumbnail = os.path.join(self.plugin_thumbnail_path, title + ".png")
			if (not os.path.isfile(thumbnail)):
				thumbnail = "DefaultFolder.png"

		return thumbnail
Exemplo n.º 13
0
	def getThumbnail( self, title ):
		if (not title):
			title = "DefaultFolder.png"
		
		thumbnail = os.path.join( sys.modules[ "__main__" ].__plugin__, title + ".png" )
		
		if ( not xbmc.skinHasImage( thumbnail ) ):
			thumbnail = os.path.join( self.plugin_thumbnail_path, title + ".png" )
			if ( not os.path.isfile( thumbnail ) ):
				thumbnail = "DefaultFolder.png"	
		
		return thumbnail
Exemplo n.º 14
0
def getThumbnail(title):
    if not title:
        title = DEFAULT_FOLDER_TITLE

    thumbnail = os.path.join(ADDON_NAME, title + '.png')

    if not xbmc.skinHasImage(thumbnail):
        thumbnail = os.path.join(THUMBNAIL_PATH, title + '.png')
        if not os.path.isfile(thumbnail):
            thumbnail = DEFAULT_FOLDER_IMAGE

    return thumbnail
Exemplo n.º 15
0
def getThumbnail(title):
    if not title:
        title = DEFAULT_FOLDER_TITLE

    thumbnail = os.path.join(ADDON_NAME, title + '.png')

    if not xbmc.skinHasImage(thumbnail):
        thumbnail = os.path.join(THUMBNAIL_PATH, title + '.png')
        if not os.path.isfile(thumbnail):
            thumbnail = DEFAULT_FOLDER_IMAGE

    return thumbnail
Exemplo n.º 16
0
 def _set_fanart(self, fanart):
     # if user passed fanart tuple (path, method,)
     if (fanart is not None):
         # if skin has fanart image use it
         fanart_image = os.path.join(sys.modules["__main__"].__plugin__,
                                     fanart[1] + "-fanart.png")
         if (xbmc.skinHasImage(fanart_image)):
             xbmcplugin.setPluginFanart(handle=self.m_handle,
                                        image=fanart_image)
         # set our fanart from user setting
         elif (fanart[0]):
             xbmcplugin.setPluginFanart(handle=self.m_handle,
                                        image=fanart[0])
Exemplo n.º 17
0
def get_title_control(text_or_id, addon):
    '''
    use this method to make sure view titles are everywhere on the same position
    '''
    #xbmc.log("label: " + str(text_or_id), level=xbmc.LOGNOTICE)
    if isinstance(text_or_id, int):
        label = addon.getLocalizedString(text_or_id)
    else:
        label = text_or_id
    if xbmc.skinHasImage('settings/slider_back.png'):
        control = xbmcgui.ControlLabel(330, 65, 600, 75, label, font="Font_Reg22")
    else:
        control = xbmcgui.ControlLabel(400, 50, 600, 75, label, font="font16")
    return control
Exemplo n.º 18
0
    def __init__(self, *args, **kwargs):
        self.epgdata = EPGData()
        self.epgdata.epgwindow = self

        self.focusRow = 0
        self.focusIndex = 0
        self.shownTime = 0
        self.centerChannel = 0
        self.rowCount = 6
        self.channelButtons = [None] * self.rowCount
        self.actionSemaphore = threading.BoundedSemaphore()
        self.lastActionTime = time.time()
        self.textcolor = "FFFFFFFF"
        self.focusedcolor = "FF7d7d7d"
        self.clockMode = "0"

        self.channelLabel = [] #adding channel numbers
        self.inputChannel = -1

        # Decide whether to use the current skin or the default skin.  If the current skin has the proper
        # image, then it should work.
        if os.path.exists(xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media'))):
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', xbmc.getSkinDir(), 'media')) + '/'
        elif os.path.exists(xbmc.translatePath('special://skin/media/' + TIME_BAR)):
            self.mediaPath = xbmc.translatePath('special://skin/media/')
        elif xbmc.skinHasImage(TIME_BAR):
            self.mediaPath = ''
        else:
            self.mediaPath = xbmc.translatePath(os.path.join(ADDON_INFO, 'resources', 'skins', 'default', 'media')) + '/'

        self.log('Media Path is ' + self.mediaPath)

        # Use the given focus and non-focus textures if they exist.  Otherwise use the defaults.
        if os.path.exists(self.mediaPath + BUTTON_FOCUS):
            self.textureButtonFocus = self.mediaPath + BUTTON_FOCUS
        else:
            self.textureButtonFocus = 'button-focus.png'

        if os.path.exists(self.mediaPath + BUTTON_NO_FOCUS):
            self.textureButtonNoFocus = self.mediaPath + BUTTON_NO_FOCUS
        else:
            self.textureButtonNoFocus = 'button-nofocus.png'

        for i in range(self.rowCount):
            self.channelButtons[i] = []
    def find_other_match(fav):
        '''create listitem for any other item in favourites'''
        item = {}
        is_folder = False
        if fav["type"] == "window":
            media_path = fav["windowparameter"]
            is_folder = True
        elif fav["type"] == "media":
            media_path = fav["path"]
        else:
            media_path = 'plugin://script.skin.helper.service/?action=launch&path=%s'\
                % quote_plus(fav.get("path"))
        if not fav.get("label"):
            fav["label"] = fav.get("title")
        if not fav.get("title"):
            fav["label"] = fav.get("label")

        thumb = fav.get("thumbnail")
        fanart = ""
        if "plugin://" in fav["path"]:
            # get fanart and thumb for addons
            addon = fav["path"].split("plugin://")[1].split("/")[0]
            if not (xbmcvfs.exists(thumb) or xbmc.skinHasImage(thumb)):
                if xbmcvfs.exists("special://home/addons/%s/icon.png" % addon):
                    thumb = "special://home/addons/%s/icon.png" % addon
            if xbmcvfs.exists("special://home/addons/%s/fanart.jpg" % addon):
                fanart = "special://home/addons/%s/fanart.jpg" % addon

        item = {
            "label": fav.get("label"),
            "title": fav.get("title"),
            "thumbnail": thumb,
            "fanart": fanart,
            "file": media_path,
            "type": "favourite",
            "art": {
                "landscape": thumb,
                "poster": thumb,
                "fanart": fanart
            }
        }
        if is_folder:
            item["isFolder"] = True
        return item
Exemplo n.º 20
0
    def getTexture(self, texture):
        """ verifie si la texture existe dans le XBT du skin en cours,
            sinon retourne le chemin complet
        """
        if not texture or os.path.exists(texture) or xbmc.skinHasImage(texture):
            return texture

        # check in xbmc skin
        skinpath = xbmc.translatePath("special://skin")
        if os.path.exists(os.path.join(skinpath, texture)):
            texture = os.path.join(skinpath, texture)
        # check in xbmc skin media
        elif os.path.exists(os.path.join(skinpath, "media", texture)):
            texture = os.path.join(skinpath, "media", texture)
        # check in add-on skins
        elif os.path.exists(os.path.join(self.spriteDir, texture)):
            texture = os.path.join(self.spriteDir, texture)

        return texture
Exemplo n.º 21
0
    def find_other_match(fav):
        '''create listitem for any other item in favourites'''
        item = {}
        is_folder = False
        if fav["type"] == "window":
            media_path = fav["windowparameter"]
            is_folder = True
        elif fav["type"] == "media":
            media_path = fav["path"]
        else:
            media_path = 'plugin://script.skin.helper.service/?action=launch&path=%s'\
                % quote_plus(fav.get("path"))
        if not fav.get("label"):
            fav["label"] = fav.get("title")
        if not fav.get("title"):
            fav["label"] = fav.get("label")

        thumb = fav.get("thumbnail")
        fanart = ""
        if "plugin://" in fav["path"]:
            # get fanart and thumb for addons
            addon = fav["path"].split("plugin://")[1].split("/")[0]
            if not (xbmcvfs.exists(thumb) or xbmc.skinHasImage(thumb)):
                if xbmcvfs.exists("special://home/addons/%s/icon.png" % addon):
                    thumb = "special://home/addons/%s/icon.png" % addon
            if xbmcvfs.exists("special://home/addons/%s/fanart.jpg" % addon):
                fanart = "special://home/addons/%s/fanart.jpg" % addon

        item = {
            "label": fav.get("label"),
            "title": fav.get("title"),
            "thumbnail": thumb,
            "fanart": fanart,
            "file": media_path,
            "type": "favourite",
            "art": {
                "landscape": thumb,
                "poster": thumb,
                "fanart": fanart}
        }
        if is_folder:
            item["isFolder"] = True
        return item
Exemplo n.º 22
0
def get_title_control(text_or_id, addon):
    '''
    use this method to make sure view titles are everywhere on the same position
    '''
    #xbmc.log("label: " + str(text_or_id), level=xbmc.LOGNOTICE)
    if isinstance(text_or_id, int):
        label = addon.getLocalizedString(text_or_id)
    else:
        label = text_or_id
    if xbmc.skinHasImage('settings/slider_back.png'):
        control = xbmcgui.ControlLabel(330,
                                       65,
                                       600,
                                       75,
                                       label,
                                       font="Font_Reg22")
    else:
        control = xbmcgui.ControlLabel(400, 50, 600, 75, label, font="font16")
    return control
Exemplo n.º 23
0
    def getTexture(self, texture):
        """ verifie si la texture existe dans le XBT du skin en cours,
            sinon retourne le chemin complet
        """
        if not texture or os.path.exists(texture) or xbmc.skinHasImage(
                texture):
            return texture

        # check in xbmc skin
        skinpath = xbmc.translatePath("special://skin")
        if os.path.exists(os.path.join(skinpath, texture)):
            texture = os.path.join(skinpath, texture)
        # check in xbmc skin media
        elif os.path.exists(os.path.join(skinpath, "media", texture)):
            texture = os.path.join(skinpath, "media", texture)
        # check in add-on skins
        elif os.path.exists(os.path.join(self.spriteDir, texture)):
            texture = os.path.join(self.spriteDir, texture)

        return texture
Exemplo n.º 24
0
 def _fill_media_list( self, items ):
     try:
         ok = True
         # enumerate through the list of items and add the item to the media list
         for item in items:
             # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
             listitem=xbmcgui.ListItem( label=item.title, iconImage=item.icon, thumbnailImage=item.thumbnail_url )
             # TODO: add info and sort methods
             # add the different infolabels we want to sort by
             listitem.setInfo( type="Pictures", infoLabels={ "Title": item.title } )#, "Genre": self.args.title, "Duration": video.duration, "Date": video.date } )
             # we add additional properties and infolabels for pictures
             if ( not item.isFolder ):
                 listitem.setInfo( type="Pictures", infoLabels={ "Date": "%s-%s-%s" % ( item.datetaken[ 8 : 10 ], item.datetaken[ 5 : 7 ], item.datetaken[  : 4 ], ), } )#"Size": item[ "photo_size" ], "exif:exiftime": item[ "photo_datetime" ], "exif:resolution": "%d,%d" % ( item[ "photo_width" ], item[ "photo_height" ], ) } )
                 # skins display these with ListItem.Property(User)...
                 listitem.setProperty( "User", item.author )
                 listitem.setProperty( "Description", item.description )
                 listitem.setProperty( "DateTaken", item.datetaken )
             # add the item to the media list
             ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=item.url, listitem=listitem, isFolder=item.isFolder, totalItems=len( items ) )
             # if user cancels, call raise to exit loop
             if ( not ok ): raise
     except:
         # user cancelled dialog or an error occurred
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if ( ok ):
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE )
         # set our plugin category
         xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=self.args.title )
         # if skin has fanart image use it
         fanart_image = os.path.join( sys.modules[ "__main__" ].__plugin__, self.args.category + "-fanart.png" )
         if ( xbmc.skinHasImage( fanart_image ) ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=fanart_image )
         # set our fanart from user setting
         elif ( self.settings[ "fanart_image" ] ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=self.settings[ "fanart_image" ] )
     return ok, len( items )
Exemplo n.º 25
0
 def _fill_media_list(self, ok, videos):
     try:
         # calculate total items
         total_items = len(videos)
         # if ok (always is for now) fill directory
         if (ok):
             # set our thumbnail for queries
             self.query_thumbnail = videos[0]["thumbnail"]
             # enumerate through the list of pictures and add the item to the media list
             for c, video in enumerate(videos):
                 # only add videos with a valid video url
                 if (len(video["video_urls"])):
                     # plot
                     plot = xbmc.getLocalizedString(30904)
                     if (video["desc"]):
                         plot = video["desc"]
                         plot = self._clean_text(plot.strip())
                     # format runtime as 00:00
                     run = int(video["runtime"])
                     runtime = ""
                     # video runtime
                     if (run):
                         runtime = "%02d:%02d" % (
                             int(run / 60),
                             run % 60,
                         )
                     # viewer rating
                     try:
                         rating = float(video["rating"])
                     except:
                         rating = 0.0
                     # genre
                     genre = video["genre"]
                     # updated date
                     #<pubDate>Wed, 16 Apr 2008 18:00:30 +0000</pubDate>
                     mm = [
                         "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
                         "Aug", "Sep", "Oct", "Nov", "Dec"
                     ].index(video["date"][8:11])
                     date = "%02d-%02d-%04d" % (
                         int(video["date"][5:7]),
                         mm + 1,
                         int(video["date"][12:16]),
                     )
                     # construct our url
                     video_url = video["video_urls"][0]
                     for vid in video["video_urls"]:
                         if (vid.endswith(".flv")):
                             video_url = vid
                             break
                     url = video_url
                     # set the default icon
                     icon = "DefaultVideo.png"
                     # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
                     listitem = xbmcgui.ListItem(
                         label=video["title"],
                         iconImage=icon,
                         thumbnailImage=video["thumbnail"])
                     # add the different infolabels we want to sort by
                     listitem.setInfo(type="Video",
                                      infoLabels={
                                          "Title": video["title"],
                                          "Director": video["username"],
                                          "Duration": runtime,
                                          "Plot": plot,
                                          "PlotOutline": plot,
                                          "Rating": rating,
                                          "Genre": genre,
                                          "Date": date
                                      })
                     # add the video to the media list
                     ok = xbmcplugin.addDirectoryItem(
                         handle=int(sys.argv[1]),
                         url=url,
                         listitem=listitem,
                         isFolder=False,
                         totalItems=total_items)
                     # if user cancels, call raise to exit loop
                     if (not ok): raise
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % (
             self.__class__.__name__,
             sys.exc_info()[2].tb_frame.f_code.co_name,
             sys.exc_info()[2].tb_lineno,
             sys.exc_info()[1],
         )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if (ok):
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_LABEL)
         xbmcplugin.addSortMethod(
             handle=int(sys.argv[1]),
             sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RATING)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_DATE)
         xbmcplugin.addSortMethod(
             handle=int(sys.argv[1]),
             sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_GENRE)
         # set content
         xbmcplugin.setContent(handle=int(sys.argv[1]), content="movies")
         # set our plugin category
         xbmcplugin.setPluginCategory(handle=int(sys.argv[1]),
                                      category=self.args.title)
         # if skin has fanart image use it
         fanart_image = os.path.join(sys.modules["__main__"].__plugin__,
                                     self.args.category + "-fanart.png")
         if (xbmc.skinHasImage(fanart_image)):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=fanart_image)
         # set our fanart from user setting
         elif (self.settings["fanart_image"]):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=self.settings["fanart_image"])
     return ok, total_items
Exemplo n.º 26
0
def _get_image(image):
    return image if xbmc.skinHasImage(image) else plugin.icon
Exemplo n.º 27
0
 def _fill_media_list( self, ok, videos, page, pages=1, perpage=1, total=1, encoding="utf-8", spell_vq="" ):
     try:
         # calculate total items including previous, next and spelling folders
         total_items = len( videos ) + ( page < pages ) + ( page > 1 ) + ( spell_vq != "" and len( videos ) )
         # if ok (always is for now) fill directory
         if ( ok ):
             # if this was a search and there is a correction
             if ( spell_vq ):
                 # set the correct query
                 cat = ( "", spell_vq, )[ self.args.issearch == 3 ]
                 username = ( "", spell_vq, )[ self.args.issearch == 2 ]
                 vq = ( "", spell_vq, )[ self.args.issearch == 1 ]
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&related=%s&issearch=%d&update_listing=%d' % ( sys.argv[ 0 ], quote_plus( repr( self.args.title ) ), repr( "videos" ), 1, quote_plus( repr( vq ) ), quote_plus( repr( username ) ), quote_plus( repr( cat ) ), repr( self.args.orderby ), repr( self.args.related ), self.args.issearch, True, )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the next pictures
                 thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, "spell_page.png" )
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem=xbmcgui.ListItem( label="%s: %s" % ( xbmc.getLocalizedString( 30911 ), spell_vq, ), iconImage=icon, thumbnailImage=thumbnail )
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=total_items + ( len( videos ) == 0 ) )
             # if there is more than one page and we are not on the last page, we add our next page folder
             if ( page < pages ):
                 # calculate the starting video
                 startno = page * perpage + 1
                 # calculate the ending video
                 endno = startno + perpage - 1
                 # if there are fewer videos than per_page set endno to total
                 if ( endno > total ):
                     endno = total
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&issearch=0&related=%s&update_listing=%d' % ( sys.argv[ 0 ], quote_plus( repr( self.args.title ) ), repr( self.args.category ), page + 1, quote_plus( repr( self.args.vq ) ), quote_plus( repr( self.args.username ) ), quote_plus( repr( self.args.cat ) ), repr( self.args.orderby ), repr( self.args.related ), True, )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the next pictures
                 thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, "next.png" )
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem=xbmcgui.ListItem( label="%s (%d-%d)" % ( xbmc.getLocalizedString( 3 ), startno, endno, ), iconImage=icon, thumbnailImage=thumbnail )
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=total_items )
             # if we are on page 2 or more, we add our previous page folder
             if ( page > 1 ):
                 # calculate the starting video
                 startno = ( page - 2 ) * perpage + 1
                 # calculate the ending video
                 endno = startno + perpage - 1
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&related=%s&issearch=0&update_listing=%d' % ( sys.argv[ 0 ], quote_plus( repr( self.args.title ) ), repr( self.args.category ), page - 1, quote_plus( repr( self.args.vq ) ), quote_plus( repr( self.args.username ) ), quote_plus( repr( self.args.cat ) ), repr( self.args.orderby ), repr( self.args.related ), True, )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the previous pictures
                 thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, "previous.png" )
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem=xbmcgui.ListItem( label="%s (%d-%d)" % ( xbmc.getLocalizedString( 3 ), startno, endno, ), iconImage=icon, thumbnailImage=thumbnail )
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=total_items )
             # set our thumbnail for queries
             self.query_thumbnail = videos[ 0 ][ "media$group" ][ "media$thumbnail" ][ -1 ][ "url" ]
             # enumerate through the list of pictures and add the item to the media list
             for video in videos:
                 # only add videos with an embeddable video
                 if ( video[ "media$group" ].has_key( "media$player" ) ):
                     # create the title, we use video title and author (exec is a hack for unescaping \u#### characters)
                     exec 'title = u"%s"' % ( unicode( video[ "title" ][ "$t" ].replace( '"', '\\"' ), encoding, "replace" ), )
                     # set the director with author (exec is a hack for unescaping \u#### characters)
                     exec 'director = u"%s"' % ( unicode( video[ "author" ][ 0 ][ "name" ][ "$t" ].replace( '"', '\\"' ), encoding, "replace" ), )
                     # thumbnail url
                     thumbnail_url = video[ "media$group" ][ "media$thumbnail" ][ -1 ][ "url" ]
                     # plot
                     try:
                         # we need to replace \n and \r as it messes up our exec hack (exec is a hack for unescaping \u#### characters)
                         exec 'plot = u"%s"' % ( unicode( video[ "media$group" ][ "media$description" ][ "$t" ].replace( '"', '\\"' ).replace( "\n", "\\n" ).replace( "\r", "\\r" ), encoding, "replace" ), )
                     except:
                         plot = xbmc.getLocalizedString( 30904 )    
                     # format runtime as 00:00
                     runtime = int( video[ "media$group" ][ "yt$duration" ][ "seconds" ] )
                     # video runtime
                     if ( runtime ):
                         runtime = "%02d:%02d" % ( int( runtime / 60 ), runtime % 60, )
                     else:
                         runtime = ""
                     # viewer rating
                     try:
                         rating = float( video[ "gd$rating" ][ "average" ] )
                     except:
                         rating = 0.0
                     # times viewed
                     try:
                         count = int( video[ "yt$statistics" ][ "viewCount" ] )
                     except:
                         count = 0
                     # genre
                     genre = video[ "media$group" ][ "media$category" ][ 0 ][ "$t" ]
                     # updated date
                     date = "%s-%s-%s" % ( video[ "updated" ][ "$t" ][ 8 : 10 ], video[ "updated" ][ "$t" ][ 5 : 7 ], video[ "updated" ][ "$t" ][ : 4 ], )
                     # video url
                     exec 'video_url = u"%s"' % ( unicode( video[ "media$group" ][ "media$player" ][ 0 ][ "url" ], encoding ), )
                     # construct our url
                     url = "%s?category='play_video'&video_url=%s&releated=%s&update_listing=%d" % ( sys.argv[ 0 ], quote_plus( repr( video_url ) ), repr( video[ "id" ][ "$t" ].split( "/" )[ -1 ] ), False, )
                     # set the default icon
                     icon = "DefaultVideo.png"
                     # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
                     listitem=xbmcgui.ListItem( label=title, iconImage=icon, thumbnailImage=thumbnail_url )
                     # add the different infolabels we want to sort by
                     listitem.setInfo( type="Video", infoLabels={ "Title": title, "Director": director, "Duration": runtime, "Plot": plot, "Rating": rating, "Genre": genre, "Count": count, "Date": date } )
                     # set isplayable property
                     listitem.setProperty( "IsPlayable", "true" )
                     # set context menu items
                     cm = []
                     # add queue video
                     cm += [ ( xbmc.getLocalizedString( 30504 ), "XBMC.Action(Queue)", ) ]
                     # add related videos
                     cm += [ ( xbmc.getLocalizedString( 30500 ), "Container.Update(%s?title=%s&category='related'&page=1&vq=''&username=''&cat=''&orderby='relevance'&related=%s&issearch=False&update_listing=False)" % ( sys.argv[ 0 ], repr( xbmc.getLocalizedString( 30968 ) ), repr( video[ "id" ][ "$t" ].split( "/" )[ -1 ] ), ), ) ]
                     # add author videos
                     cm += [ ( xbmc.getLocalizedString( 30507 ) % ( director, ), "Container.Update(%s?title=%s&category='users__uploads'&page=1&vq=''&username=%s&cat=''&orderby='relevance'&related=''&issearch=False&update_listing=False)" % ( sys.argv[ 0 ], quote_plus( repr( director ) ), quote_plus( repr( director ) ), ), ) ]
                     # if download path set, add download item
                     if ( self.settings[ "download_path" ] != "" ):
                         cm += [ ( xbmc.getLocalizedString( 30501 ), "XBMC.RunPlugin(%s?category='download_video'&video_url=%s)" % ( sys.argv[ 0 ], quote_plus( repr( video_url ) ), ), ) ]
                     # add movie info
                     cm += [ ( xbmc.getLocalizedString( 30502 ), "XBMC.Action(Info)", ) ]
                     # add to favourites
                     if ( self.args.category != "my_favorites" and self.authkey ):
                         cm += [ ( xbmc.getLocalizedString( 30503 ), "XBMC.RunPlugin(%s?category='add__favorite'&video_id=%s&update_listing=False)" % ( sys.argv[ 0 ], repr( video[ "id" ][ "$t" ].split( "/" )[ -1 ] ), ) ) ]
                     else:
                         # find the edit url
                         for link in video["link"]:
                             # this is the edit url, so set the context menu item
                             if ( link["rel"] == "edit" ):
                                 # set url using this hack to clean the result (exec is a hack for unescaping \u#### characters)
                                 exec 'edit_url = u"%s"' % ( unicode( link[ "href" ], encoding ), )
                                 # add context menu item
                                 cm += [ ( xbmc.getLocalizedString( 30506 ), "XBMC.RunPlugin(%s?category='delete__favorite'&edit_url=%s&update_listing=False)" % ( sys.argv[ 0 ], quote_plus( repr( edit_url ) ), ), ) ]
                     # add now playing
                     cm += [ ( xbmc.getLocalizedString( 30505 ), "XBMC.ActivateWindow(10028)", ) ]
                     # add context menu items
                     listitem.addContextMenuItems( cm, replaceItems=True )
                     # add the video to the media list
                     ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=False, totalItems=total_items )
                     # if user cancels, call raise to exit loop
                     if ( not ok ): raise
             if ( spell_vq ):
                 self.args.username = ( "", spell_vq, )[ self.args.issearch == 2 ]
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if ( ok ):
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RATING )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_PROGRAM_COUNT )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_GENRE )
         # set content
         xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="movies" )
         # set our plugin category
         xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=self.args.title )
         # if skin has fanart image use it
         fanart_image = os.path.join( sys.modules[ "__main__" ].__plugin__, self.args.category + "-fanart.png" )
         if ( xbmc.skinHasImage( fanart_image ) ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=fanart_image )
         # set our fanart from user setting
         elif ( self.settings[ "fanart_image" ] ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=self.settings[ "fanart_image" ] )
     return ok, total_items
Exemplo n.º 28
0
 def _fill_media_list( self, ok, videos ):
     try:
         # calculate total items
         total_items = len( videos )
         # if ok (always is for now) fill directory
         if ( ok ):
             # set our thumbnail for queries
             self.query_thumbnail = videos[ 0 ][ "thumbnail" ]
             # enumerate through the list of pictures and add the item to the media list
             for c, video in enumerate( videos ):
                 # only add videos with a valid video url
                 if ( len( video[ "video_urls" ] ) ):
                     # plot
                     plot = xbmc.getLocalizedString( 30904 )
                     if ( video[ "desc" ] ):
                         plot = video[ "desc" ]
                         plot = self._clean_text( plot.strip() )
                     # format runtime as 00:00
                     run = int( video[ "runtime" ] )
                     runtime = ""
                     # video runtime
                     if ( run ):
                         runtime = "%02d:%02d" % ( int( run / 60 ), run % 60, )
                     # viewer rating
                     try:
                         rating = float( video[ "rating" ] )
                     except:
                         rating = 0.0
                     # genre
                     genre = video[ "genre" ]
                     # updated date
                     #<pubDate>Wed, 16 Apr 2008 18:00:30 +0000</pubDate>
                     mm = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ].index(video[ "date" ][ 8 : 11 ] )
                     date = "%02d-%02d-%04d" % ( int( video[ "date" ][ 5 : 7 ] ), mm + 1, int( video[ "date" ][ 12 : 16 ] ), )                            
                     # construct our url
                     video_url = video[ "video_urls" ][ 0 ]
                     for vid in video[ "video_urls" ]:
                         if ( vid.endswith( ".flv" ) ):
                             video_url = vid
                             break
                     url = video_url
                     # set the default icon
                     icon = "DefaultVideo.png"
                     # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
                     listitem=xbmcgui.ListItem( label=video[ "title" ], iconImage=icon, thumbnailImage=video[ "thumbnail" ] )
                     # add the different infolabels we want to sort by
                     listitem.setInfo( type="Video", infoLabels={ "Title": video[ "title" ], "Director": video[ "username" ], "Duration": runtime, "Plot": plot, "PlotOutline": plot, "Rating": rating, "Genre": genre, "Date": date } )
                     # add the video to the media list
                     ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=False, totalItems=total_items )
                     # if user cancels, call raise to exit loop
                     if ( not ok ): raise
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if ( ok ):
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RATING )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_GENRE )
         # set content
         xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="movies" )
         # set our plugin category
         xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=self.args.title )
         # if skin has fanart image use it
         fanart_image = os.path.join( sys.modules[ "__main__" ].__plugin__, self.args.category + "-fanart.png" )
         if ( xbmc.skinHasImage( fanart_image ) ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=fanart_image )
         # set our fanart from user setting
         elif ( self.settings[ "fanart_image" ] ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=self.settings[ "fanart_image" ] )
     return ok, total_items
def get_image(image, alt_image=None):
    if not alt_image:
        alt_image = treetv
    return image if skinHasImage(image) else alt_image
Exemplo n.º 30
0
def has(filename):
    return True if xbmc.skinHasImage(filename) else False
Exemplo n.º 31
0
def _openimage(image, targetpath, filename):
    if not PYTHON3:
        image = image.encode('utf-8')

    image = url_unquote(image.replace('image://', ''))
    if image.endswith('/'):
        image = image[:-1]

    cached_files = list()
    cachedthumb = xbmc.getCacheThumbName(image)
    cached_files.append(
        os.path.join('special://profile/Thumbnails/', cachedthumb[0],
                     cachedthumb[:-4] + '.jpg'))
    cached_files.append(
        os.path.join('special://profile/Thumbnails/', cachedthumb[0],
                     cachedthumb[:-4] + '.png'))
    cached_files.append(
        os.path.join('special://profile/Thumbnails/Video/', cachedthumb[0],
                     cachedthumb))

    for i in range(1, 4):
        try:
            ''' Try to get cached image at first
            '''
            for cache in cached_files:
                if xbmcvfs.exists(cache):
                    try:
                        img = Image.open(xbmc.translatePath(cache))
                        return img
                    except Exception as error:
                        log(
                            'Image error: Could not open cached image --> %s' %
                            error, WARNING)
                        pass
            ''' Skin images will be tried to be accessed directly. For all other ones
                the source will be copied to the addon_data folder to get access.
            '''
            if xbmc.skinHasImage(image):
                if not image.startswith('special://skin'):
                    image = os.path.join('special://skin/media/', image)

                try:  # in case image is packed in textures.xbt
                    img = Image.open(xbmc.translatePath(image))
                    return img
                except Exception:
                    return ''

            else:
                targetfile = os.path.join(targetpath, filename)
                if not xbmcvfs.exists(targetfile):
                    xbmcvfs.copy(image, targetfile)

                img = Image.open(targetfile)
                return img

        except Exception as error:
            log(
                'Image error: Could not get image for %s (try %d) -> %s' %
                (image, i, error), ERROR)
            xbmc.sleep(500)
            pass

    return ''
Exemplo n.º 32
0
    def showUpdates(self):
        log("> showUpdates()")
        ok = False

        # create update_all file that contains all listitem details
        deleteFile(self.UPDATE_ALL_FILENAME)
        updateAllItems = []

        # create display list
        sz = len(self.INSTALLED)
        log("showing INSTALLED count=%s" % sz)
        for info in self.INSTALLED:
            try:
                log("info: %s" % info)
                svn_url = info.get('svn_url', '')
                svn_ver = info.get('svn_ver', '')

                # ignore those not in SVN as per settings
                if (not svn_url or not svn_ver) and not self.showNoSVN:
                    log("ignored, as not in svn, showNoSVN: off")
                    continue

                # get addon details
                path = ""
                filepath = info.get('filepath', '')
                ver = info.get('version', '')
                svn_xbmc_rev = info.get('XBMC_Revision', 0)
                readme = info.get('readme', '')
                category = info.get('category', '')
                repo = info.get('repo', 'SVN ?')
                labelColour = "FFFFFFFF"

                # add ContextMenu: Delete (unless already deleted status)
                if "SVN Repo Installer" not in category:
                    cm = self._contextMenuItem(30022, {
                        "delete": filepath,
                        "title": category
                    })  # 'Delete'
                else:
                    cm = []

                # make update state according to found information
                if ".backups" in filepath:
                    verState = xbmc.getLocalizedString(30018)  # Deleted
                    labelColour = "66FFFFFF"
                elif not svn_url:
                    verState = xbmc.getLocalizedString(30012)  # not in SVN
                elif not svn_ver:
                    verState = xbmc.getLocalizedString(
                        30013)  # unknown version
                elif ver >= svn_ver:
                    verState = xbmc.getLocalizedString(30011)  # OK
                    url_args = "show_info=%s" % urllib.quote_plus(
                        repr(filepath))
                    path = '%s?%s' % (
                        sys.argv[0],
                        url_args,
                    )
                elif (svn_xbmc_rev and self.XBMC_REVISION and self.XBMC_REVISION >= svn_xbmc_rev) or \
                 (not svn_xbmc_rev or not self.XBMC_REVISION):
                    # Compatible, NEW AVAILABLE - setup callback url for plugin SVN Repo Installer
                    # assume compatible if no svn xbmc_revision found.
                    verState = "v%s (%s)" % (
                        svn_ver, xbmc.getLocalizedString(30014)
                    )  # eg. !New! v1.1
                    trunk_url = re.search('(/(?:trunk|branch|tag).*?)$',
                                          svn_url, re.IGNORECASE).group(1)
                    #['plugin://programs/SVN Repo Installer/', '-1', '?download_url="%2Ftrunk%2Fplugins%2Fmusic/iTunes%2F"&repo=\'xbmc-addons\'&install=""&ioffset=2&voffset=0']
                    info['download_url'] = "download_url=%s&repo=%s&install=%s&ioffset=%s&voffset=%s" % \
                       (repr(urllib.quote_plus(trunk_url + "/")),
                       repr(urllib.quote_plus(repo)),
                       repr(info["install"]),
                       info["ioffset"],
                       info["voffset"],)

                    url_args = "show_info=%s" % urllib.quote_plus(
                        repr(filepath))

                    # exclude self update from "update all"
                    if "SVN Repo Installer" not in category:
                        updateAllItems.append("?" + info['download_url'])
                    path = '%s?%s' % (
                        sys.argv[0],
                        url_args,
                    )
                else:
                    verState = "v%s (%s)" % (
                        svn_ver,
                        xbmc.getLocalizedString(30015),
                    )  # eg. Incompatible

                if not path:
                    path = os.path.join(filepath, 'default.tbn')
                if not svn_ver:
                    svn_ver = '?'
                if not ver:
                    ver = '?'

                # Addon status text as label2
                text = "[COLOR=%s][%s] %s (v%s)[/COLOR]" % (labelColour, repo,
                                                            category, ver)
                label2 = makeLabel2(verState)

                # determine default icon according to addon type
                icon = ""
                if find(filepath, 'scripts') != -1:
                    icon = "DefaultScriptBig.png"
                elif find(filepath, 'programs') != -1:
                    icon = "DefaultProgramBig.png"
                elif find(filepath, 'music') != -1:
                    icon = "defaultAudioBig.png"
                elif find(filepath, 'pictures') != -1:
                    icon = "defaultPictureBig.png"
                elif find(filepath, 'video') != -1:
                    icon = "defaultVideoBig.png"
                # check skin for image, else fallback DefaultFile
                if not icon or not xbmc.skinHasImage(icon):
                    icon = "DefaultFile.png"

                # assign thumb, in order from: local, svn, icon
                thumb = info.get('thumb', '')
                if not thumb:
                    thumb = icon

                li = xbmcgui.ListItem(text, label2, icon, thumb)
                li.setInfo(type="Video",
                           infoLabels={
                               "Title": text,
                               "Genre": label2
                           })

                # add ContextMenu: Changelog
                cm += self._contextMenuItem(
                    30600, {
                        "showlog": True,
                        "repo": repo,
                        "category": category.split("/")[-1],
                        "revision": None,
                        "parse": True
                    })  # view readme
                # add ContextMenu: Readme
                if readme:
                    cm += self._contextMenuItem(30610, {
                        "showreadme": True,
                        "repo": None,
                        "readme": readme
                    })

                li.addContextMenuItems(cm, replaceItems=True)
                ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                 url=path,
                                                 listitem=li,
                                                 isFolder=False,
                                                 totalItems=sz)
                if (not ok): break
            except:
                # user cancelled dialog or an error occurred
                logError()
                print info

        # if New Updates; add Update All item
        log("Updated Count=%d" % len(updateAllItems))
        if updateAllItems:
            icon = "DefaultFile.png"
            text = xbmc.getLocalizedString(30019)
            li = xbmcgui.ListItem(text, "", icon, icon)
            li.setInfo(type="Video", infoLabels={"Title": text, "Genre": ""})
            path = '%s?download_url=update_all' % (sys.argv[0], )
            xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                        url=path,
                                        listitem=li,
                                        isFolder=False,
                                        totalItems=sz)
            # save update_all dict to file
            saveFileObj(self.UPDATE_ALL_FILENAME, updateAllItems)

        # add list sort methods
        xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                 sortMethod=xbmcplugin.SORT_METHOD_GENRE)
        #            xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="files")
        ok = True

        log("< showUpdates() ok=%s" % ok)
        return ok
Exemplo n.º 33
0
 def _get_thumbnail( self, title ):
     # create the full thumbnail path for skins directory
     thumbnail = os.path.join( sys.modules[ "__main__" ].__plugin__, title + ".png" )
     # use a plugin custom thumbnail if a custom skin thumbnail does not exists
     if ( not xbmc.skinHasImage( thumbnail ) ):
Exemplo n.º 34
0
 def _fill_media_list( self, items, page, pages=1, perpage=1, total=1, encoding="UTF-8", kind="photo", access="" ):
     try:
         # calculate total items including previous and next
         total_items = len( items ) + ( page < pages ) + ( page > 1 )
         # if there is more than one page and we are not on the last page, we add our next page folder
         if ( page < pages ):
             # calculate the starting video
             startno = page * perpage + 1
             # calculate the ending video
             endno = startno + perpage - 1
             # if there are fewer items than per_page set endno to total
             if ( endno > total ):
                 endno = total
             # create the callback url
             url = '%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s' % ( sys.argv[ 0 ], quote_plus( repr( self.args.title ) ), repr( self.args.category ), repr( access ), repr( kind ), page + 1, quote_plus( repr( self.args.pq ) ), True, repr( self.args.user_id ), repr( self.args.album_id ), repr( self.args.photo_id ), )
             # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
             # we set the thumb so XBMC does not try and cache the next pictures
             thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, "next.png" )
             # set the default icon
             icon = "DefaultFolder.png"
             # set stringid
             stringid = 30908 + ( kind == "album" )
             # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
             listitem=xbmcgui.ListItem( label="%s (%d-%d)" % ( xbmc.getLocalizedString( stringid ), startno, endno, ), iconImage=icon, thumbnailImage=thumbnail )
             # add the folder item to our media list
             ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=total_items )
         # if we are on page 2 or more, we add our previous page folder
         if ( page > 1 ):
             # calculate the starting video
             startno = ( page - 2 ) * perpage + 1
             # calculate the ending video
             endno = startno + perpage - 1
             # create the callback url
             url = '%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s' % ( sys.argv[ 0 ], quote_plus( repr( self.args.title ) ), repr( self.args.category ), repr( access ), repr( kind ), page - 1, quote_plus( repr( self.args.pq ) ), True, repr( self.args.user_id ), repr( self.args.album_id ), repr( self.args.photo_id ), )
             # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
             # we set the thumb so XBMC does not try and cache the previous pictures
             thumbnail = os.path.join( self.BASE_PLUGIN_THUMBNAIL_PATH, "previous.png" )
             # set the default icon
             icon = "DefaultFolder.png"
             # set stringid
             stringid = 30908 + ( kind == "album" )
             # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
             listitem=xbmcgui.ListItem( label="%s (%d-%d)" % ( xbmc.getLocalizedString( stringid ), startno, endno, ), iconImage=icon, thumbnailImage=thumbnail )
             # add the folder item to our media list
             ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=total_items )
         # set our thumbnail for queries
         if ( self.user_icon ):
             self.query_thumbnail = self.user_icon
         else:
             self.query_thumbnail = items[ 0 ][ "thumb_url" ]
         # enumerate through the list of pictures and add the item to the media list
         for c, item in enumerate( items ):
             # construct our url
             if ( item[ "photo_url" ] ):
                 # we are a photo, so set it's url to the full image
                 url = item[ "photo_url" ]
                 # we are not a folder
                 isfolder = False
                 # set the default icon
                 icon = "DefaultPicture.png"
             else:
                 # we need to reset page and kind for albums that contain photos
                 if ( item[ "album_id" ] and kind == "album" ):
                     # we switch to photos since that's what an album holds
                     kind = "photo"
                     # set page to #1
                     page = 1
                     # set our category to photos
                     self.args.category = "photos"
                 url = "%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s" % ( sys.argv[ 0 ], quote_plus( repr( item[ "title" ] ) ), repr( self.args.category ), repr( access ), repr( kind ), page, repr( "" ), False, repr( item[ "user_id" ] ), repr( item[ "album_id" ] ), repr( item[ "photo_id" ] ), )
                 # no photo_url, must be an album
                 isfolder = True
                 # set the default icon
                 icon = "DefaultFolder.png"
             # we add total items if this is an album, we add author if it is a photo
             if ( item[ "photo_url" ] ):
                 title = item[ "title" ]
             else:
                 title = "%s (%d)" % ( item[ "title" ], item[ "numphotos" ], )
             # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
             listitem=xbmcgui.ListItem( label=title, iconImage=icon, thumbnailImage=item[ "thumb_url" ] )
             # add the different infolabels we want to sort by
             listitem.setInfo( type="Pictures", infoLabels={ "Title": title } )
             # we add additional properties and infolabels for photos
             if ( item[ "photo_url" ] ):
                 listitem.setInfo( type="Pictures", infoLabels={ "Date": "%s-%s-%s" % ( item[ "photo_datetime" ][ 8 : 10 ], item[ "photo_datetime" ][ 5 : 7 ], item[ "photo_datetime" ][  : 4 ], ), "Size": item[ "photo_size" ], "exif:exiftime": item[ "photo_datetime" ], "exif:resolution": "%d,%d" % ( item[ "photo_width" ], item[ "photo_height" ], ) } )
                 # skins display these with ListItem.Property(User)...
                 listitem.setProperty( "User", item[ "author" ] )
                 listitem.setProperty( "Description", item[ "summary" ] )
                 listitem.setProperty( "DateTaken", item[ "photo_datetime" ] )
             # add the video to the media list
             ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=isfolder, totalItems=total_items )
             # if user cancels, call raise to exit loop
             if ( not ok ): raise
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if ( ok ):
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_SIZE )
         xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE )
         # set content
         xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="pictures" )
         # set our plugin category
         xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=self.args.title )
         # if skin has fanart image use it
         fanart_image = os.path.join( sys.modules[ "__main__" ].__plugin__, self.args.category + "-fanart.png" )
         if ( xbmc.skinHasImage( fanart_image ) ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=fanart_image )
         # set our fanart from user setting
         elif ( self.settings[ "fanart_image" ] ):
             xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=self.settings[ "fanart_image" ] )
     return ok, total_items
Exemplo n.º 35
0
 def _fill_media_list(self, items):
     try:
         ok = True
         # enumerate through the list of items and add the item to the media list
         for item in items:
             # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
             listitem = xbmcgui.ListItem(label=item.title,
                                         iconImage=item.icon,
                                         thumbnailImage=item.thumbnail_url)
             # TODO: add info and sort methods
             # add the different infolabels we want to sort by
             listitem.setInfo(
                 type="Pictures", infoLabels={"Title": item.title}
             )  #, "Genre": self.args.title, "Duration": video.duration, "Date": video.date } )
             # we add additional properties and infolabels for pictures
             if (not item.isFolder):
                 listitem.setInfo(
                     type="Pictures",
                     infoLabels={
                         "Date":
                         "%s-%s-%s" % (
                             item.datetaken[8:10],
                             item.datetaken[5:7],
                             item.datetaken[:4],
                         ),
                     }
                 )  #"Size": item[ "photo_size" ], "exif:exiftime": item[ "photo_datetime" ], "exif:resolution": "%d,%d" % ( item[ "photo_width" ], item[ "photo_height" ], ) } )
                 # skins display these with ListItem.Property(User)...
                 listitem.setProperty("User", item.author)
                 listitem.setProperty("Description", item.description)
                 listitem.setProperty("DateTaken", item.datetaken)
             # add the item to the media list
             ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                              url=item.url,
                                              listitem=listitem,
                                              isFolder=item.isFolder,
                                              totalItems=len(items))
             # if user cancels, call raise to exit loop
             if (not ok): raise
     except:
         # user cancelled dialog or an error occurred
         print "ERROR: %s::%s (%d) - %s" % (
             self.__class__.__name__,
             sys.exc_info()[2].tb_frame.f_code.co_name,
             sys.exc_info()[2].tb_lineno,
             sys.exc_info()[1],
         )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if (ok):
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_LABEL)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_DATE)
         # set our plugin category
         xbmcplugin.setPluginCategory(handle=int(sys.argv[1]),
                                      category=self.args.title)
         # if skin has fanart image use it
         fanart_image = os.path.join(sys.modules["__main__"].__plugin__,
                                     self.args.category + "-fanart.png")
         if (xbmc.skinHasImage(fanart_image)):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=fanart_image)
         # set our fanart from user setting
         elif (self.settings["fanart_image"]):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=self.settings["fanart_image"])
     return ok, len(items)
 def get_image(self, image):
     return image if xbmc.skinHasImage(image) else self.icon
Exemplo n.º 37
0
	def showUpdates(self):
		log("> showUpdates()")
		ok = False

		# create update_all file that contains all listitem details
		deleteFile(self.UPDATE_ALL_FILENAME)
		updateAllItems = []

		# create display list
		sz = len(self.INSTALLED)
		log("showing INSTALLED count=%s" % sz)
		for info in self.INSTALLED:
			try:
				log("info: %s" % info)
				svn_url = info.get('svn_url','')
				svn_ver = info.get('svn_ver','')

				# ignore those not in SVN as per settings
				if (not svn_url or not svn_ver) and not self.showNoSVN:
					log("ignored, as not in svn, showNoSVN: off")
					continue

				# get addon details
				path = ""
				filepath = info.get('filepath', '')
				ver = info.get('version', '')
				svn_xbmc_rev = info.get('XBMC_Revision',0)
				readme = info.get('readme','')
				category = info.get('category','')
				repo = info.get('repo','SVN ?')
				labelColour = "FFFFFFFF"

				# add ContextMenu: Delete (unless already deleted status)
				if "SVN Repo Installer" not in category:
					cm =  self._contextMenuItem( 30022, { "delete": filepath, "title": category } )	# 'Delete'
				else:
					cm = []

				# make update state according to found information
				if ".backups" in filepath:
					verState = xbmc.getLocalizedString( 30018 )				# Deleted
					labelColour = "66FFFFFF"
				elif not svn_url:
					verState = xbmc.getLocalizedString( 30012 )             # not in SVN
				elif not svn_ver:
					verState = xbmc.getLocalizedString( 30013 )				# unknown version
				elif ver >= svn_ver:
					verState = xbmc.getLocalizedString( 30011 )				# OK
					url_args = "show_info=%s" % urllib.quote_plus( repr(filepath) )
					path = '%s?%s' % ( sys.argv[ 0 ], url_args, )
				elif (svn_xbmc_rev and self.XBMC_REVISION and self.XBMC_REVISION >= svn_xbmc_rev) or \
					(not svn_xbmc_rev or not self.XBMC_REVISION):
					# Compatible, NEW AVAILABLE - setup callback url for plugin SVN Repo Installer
					# assume compatible if no svn xbmc_revision found.
					verState = "v%s (%s)" % ( svn_ver, xbmc.getLocalizedString( 30014 ) )        # eg. !New! v1.1
					trunk_url = re.search('(/(?:trunk|branch|tag).*?)$', svn_url, re.IGNORECASE).group(1)
#['plugin://programs/SVN Repo Installer/', '-1', '?download_url="%2Ftrunk%2Fplugins%2Fmusic/iTunes%2F"&repo=\'xbmc-addons\'&install=""&ioffset=2&voffset=0']
					info['download_url'] = "download_url=%s&repo=%s&install=%s&ioffset=%s&voffset=%s" % \
								(repr(urllib.quote_plus(trunk_url + "/")),
								repr(urllib.quote_plus(repo)),
								repr(info["install"]),
								info["ioffset"],
								info["voffset"],)

					url_args = "show_info=%s" % urllib.quote_plus( repr(filepath) )

					# exclude self update from "update all"
					if "SVN Repo Installer" not in category:
						updateAllItems.append("?" + info['download_url'])
					path = '%s?%s' % ( sys.argv[ 0 ], url_args, )
				else:
					verState = "v%s (%s)" % ( svn_ver, xbmc.getLocalizedString( 30015 ), )	# eg. Incompatible

				if not path:
					path = os.path.join(filepath, 'default.tbn')
				if not svn_ver:
					svn_ver = '?'
				if not ver:
					ver = '?'

				# Addon status text as label2
				text = "[COLOR=%s][%s] %s (v%s)[/COLOR]" % (labelColour, repo, category, ver)
				label2 = makeLabel2( verState )

				# determine default icon according to addon type
				icon = ""
				if find(filepath,'scripts') != -1:
					icon = "DefaultScriptBig.png"
				elif find(filepath,'programs') != -1:
					icon = "DefaultProgramBig.png"
				elif find(filepath,'music') != -1:
					icon = "defaultAudioBig.png"
				elif find(filepath,'pictures') != -1:
					icon = "defaultPictureBig.png"
				elif find(filepath,'video') != -1:
					icon = "defaultVideoBig.png"
				# check skin for image, else fallback DefaultFile
				if not icon or not xbmc.skinHasImage(icon):
					icon = "DefaultFile.png"

				# assign thumb, in order from: local, svn, icon
				thumb = info.get('thumb','')
				if not thumb:
					thumb = icon

				li=xbmcgui.ListItem( text, label2, icon, thumb)
				li.setInfo( type="Video", infoLabels={ "Title": text, "Genre": label2 } )

				# add ContextMenu: Changelog
				cm +=  self._contextMenuItem( 30600, { "showlog": True, "repo": repo, "category": category.split( "/" )[ -1 ], "revision": None, "parse": True } )		# view readme
				# add ContextMenu: Readme
				if readme:
					cm +=  self._contextMenuItem( 30610, { "showreadme": True, "repo": None, "readme": readme } )

				li.addContextMenuItems( cm, replaceItems=True )
				ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=path, listitem=li, isFolder=False, totalItems=sz )
				if ( not ok ): break
			except:
				# user cancelled dialog or an error occurred
				logError()
				print info

		# if New Updates; add Update All item
		log("Updated Count=%d" % len(updateAllItems))
		if updateAllItems:
			icon = "DefaultFile.png"
			text = xbmc.getLocalizedString( 30019 )
			li=xbmcgui.ListItem( text, "", icon, icon)
			li.setInfo( type="Video", infoLabels={ "Title": text, "Genre": "" } )
			path = '%s?download_url=update_all' % ( sys.argv[ 0 ], )
			xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=path, listitem=li, isFolder=False, totalItems=sz )
			# save update_all dict to file
			saveFileObj(self.UPDATE_ALL_FILENAME, updateAllItems)

		# add list sort methods
		xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_GENRE )
#            xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="files")
		ok = True

		log("< showUpdates() ok=%s" % ok)
		return ok
Exemplo n.º 38
0
 def _fill_media_list(self,
                      ok,
                      videos,
                      page,
                      pages=1,
                      perpage=1,
                      total=1,
                      encoding="utf-8",
                      spell_vq=""):
     try:
         # calculate total items including previous, next and spelling folders
         total_items = len(videos) + (page < pages) + (page > 1) + (
             spell_vq != "" and len(videos))
         # if ok (always is for now) fill directory
         if (ok):
             # if this was a search and there is a correction
             if (spell_vq):
                 # set the correct query
                 cat = (
                     "",
                     spell_vq,
                 )[self.args.issearch == 3]
                 username = (
                     "",
                     spell_vq,
                 )[self.args.issearch == 2]
                 vq = (
                     "",
                     spell_vq,
                 )[self.args.issearch == 1]
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&related=%s&issearch=%d&update_listing=%d' % (
                     sys.argv[0],
                     quote_plus(repr(self.args.title)),
                     repr("videos"),
                     1,
                     quote_plus(repr(vq)),
                     quote_plus(repr(username)),
                     quote_plus(repr(cat)),
                     repr(self.args.orderby),
                     repr(self.args.related),
                     self.args.issearch,
                     True,
                 )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the next pictures
                 thumbnail = os.path.join(self.BASE_PLUGIN_THUMBNAIL_PATH,
                                          "spell_page.png")
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem = xbmcgui.ListItem(label="%s: %s" % (
                     xbmc.getLocalizedString(30911),
                     spell_vq,
                 ),
                                             iconImage=icon,
                                             thumbnailImage=thumbnail)
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                  url=url,
                                                  listitem=listitem,
                                                  isFolder=True,
                                                  totalItems=total_items +
                                                  (len(videos) == 0))
             # if there is more than one page and we are not on the last page, we add our next page folder
             if (page < pages):
                 # calculate the starting video
                 startno = page * perpage + 1
                 # calculate the ending video
                 endno = startno + perpage - 1
                 # if there are fewer videos than per_page set endno to total
                 if (endno > total):
                     endno = total
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&issearch=0&related=%s&update_listing=%d' % (
                     sys.argv[0],
                     quote_plus(repr(self.args.title)),
                     repr(self.args.category),
                     page + 1,
                     quote_plus(repr(self.args.vq)),
                     quote_plus(repr(self.args.username)),
                     quote_plus(repr(self.args.cat)),
                     repr(self.args.orderby),
                     repr(self.args.related),
                     True,
                 )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the next pictures
                 thumbnail = os.path.join(self.BASE_PLUGIN_THUMBNAIL_PATH,
                                          "next.png")
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem = xbmcgui.ListItem(label="%s (%d-%d)" % (
                     xbmc.getLocalizedString(3),
                     startno,
                     endno,
                 ),
                                             iconImage=icon,
                                             thumbnailImage=thumbnail)
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                  url=url,
                                                  listitem=listitem,
                                                  isFolder=True,
                                                  totalItems=total_items)
             # if we are on page 2 or more, we add our previous page folder
             if (page > 1):
                 # calculate the starting video
                 startno = (page - 2) * perpage + 1
                 # calculate the ending video
                 endno = startno + perpage - 1
                 # create the callback url
                 url = '%s?title=%s&category=%s&page=%d&vq=%s&username=%s&cat=%s&orderby=%s&related=%s&issearch=0&update_listing=%d' % (
                     sys.argv[0],
                     quote_plus(repr(self.args.title)),
                     repr(self.args.category),
                     page - 1,
                     quote_plus(repr(self.args.vq)),
                     quote_plus(repr(self.args.username)),
                     quote_plus(repr(self.args.cat)),
                     repr(self.args.orderby),
                     repr(self.args.related),
                     True,
                 )
                 # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
                 # we set the thumb so XBMC does not try and cache the previous pictures
                 thumbnail = os.path.join(self.BASE_PLUGIN_THUMBNAIL_PATH,
                                          "previous.png")
                 # set the default icon
                 icon = "DefaultFolder.png"
                 # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
                 listitem = xbmcgui.ListItem(label="%s (%d-%d)" % (
                     xbmc.getLocalizedString(3),
                     startno,
                     endno,
                 ),
                                             iconImage=icon,
                                             thumbnailImage=thumbnail)
                 # add the folder item to our media list
                 ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                  url=url,
                                                  listitem=listitem,
                                                  isFolder=True,
                                                  totalItems=total_items)
             # set our thumbnail for queries
             self.query_thumbnail = videos[0]["media$group"][
                 "media$thumbnail"][-1]["url"]
             # enumerate through the list of pictures and add the item to the media list
             for video in videos:
                 # only add videos with an embeddable video
                 if (video["media$group"].has_key("media$player")):
                     # create the title, we use video title and author (exec is a hack for unescaping \u#### characters)
                     exec 'title = u"%s"' % (unicode(
                         video["title"]["$t"].replace('"', '\\"'), encoding,
                         "replace"), )
                     # set the director with author (exec is a hack for unescaping \u#### characters)
                     exec 'director = u"%s"' % (unicode(
                         video["author"][0]["name"]["$t"].replace(
                             '"', '\\"'), encoding, "replace"), )
                     # thumbnail url
                     thumbnail_url = video["media$group"][
                         "media$thumbnail"][-1]["url"]
                     # plot
                     try:
                         # we need to replace \n and \r as it messes up our exec hack (exec is a hack for unescaping \u#### characters)
                         exec 'plot = u"%s"' % (unicode(
                             video["media$group"]
                             ["media$description"]["$t"].replace(
                                 '"', '\\"').replace("\n", "\\n").replace(
                                     "\r", "\\r"), encoding, "replace"), )
                     except:
                         plot = xbmc.getLocalizedString(30904)
                     # format runtime as 00:00
                     runtime = int(
                         video["media$group"]["yt$duration"]["seconds"])
                     # video runtime
                     if (runtime):
                         runtime = "%02d:%02d" % (
                             int(runtime / 60),
                             runtime % 60,
                         )
                     else:
                         runtime = ""
                     # viewer rating
                     try:
                         rating = float(video["gd$rating"]["average"])
                     except:
                         rating = 0.0
                     # times viewed
                     try:
                         count = int(video["yt$statistics"]["viewCount"])
                     except:
                         count = 0
                     # genre
                     genre = video["media$group"]["media$category"][0]["$t"]
                     # updated date
                     date = "%s-%s-%s" % (
                         video["updated"]["$t"][8:10],
                         video["updated"]["$t"][5:7],
                         video["updated"]["$t"][:4],
                     )
                     # video url
                     exec 'video_url = u"%s"' % (unicode(
                         video["media$group"]["media$player"][0]["url"],
                         encoding), )
                     # construct our url
                     url = "%s?category='play_video'&video_url=%s&releated=%s&update_listing=%d" % (
                         sys.argv[0],
                         quote_plus(repr(video_url)),
                         repr(video["id"]["$t"].split("/")[-1]),
                         False,
                     )
                     # set the default icon
                     icon = "DefaultVideo.png"
                     # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
                     listitem = xbmcgui.ListItem(
                         label=title,
                         iconImage=icon,
                         thumbnailImage=thumbnail_url)
                     # add the different infolabels we want to sort by
                     listitem.setInfo(type="Video",
                                      infoLabels={
                                          "Title": title,
                                          "Director": director,
                                          "Duration": runtime,
                                          "Plot": plot,
                                          "Rating": rating,
                                          "Genre": genre,
                                          "Count": count,
                                          "Date": date
                                      })
                     # set isplayable property
                     listitem.setProperty("IsPlayable", "true")
                     # set context menu items
                     cm = []
                     # add queue video
                     cm += [(
                         xbmc.getLocalizedString(30504),
                         "XBMC.Action(Queue)",
                     )]
                     # add related videos
                     cm += [(
                         xbmc.getLocalizedString(30500),
                         "Container.Update(%s?title=%s&category='related'&page=1&vq=''&username=''&cat=''&orderby='relevance'&related=%s&issearch=False&update_listing=False)"
                         % (
                             sys.argv[0],
                             repr(xbmc.getLocalizedString(30968)),
                             repr(video["id"]["$t"].split("/")[-1]),
                         ),
                     )]
                     # add author videos
                     cm += [(
                         xbmc.getLocalizedString(30507) % (director, ),
                         "Container.Update(%s?title=%s&category='users__uploads'&page=1&vq=''&username=%s&cat=''&orderby='relevance'&related=''&issearch=False&update_listing=False)"
                         % (
                             sys.argv[0],
                             quote_plus(repr(director)),
                             quote_plus(repr(director)),
                         ),
                     )]
                     # if download path set, add download item
                     if (self.settings["download_path"] != ""):
                         cm += [(
                             xbmc.getLocalizedString(30501),
                             "XBMC.RunPlugin(%s?category='download_video'&video_url=%s)"
                             % (
                                 sys.argv[0],
                                 quote_plus(repr(video_url)),
                             ),
                         )]
                     # add movie info
                     cm += [(
                         xbmc.getLocalizedString(30502),
                         "XBMC.Action(Info)",
                     )]
                     # add to favourites
                     if (self.args.category != "my_favorites"
                             and self.authkey):
                         cm += [(xbmc.getLocalizedString(
                             30503
                         ), "XBMC.RunPlugin(%s?category='add__favorite'&video_id=%s&update_listing=False)"
                                 % (
                                     sys.argv[0],
                                     repr(video["id"]["$t"].split("/")[-1]),
                                 ))]
                     else:
                         # find the edit url
                         for link in video["link"]:
                             # this is the edit url, so set the context menu item
                             if (link["rel"] == "edit"):
                                 # set url using this hack to clean the result (exec is a hack for unescaping \u#### characters)
                                 exec 'edit_url = u"%s"' % (unicode(
                                     link["href"], encoding), )
                                 # add context menu item
                                 cm += [(
                                     xbmc.getLocalizedString(30506),
                                     "XBMC.RunPlugin(%s?category='delete__favorite'&edit_url=%s&update_listing=False)"
                                     % (
                                         sys.argv[0],
                                         quote_plus(repr(edit_url)),
                                     ),
                                 )]
                     # add now playing
                     cm += [(
                         xbmc.getLocalizedString(30505),
                         "XBMC.ActivateWindow(10028)",
                     )]
                     # add context menu items
                     listitem.addContextMenuItems(cm, replaceItems=True)
                     # add the video to the media list
                     ok = xbmcplugin.addDirectoryItem(
                         handle=int(sys.argv[1]),
                         url=url,
                         listitem=listitem,
                         isFolder=False,
                         totalItems=total_items)
                     # if user cancels, call raise to exit loop
                     if (not ok): raise
             if (spell_vq):
                 self.args.username = (
                     "",
                     spell_vq,
                 )[self.args.issearch == 2]
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % (
             self.__class__.__name__,
             sys.exc_info()[2].tb_frame.f_code.co_name,
             sys.exc_info()[2].tb_lineno,
             sys.exc_info()[1],
         )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if (ok):
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_LABEL)
         xbmcplugin.addSortMethod(
             handle=int(sys.argv[1]),
             sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RATING)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_DATE)
         xbmcplugin.addSortMethod(
             handle=int(sys.argv[1]),
             sortMethod=xbmcplugin.SORT_METHOD_PROGRAM_COUNT)
         xbmcplugin.addSortMethod(
             handle=int(sys.argv[1]),
             sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_GENRE)
         # set content
         xbmcplugin.setContent(handle=int(sys.argv[1]), content="movies")
         # set our plugin category
         xbmcplugin.setPluginCategory(handle=int(sys.argv[1]),
                                      category=self.args.title)
         # if skin has fanart image use it
         fanart_image = os.path.join(sys.modules["__main__"].__plugin__,
                                     self.args.category + "-fanart.png")
         if (xbmc.skinHasImage(fanart_image)):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=fanart_image)
         # set our fanart from user setting
         elif (self.settings["fanart_image"]):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=self.settings["fanart_image"])
     return ok, total_items
def has(filename):
    return True if xbmc.skinHasImage(filename) else False
Exemplo n.º 40
0
 def _fill_media_list(self,
                      items,
                      page,
                      pages=1,
                      perpage=1,
                      total=1,
                      encoding="utf-8",
                      kind="photo",
                      access=""):
     try:
         # calculate total items including previous and next
         total_items = len(items) + (page < pages) + (page > 1)
         # if there is more than one page and we are not on the last page, we add our next page folder
         if (page < pages):
             # calculate the starting video
             startno = page * perpage + 1
             # calculate the ending video
             endno = startno + perpage - 1
             # if there are fewer items than per_page set endno to total
             if (endno > total):
                 endno = total
             # create the callback url
             url = '%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s' % (
                 sys.argv[0],
                 quote_plus(repr(self.args.title)),
                 repr(self.args.category),
                 repr(access),
                 repr(kind),
                 page + 1,
                 quote_plus(repr(self.args.pq)),
                 True,
                 repr(self.args.user_id),
                 repr(self.args.album_id),
                 repr(self.args.photo_id),
             )
             # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
             # we set the thumb so XBMC does not try and cache the next pictures
             thumbnail = os.path.join(self.BASE_PLUGIN_THUMBNAIL_PATH,
                                      "next.png")
             # set the default icon
             icon = "DefaultFolder.png"
             # set stringid
             stringid = 30908 + (kind == "album")
             # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
             listitem = xbmcgui.ListItem(label="%s (%d-%d)" % (
                 xbmc.getLocalizedString(stringid),
                 startno,
                 endno,
             ),
                                         iconImage=icon,
                                         thumbnailImage=thumbnail)
             # add the folder item to our media list
             ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                              url=url,
                                              listitem=listitem,
                                              isFolder=True,
                                              totalItems=total_items)
         # if we are on page 2 or more, we add our previous page folder
         if (page > 1):
             # calculate the starting video
             startno = (page - 2) * perpage + 1
             # calculate the ending video
             endno = startno + perpage - 1
             # create the callback url
             url = '%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s' % (
                 sys.argv[0],
                 quote_plus(repr(self.args.title)),
                 repr(self.args.category),
                 repr(access),
                 repr(kind),
                 page - 1,
                 quote_plus(repr(self.args.pq)),
                 True,
                 repr(self.args.user_id),
                 repr(self.args.album_id),
                 repr(self.args.photo_id),
             )
             # TODO: get rid of self.BASE_PLUGIN_THUMBNAIL_PATH
             # we set the thumb so XBMC does not try and cache the previous pictures
             thumbnail = os.path.join(self.BASE_PLUGIN_THUMBNAIL_PATH,
                                      "previous.png")
             # set the default icon
             icon = "DefaultFolder.png"
             # set stringid
             stringid = 30908 + (kind == "album")
             # only need to add label and icon, setInfo() and addSortMethod() takes care of label2
             listitem = xbmcgui.ListItem(label="%s (%d-%d)" % (
                 xbmc.getLocalizedString(stringid),
                 startno,
                 endno,
             ),
                                         iconImage=icon,
                                         thumbnailImage=thumbnail)
             # add the folder item to our media list
             ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                              url=url,
                                              listitem=listitem,
                                              isFolder=True,
                                              totalItems=total_items)
         # set our thumbnail for queries
         if (self.user_icon):
             self.query_thumbnail = self.user_icon
         else:
             self.query_thumbnail = items[0]["thumb_url"]
         # enumerate through the list of pictures and add the item to the media list
         for c, item in enumerate(items):
             # construct our url
             if (item["photo_url"]):
                 # we are a photo, so set it's url to the full image
                 url = item["photo_url"]
                 # we are not a folder
                 isfolder = False
                 # set the default icon
                 icon = "DefaultPicture.png"
             else:
                 # we need to reset page and kind for albums that contain photos
                 if (item["album_id"] and kind == "album"):
                     # we switch to photos since that's what an album holds
                     kind = "photo"
                     # set page to #1
                     page = 1
                     # set our category to photos
                     self.args.category = "photos"
                 url = "%s?title=%s&category=%s&access=%s&kind=%s&page=%d&pq=%s&issearch=0&update_listing=%d&user_id=%s&album_id=%s&photo_id=%s" % (
                     sys.argv[0],
                     quote_plus(repr(item["title"])),
                     repr(self.args.category),
                     repr(access),
                     repr(kind),
                     page,
                     repr(""),
                     False,
                     repr(item["user_id"]),
                     repr(item["album_id"]),
                     repr(item["photo_id"]),
                 )
                 # no photo_url, must be an album
                 isfolder = True
                 # set the default icon
                 icon = "DefaultFolder.png"
             # we add total items if this is an album, we add author if it is a photo
             if (item["photo_url"]):
                 title = item["title"]
             else:
                 title = "%s (%d)" % (
                     item["title"],
                     item["numphotos"],
                 )
             # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2
             listitem = xbmcgui.ListItem(label=title,
                                         iconImage=icon,
                                         thumbnailImage=item["thumb_url"])
             # add the different infolabels we want to sort by
             listitem.setInfo(type="Pictures", infoLabels={"Title": title})
             # we add additional properties and infolabels for photos
             if (item["photo_url"]):
                 listitem.setInfo(type="Pictures",
                                  infoLabels={
                                      "Date":
                                      "%s-%s-%s" % (
                                          item["photo_datetime"][8:10],
                                          item["photo_datetime"][5:7],
                                          item["photo_datetime"][:4],
                                      ),
                                      "Size":
                                      item["photo_size"],
                                      "exif:exiftime":
                                      item["photo_datetime"],
                                      "exif:resolution":
                                      "%d,%d" % (
                                          item["photo_width"],
                                          item["photo_height"],
                                      )
                                  })
                 # skins display these with ListItem.Property(User)...
                 listitem.setProperty("User", item["author"])
                 listitem.setProperty("Description", item["summary"])
                 listitem.setProperty("DateTaken", item["photo_datetime"])
             # add the video to the media list
             ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                              url=url,
                                              listitem=listitem,
                                              isFolder=isfolder,
                                              totalItems=total_items)
             # if user cancels, call raise to exit loop
             if (not ok): raise
     except:
         # oops print error message
         print "ERROR: %s::%s (%d) - %s" % (
             self.__class__.__name__,
             sys.exc_info()[2].tb_frame.f_code.co_name,
             sys.exc_info()[2].tb_lineno,
             sys.exc_info()[1],
         )
         ok = False
     # if successful and user did not cancel, add all the required sort methods
     if (ok):
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_LABEL)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_SIZE)
         xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                  sortMethod=xbmcplugin.SORT_METHOD_DATE)
         # set content
         xbmcplugin.setContent(handle=int(sys.argv[1]), content="pictures")
         # set our plugin category
         xbmcplugin.setPluginCategory(handle=int(sys.argv[1]),
                                      category=self.args.title)
         # if skin has fanart image use it
         fanart_image = os.path.join(sys.modules["__main__"].__plugin__,
                                     self.args.category + "-fanart.png")
         if (xbmc.skinHasImage(fanart_image)):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=fanart_image)
         # set our fanart from user setting
         elif (self.settings["fanart_image"]):
             xbmcplugin.setPluginFanart(handle=int(sys.argv[1]),
                                        image=self.settings["fanart_image"])
     return ok, total_items