Example #1
0
def handle():
    """
  Handle an XBMC plugin request.
  This will get the appropriate handler function, execute it to get a PluginResult
  then if they-re in normal flor, handle the result by either listing the items or playing them.
  """
    arguments = pluginsupport.getArguments()

    def __getArgument(arg):
        if not arguments.has_key(arg):
            return None
        val = arguments[arg]
        del arguments[arg]
        return val

    if __isAction(arguments):
        action = __getArgument('action')
        log.debug("invoking action '%s'" % action)
        actionHandlers[action].call(arguments)
    else:
        mode = __getArgument('mode') or "ROOT"
        handler = modeHandlers[mode]
        log.debug("invoking mode %r handler with arguments %r" %
                  (mode, arguments))
        result = handler.call(arguments)
        log.debug("results from mode %r handler: %r" % (mode, result))
        if handler.playable:
            log.debug("playing results for mode %r" % mode)
            pluginsupport.play(result.items)
        else:
            log.debug("listing results for mode %r" % mode)
            pluginsupport.list(result, handler.getContentType(arguments))
        pluginsupport.done()
Example #2
0
def handle():
    """
  Handle an XBMC plugin request.
  This will get the appropriate handler function, execute it to get a PluginResult
  then if they-re in normal flor, handle the result by either listing the items or playing them.
  """
    arguments = pluginsupport.getArguments()

    def __getArgument(arg):
        if not arguments.has_key(arg):
            return None
        val = arguments[arg]
        del arguments[arg]
        return val

    if __isAction(arguments):
        action = __getArgument('action')
        log.debug("invoking action '%s'" % action)
        actionHandlers[action].call(arguments)
    else:
        mode = __getArgument('mode') or "ROOT"
        handler = modeHandlers[mode]
        log.debug("invoking mode %r handler with arguments %r" % (mode, arguments))
        result = handler.call(arguments)
        log.debug("results from mode %r handler: %r" % (mode, result))
        if handler.playable:
            log.debug("playing results for mode %r" % mode)
            pluginsupport.play(result.items)
        else:
            log.debug("listing results for mode %r" % mode)
            pluginsupport.list(result, handler.getContentType(arguments))
        pluginsupport.done()
Example #3
0
 def getContentType(self, params=None):
     """Gets the content type for this handler
 @param params: the invocation params
 @return: the content type of this handler"""
     contentType = self.contentType
     params = params or pluginsupport.getArguments()
     if callable(contentType):
         contentType = contentType(params)
     return contentType
Example #4
0
 def getContentType(self, params=None):
     """Gets the content type for this handler
 @param params: the invocation params
 @return: the content type of this handler"""
     contentType = self.contentType
     params = params or pluginsupport.getArguments()
     if callable(contentType):
         contentType = contentType(params)
     return contentType
Example #5
0
    def getListItem(self):
        """Create a list item for XBMC for this PluginMovieItem
    @return the list item for XBMC"""
        if self.__listItem:
            return self.__listItem

        # get the current mode from the plugin's invocation arguments
        args = pluginsupport.getArguments()

        contentTypeOfCurrentList = None
        if args:
            contentTypeOfCurrentList = modeHandlers[
                args["mode"]].getContentType()

        if not contentTypeOfCurrentList in ["tvshows", "movies", "episodes"]:
            metadata = self.getMetadataLabels()
        elif contentTypeOfCurrentList == 'episodes':
            metadata = metadataFacade.get_episode_meta(args['name'],
                                                       args['imdbid'],
                                                       self.season,
                                                       self.episode)
        else:
            # get metadata for this item
            metadata = metadataFacade.get_meta(
                self.getMetadataMediaType(contentTypeOfCurrentList),
                self.getLabel())

        if 'cover_url' in metadata:
            thumb = metadata['cover_url']
        else:
            thumb = ""

        if 'imdb_id' in metadata:
            self.imdbid = metadata['imdb_id']

        self.__listItem = xbmcgui.ListItem(self.getLabel(),
                                           iconImage=thumb,
                                           thumbnailImage=thumb,
                                           path=self.getPath())
        self.__listItem.setInfo(type="Video", infoLabels=metadata)

        if 'backdrop_url' in metadata:
            fanart = metadata['backdrop_url']
            self.__listItem.setProperty('fanart_image', fanart)

        if self.isPlayable():
            self.__listItem.setProperty('IsPlayable', 'true')

        contextMenu = self.buildContextMenu()
        if contextMenu:
            self.__listItem.addContextMenuItems(contextMenu)

        return self.__listItem
Example #6
0
    def getListItem(self):
        """Create a list item for XBMC for this PluginMovieItem
    @return the list item for XBMC"""
        if self.__listItem:
            return self.__listItem

        # get the current mode from the plugin's invocation arguments
        args = pluginsupport.getArguments()

        contentTypeOfCurrentList = None
        if args:
            contentTypeOfCurrentList = modeHandlers[args["mode"]].getContentType()

        if not contentTypeOfCurrentList in ["tvshows", "movies", "episodes"]:
            metadata = self.getMetadataLabels()
        elif contentTypeOfCurrentList == 'episodes':
            metadata = metadataFacade.get_episode_meta(args['name'], args['imdbid'], self.season, self.episode)
        else:
            # get metadata for this item
            metadata = metadataFacade.get_meta(self.getMetadataMediaType(contentTypeOfCurrentList), self.getLabel())

        if 'cover_url' in metadata:
            thumb = metadata['cover_url']
        else:
            thumb = ""

        if 'imdb_id' in metadata:
            self.imdbid = metadata['imdb_id']

        self.__listItem = xbmcgui.ListItem(self.getLabel(), iconImage=thumb, thumbnailImage=thumb, path=self.getPath())
        self.__listItem.setInfo(type="Video", infoLabels=metadata)

        if 'backdrop_url' in metadata:
            fanart = metadata['backdrop_url']
            self.__listItem.setProperty('fanart_image', fanart)

        if self.isPlayable():
            self.__listItem.setProperty('IsPlayable', 'true')

        contextMenu = self.buildContextMenu()
        if contextMenu:
            self.__listItem.addContextMenuItems(contextMenu)

        return self.__listItem