Example #1
0
    def _createRootList(self):
        """
        Create and return the root list (all type available)
        Returns list and name of the list
        """
        list = []
        listTitle = _( 10 )

        # List the main categorie at the root level
        for cat in self.racineDisplayList:   
            item = {}
            #item['id']                = ""
            item['name']              = Item.get_type_title( cat )
            #item['parent']            = self.type
            item['downloadurl']       = None
            item['type']              = 'CAT'
            item['xbmc_type']         = cat
            item['cattype']           = cat
            item['previewpictureurl'] = None
            item['description']       = Item.get_type_title( cat )
            item['language']          = ""
            item['version']           = ""
            item['author']            = ""
            item['date']              = ""
            item['added']             = ""
            item['thumbnail']         = Item.get_thumb( cat )
            item['previewpicture']    = ""#Item.get_thumb( cat )
            item['image2retrieve']    = False # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

            list.append(item)
            print item
            
        return listTitle, list
    def _createScraperList(self):
        """
        Create and return the list of scraper types
        Returns list and name of the list
        """
        list = []
        listTitle = Item.get_type_title(Item.TYPE_SCRAPER)

        # List all the type of plugins
        for cat in self.scraperDisplayList:
            item = {}
            item["name"] = Item.get_type_title(cat)
            item["downloadurl"] = None
            item["type"] = "CAT"
            item["xbmc_type"] = cat
            item["previewpictureurl"] = None
            item["description"] = Item.get_type_title(cat)
            item["language"] = ""
            item["version"] = ""
            item["author"] = ""
            item["date"] = ""
            item["added"] = ""
            item["thumbnail"] = Item.get_thumb(cat)
            item["previewpicture"] = ""  # Item.get_thumb( cat )
            item[
                "image2retrieve"
            ] = (
                False
            )  # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

            list.append(item)
            print item

        return listTitle, list
    def _createScraperList(self):
        """
        Create and return the list of scraper types
        Returns list and name of the list
        """
        list = []
        listTitle = Item.get_type_title(Item.TYPE_SCRAPER)

        # List all the type of plugins
        for cat in self.scraperDisplayList:
            item = {}
            item['name'] = Item.get_type_title(cat)
            item['downloadurl'] = None
            item['type'] = 'CAT'
            item['xbmc_type'] = cat
            item['previewpictureurl'] = None
            item['description'] = Item.get_type_title(cat)
            item['language'] = ""
            item['version'] = ""
            item['author'] = ""
            item['date'] = ""
            item['added'] = ""
            item['thumbnail'] = Item.get_thumb(cat)
            item['previewpicture'] = ""  #Item.get_thumb( cat )
            item[
                'image2retrieve'] = False  # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

            list.append(item)
            print item

        return listTitle, list
    def _getList( self, listItem=None ):
        """
        Retrieves list matching to a specific list Item
        """
        # Check type of selected item
        list = []
        curCategory = None
        #TODO: manage exception
        
        try:            
            if listItem != None:
                listItemName = listItem['name']
                if listItem['type'] == 'cat':
                    listItemID = listItem['id']
                    listTitle  = listItem['name']
                    #if listItem['xbmc_type'] == Item.TYPE_NEW:
                    if listItem['xbmc_type'] == Item.TYPE_SKIN_NIGHTLY:
                        curCategory = listItemName
                        list = self._createCatList( listItemID, skipdescript=True )
                        list.append( self._createALLListItem( listItem['xbmc_type'] ) )
                    else:
                        # List of item to download case                  
                        curCategory = listItemName
                        list = self._createCatList( listItemID )
                        list.append( self._createALLListItem( listItem['xbmc_type'] ) )
                elif listItem['type'] == Item.TYPE_NEW:
                    # Lastest/new items case
                    # We look for 30 days back
                    # TODO: set the duration in settings
                    curCategory = listItemName

                    # Create epoch date
                    sincedate = mktime((date.today() - timedelta(days=30)).timetuple())
                    list = self._createNewItemList( sincedate, skipdescript=True )
#                    list = []
#                    # Merge list (could be optimized)
#                    for xbmcType in validCatList:
#                        list = list + self._createNewItemList( sincedate, xbmcType, skipdescript=True )
                elif listItem['type'] == 'addon_type':
                    curCategory = Item.get_type_title( listItem['xbmc_type'] )
                    list = self._createXbmcTypeList( listItem['xbmc_type'] )
                    
                else:
                    # Return the current list
                    #TODO: start download here?
                    print "This is not a category but an item (download)"
                    list = None
            else: # listItem == None 
                # 1st time (init), we display root list
                # List the main categorie at the root level
                curCategory = _( 10 )
                list = self._createCatList( 0 )
                # Convert Fr title to En if necessary
                self._convertFr2EnRootTitle(list)
                list.append( self._createNEWListItem() )
        except Exception, e:
            print "Exception during getNextList"
            print e
            print_exc()
Example #5
0
 def _convertFr2EnRootTitle(self, list):
     """
     Replace in the root list french title by english one
     This will disappear when the server will return en and fr (now only french is returned for cat) 
     """
     if not LANGUAGE_IS_FRENCH:
         try:
             for item in list:
                 item['name'] = Item.get_type_title(item['xbmc_type'])
         except Exception, e:
             print "Exception during _convertFr2EnRootTitle"
             print e
             print_exc()
 def _convertFr2EnRootTitle( self, list ):
     """
     Replace in the root list french title by english one
     This will disappear when the server will return en and fr (now only french is returned for cat) 
     """
     if not LANGUAGE_IS_FRENCH:
         try:
             for item in list:
                 item['name'] = Item.get_type_title( item['xbmc_type'] )
         except Exception, e:
             print "Exception during _convertFr2EnRootTitle"
             print e
             print_exc()
    def _createRootList(self):
        """
        Create and return the root list (all type available)
        Returns list and name of the list
        """
        list = []
        listTitle = _(10)

        # List the main categorie at the root level
        for cat in self.racineDisplayList:
            item = {}
            # item['id']                = ""
            item["name"] = Item.get_type_title(cat)
            # item['parent']            = self.type
            item["downloadurl"] = None
            item["type"] = "CAT"
            item["xbmc_type"] = cat
            item["previewpictureurl"] = None
            item["description"] = Item.get_type_title(cat)
            item["language"] = ""
            item["version"] = ""
            item["author"] = ""
            item["date"] = ""
            item["added"] = ""
            item["thumbnail"] = Item.get_thumb(cat)
            item["previewpicture"] = ""  # Item.get_thumb( cat )
            item[
                "image2retrieve"
            ] = (
                False
            )  # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

            list.append(item)
            print item

        return listTitle, list
Example #8
0
 def _createLastestList( self ):
     """
     Create and return the list of Lastest addons
     Returns list and name of the list
     """
     xmlURL = "http://www.xbmczone.com/installer/addon_list_edit.asp?category=New"
     listTitle = Item.get_type_title( Item.TYPE_NEW )
     
     # Get page (XML)...
     usock = urllib.urlopen( xmlURL )
     dom   = minidom.parse( usock )
     usock.close()
     
     # Parse XML...
     list = self._createItemList( dom )
     return listTitle, list
Example #9
0
    def _getList(self, listItem=None):
        """
        Retrieves list matching to a specific list Item
        """
        # Check type of selected item
        list = []
        curCategory = None
        #TODO: manage exception

        try:
            if listItem != None:
                listItemName = listItem['name']
                if listItem['type'] == 'cat':
                    listItemID = listItem['id']
                    listTitle = listItem['name']
                    #if listItem['xbmc_type'] == Item.TYPE_NEW:
                    if listItem['xbmc_type'] == Item.TYPE_SKIN_NIGHTLY:
                        curCategory = listItemName
                        list = self._createCatList(listItemID,
                                                   skipdescript=True)
                        list.append(
                            self._createALLListItem(listItem['xbmc_type']))
                    else:
                        # List of item to download case
                        curCategory = listItemName
                        list = self._createCatList(listItemID)
                        list.append(
                            self._createALLListItem(listItem['xbmc_type']))
                elif listItem['type'] == Item.TYPE_NEW:
                    # Lastest/new items case
                    # We look for 30 days back
                    # TODO: set the duration in settings
                    curCategory = listItemName

                    # Create epoch date
                    sincedate = mktime(
                        (date.today() - timedelta(days=30)).timetuple())
                    list = self._createNewItemList(sincedate,
                                                   skipdescript=True)
#                    list = []
#                    # Merge list (could be optimized)
#                    for xbmcType in validCatList:
#                        list = list + self._createNewItemList( sincedate, xbmcType, skipdescript=True )
                elif listItem['type'] == 'addon_type':
                    curCategory = Item.get_type_title(listItem['xbmc_type'])
                    list = self._createXbmcTypeList(listItem['xbmc_type'])

                else:
                    # Return the current list
                    #TODO: start download here?
                    print "This is not a category but an item (download)"
                    list = None
            else:  # listItem == None
                # 1st time (init), we display root list
                # List the main categorie at the root level
                curCategory = _(10)
                list = self._createCatList(0)
                # Convert Fr title to En if necessary
                self._convertFr2EnRootTitle(list)
                list.append(self._createNEWListItem())
        except Exception, e:
            print "Exception during getNextList"
            print e
            print_exc()
Example #10
0
    def _createCatList( self, typeList):
        """
        Create and return the list of plugin categories
        Returns list and name of the list
        """
        categoryURL = {Item.TYPE_PLUGIN     : "http://www.xbmczone.com/installer/addon_categories.asp?type=Plugin",
                       Item.TYPE_SCRIPT_CAT : "http://www.xbmczone.com/installer/addon_categories.asp?type=Script"}
        list = []
        listTitle = Item.get_type_title( typeList )
        
        # Get page (XML)...
        usock = urllib.urlopen( categoryURL[ typeList ] )
        dom   = minidom.parse( usock )
        usock.close()
        

        # Add 'All' category
        item = {}
        item['cattype']   = self._mapType_Local2Server( typeList )
        item['name']      = _(2201)
        item['catname']      = "All"
        if self._mapType_Local2Server( typeList ) == "Script":
            item['xbmc_type'] = Item.TYPE_SCRIPT
        else: # Plugins
            item['xbmc_type'] = Item.TYPE_PLUGIN_VIDEO # Temporary patch ALL is not video plugin
        item['description']       = ""
        item['downloadurl']       = None
        item['type']              = 'CAT'
        item['previewpictureurl'] = None
        item['language']          = ""
        item['version']           = ""
        item['author']            = ""
        item['date']              = ""
        item['added']             = ""
        item['thumbnail']         = Item.get_thumb( item['xbmc_type'] )
        item['previewpicture']    = ""#Item.get_thumb( item['xbmc_type'] )
        item['image2retrieve']    = False # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)
        list.append(item)
        
        # Parse XML...
        for category in dom.getElementsByTagName('Category') :
            item = {}
            for child in category.childNodes:
                if child.localName == "Type" :
                    #type = child.childNodes[0].data
                    item['cattype'] = child.childNodes[0].data
                    #TODO: find cleaner solution for defining xbmc_type
                    if item['cattype'] == "Script":
                        #item['xbmc_type'] = self._mapType_Server2Local( child.childNodes[0].data )
                        item['xbmc_type'] = Item.TYPE_SCRIPT
                    
                elif child.localName == "Name" :
                    try:
                        item['name']    = child.childNodes[0].data
                        item['catname'] = child.childNodes[0].data
                        #item['xbmc_type'] = self._mapType_Server2Local( child.childNodes[0].data.decode("utf8") )
                        #TODO: find cleaner solution for defining xbmc_type
                        if "Plugin" in item['name']:
                            item['xbmc_type'] = self._mapType_Server2Local( child.childNodes[0].data )
                    except:
                        item['name']    = ""
                        item['catname'] = ""
                elif child.localName == "Description" :
                    try:
                        item['description'] = child.childNodes[0].data
                    except:
                        item['description'] = ""
            # Add entry...
#            listitem = xbmcgui.ListItem( category.replace("Plugin", ""), iconImage="DefaultFolder.png" )
#            xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = sys.argv[ 0 ] + '?action=plugin-list&category=%s' % urllib.quote( category ), listitem=listitem, isFolder=True)

            #item['parent']            = Item.TYPE_PLUGIN
            item['downloadurl']       = None
            item['type']              = 'CAT'
            item['previewpictureurl'] = None
            item['language']          = ""
            item['version']           = ""
            item['author']            = ""
            item['date']              = ""
            item['added']             = ""
            item['thumbnail']         = Item.get_thumb( item['xbmc_type'] )
            item['previewpicture']    = ""#Item.get_thumb( item['xbmc_type'] )
            item['image2retrieve']    = False # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

            list.append(item)
            print item
            
        return listTitle, list
Example #11
0
    def getNextList(self, index=0):
        """
        Returns the list of item (dictionary) on the server depending on the location we are on the server
        Retrieves list of the items and information about each item
        Other possible name: down
        """
        # Check type of selected item
        list = []
        # TODO: manage exception
        try:
            if len(self.curList) > 0:
                if self.curList[index]["type"] == "CAT":
                    if self.curList[index]["xbmc_type"] == Item.TYPE_PLUGIN:
                        # root plugin case
                        self.type = Item.TYPE_PLUGIN
                        self.curCategory, list = self._createPluginList()

                    elif self.curList[index]["xbmc_type"] == Item.TYPE_SCRAPER:
                        # root scraper case
                        self.type = Item.TYPE_SCRAPER
                        self.curCategory, list = self._createScraperList()

                    else:
                        # List of item to download
                        self.type = self.curList[index]["xbmc_type"]
                        self.curCategory = Item.get_type_title(self.type)
                        listOfItem = self.passionFTPCtrl.getDirList(self.remotedirList[Item.get_type_index(self.type)])
                        print "listOfItem in a cat"
                        print listOfItem
                        for elt in listOfItem:
                            item = {}
                            item["name"] = os.path.basename(elt).replace("_", " ")
                            item["downloadurl"] = elt
                            item["type"] = "FIC"
                            item["xbmc_type"] = self.type
                            item["previewpictureurl"] = None
                            item["description"] = _(604)
                            item["language"] = ""
                            item["version"] = ""
                            item["author"] = ""
                            item["date"] = ""
                            item["added"] = ""
                            # TODO: have different icon between cat and item without thumb
                            # item['thumbnail']         = Item.THUMB_NOT_AVAILABLE
                            item["thumbnail"] = Item.get_thumb(item["xbmc_type"])
                            item["previewpicture"] = ""  # Item.THUMB_NOT_AVAILABLE
                            item[
                                "image2retrieve"
                            ] = (
                                False
                            )  # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

                            self._set_item_infos(item)  # Update infos
                            list.append(item)
                            print item

                    # Save the current item name as category
                    self.curCategory = self.curList[index]["name"]
                else:
                    # Return the current list
                    # TODO: start download here?
                    print "This is not a category but an item (download)"
                    list = self.curList

            else:  # len(self.curList)<= 0
                # 1st time (init), we display root list
                self.type = Item.TYPE_ROOT
                # List the main categorie at the root level
                self.curCategory, list = self._createRootList()
        except Exception, e:
            print "Exception during getNextList"
            print_exc()
Example #12
0
    def getNextList(self, index=0):
        """
        Returns the list of item (dictionary) on the server depending on the location we are on the server
        Retrieves list of the items and information about each item
        Other possible name: down
        """
        # Check type of selected item
        list = []
        #TODO: manage exception
        try:
            if len(self.curList) > 0:
                if self.curList[index]['type'] == 'CAT':
                    if self.curList[index]['xbmc_type'] == Item.TYPE_PLUGIN:
                        # root plugin case
                        self.type = Item.TYPE_PLUGIN
                        self.curCategory, list = self._createPluginList()

                    elif self.curList[index]['xbmc_type'] == Item.TYPE_SCRAPER:
                        # root scraper case
                        self.type = Item.TYPE_SCRAPER
                        self.curCategory, list = self._createScraperList()

                    else:
                        # List of item to download
                        self.type = self.curList[index]['xbmc_type']
                        self.curCategory = Item.get_type_title(self.type)
                        listOfItem = self.passionFTPCtrl.getDirList(
                            self.remotedirList[Item.get_type_index(self.type)])
                        print "listOfItem in a cat"
                        print listOfItem
                        for elt in listOfItem:
                            item = {}
                            item['name'] = os.path.basename(elt).replace(
                                "_", " ")
                            item['downloadurl'] = elt
                            item['type'] = 'FIC'
                            item['xbmc_type'] = self.type
                            item['previewpictureurl'] = None
                            item['description'] = _(604)
                            item['language'] = ""
                            item['version'] = ""
                            item['author'] = ""
                            item['date'] = ""
                            item['added'] = ""
                            #TODO: have different icon between cat and item without thumb
                            #item['thumbnail']         = Item.THUMB_NOT_AVAILABLE
                            item['thumbnail'] = Item.get_thumb(
                                item['xbmc_type'])
                            item[
                                'previewpicture'] = ""  #Item.THUMB_NOT_AVAILABLE
                            item[
                                'image2retrieve'] = False  # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download)

                            self._set_item_infos(item)  # Update infos
                            list.append(item)
                            print item

                    # Save the current item name as category
                    self.curCategory = self.curList[index]['name']
                else:
                    # Return the current list
                    #TODO: start download here?
                    print "This is not a category but an item (download)"
                    list = self.curList

            else:  # len(self.curList)<= 0
                # 1st time (init), we display root list
                self.type = Item.TYPE_ROOT
                # List the main categorie at the root level
                self.curCategory, list = self._createRootList()
        except Exception, e:
            print "Exception during getNextList"
            print_exc()