def _setDefaultImages(self, item): """ Set the images with default value depending on the type of the item """ print "_setDefaultImages" print item['previewpictureurl'] if item['previewpictureurl'] == '': # No picture available -> use default one item['thumbnail'] = Item.get_thumb(item['xbmc_type']) # icone item['previewpicture'] = "" #Item.THUMB_NOT_AVAILABLE # preview else: # Check if picture is already downloaded and available downloadImage = False thumbnail, checkPathPic = set_cache_thumb_name( item['previewpictureurl']) if thumbnail and os.path.isfile(thumbnail): item['thumbnail'] = thumbnail else: item['thumbnail'] = Item.THUMB_NOT_AVAILABLE downloadImage = True if os.path.exists(checkPathPic): item['previewpicture'] = checkPathPic else: item['previewpicture'] = "" #Item.THUMB_NOT_AVAILABLE downloadImage = True if downloadImage == True: # Set flag for download (separate thread) item['image2retrieve'] = True
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 _setDefaultImages(self, item): """ Set the images with default value depending on the type of the item """ print "_setDefaultImages" print item['previewpictureurl'] if item['previewpictureurl'] == '': # No picture available -> use default one item['thumbnail'] = Item.get_thumb( item['xbmc_type'] ) # icone item['previewpicture'] = ""#Item.THUMB_NOT_AVAILABLE # preview else: # Check if picture is already downloaded and available downloadImage = False thumbnail, checkPathPic = set_cache_thumb_name( item['previewpictureurl'] ) if thumbnail and os.path.isfile( thumbnail ): item['thumbnail'] = thumbnail else: item['thumbnail'] = Item.THUMB_NOT_AVAILABLE downloadImage = True if os.path.exists(checkPathPic): item['previewpicture'] = checkPathPic else: item['previewpicture'] = ""#Item.THUMB_NOT_AVAILABLE downloadImage = True if downloadImage == True: # Set flag for download (separate thread) item['image2retrieve'] = True
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 _createNEWListItem ( self ): # Create ALL category item = {} item['name'] = _( 22 ) item['parent'] = 0 item['type'] = Item.TYPE_NEW item['description'] = "" item['xbmc_type'] = Item.TYPE_NEW item['thumbnail'] = Item.get_thumb( Item.TYPE_NEW ) item['previewpictureurl'] = "" item['previewpicture'] = ""#Item.get_thumb( entry ) item['image2retrieve'] = False # Temporary patch for reseting the flag after downlaad (would be better in the thread in charge of the download) item['language'] = "" item['version'] = "" item['author'] = "" item['added'] = "" item['date'] = "" self._setDefaultImages( item ) print item return item
def _createNEWListItem(self): # Create ALL category item = {} item['name'] = _(22) item['parent'] = 0 item['type'] = Item.TYPE_NEW item['description'] = "" item['xbmc_type'] = Item.TYPE_NEW item['thumbnail'] = Item.get_thumb(Item.TYPE_NEW) item['previewpictureurl'] = "" item['previewpicture'] = "" #Item.get_thumb( entry ) item[ 'image2retrieve'] = False # Temporary patch for reseting the flag after downlaad (would be better in the thread in charge of the download) item['language'] = "" item['version'] = "" item['author'] = "" item['added'] = "" item['date'] = "" self._setDefaultImages(item) print item return item
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
def _createListFromJson(self, requestURL, skipdescript=False): """ Create and return the list from json data Returns list and name of the list Json data: u'rating' u'script_language' u'image' u'totalitems' u'id' u'title' u'version' u'filesize' u'totaldownloads' u'type' u'filetype' u'description' u'views' u'createdate' u'orginalfilename' u'description_en' u'xbmc_type' u'commenttotal' u'date' u'fileurl' u'ID_TOPIC' u'author' u'idparent' """ list = [] # Retrieve json data jsondata = self._retrieve_json(requestURL, skipdescript) dicdata = json.loads(jsondata) # List the main categories at the root level for entry in dicdata: if Item.isSupported(categories[entry['xbmc_type']]): item = {} item['id'] = int(entry['id']) item['name'] = entry['title'] #.encode( "utf8" ) item['parent'] = int(entry['idparent']) item['downloadurl'] = entry['fileurl'] item['type'] = entry['type'] #'CAT' item['totaldownloads'] = entry['totaldownloads'] item['xbmc_type'] = categories[entry['xbmc_type']] #item['cattype'] = entry if LANGUAGE_IS_FRENCH: item['description'] = self.strip_off_passionCDT( unescape(urllib.unquote( entry['description']))) #.encode("cp1252"). else: item['description'] = self.strip_off_passionCDT( unescape(urllib.unquote(entry['description_en'])) ) #.encode("cp1252").decode('string_escape') if item['description'] == 'None': item['description'] = _(604) item['language'] = entry['script_language'] item['version'] = entry['version'] item['author'] = entry['author'] item['date'] = entry['createdate'] if entry['date'] != '': item['added'] = strftime('%d-%m-%Y', localtime(int(entry['date']))) else: item['added'] = entry['date'] if entry['filesize'] != '': item['filesize'] = int(entry['filesize']) else: item['filesize'] = 0 # '' item['thumbnail'] = Item.get_thumb(item['xbmc_type']) item['previewpictureurl'] = entry['image'] item['previewpicture'] = "" #Item.get_thumb( entry ) item[ 'image2retrieve'] = False # Temporary patch for reseting the flag after downlaad (would be better in the thread in charge of the download) item['orginalfilename'] = entry['orginalfilename'] #TODO: deprecated??? Check server side item['fileexternurl'] = "None" self._setDefaultImages(item) list.append(item) print item else: print "Type not supported by the installer:" print entry return list
def _createListFromJson( self, requestURL, skipdescript=False ): """ Create and return the list from json data Returns list and name of the list Json data: u'rating' u'script_language' u'image' u'totalitems' u'id' u'title' u'version' u'filesize' u'totaldownloads' u'type' u'filetype' u'description' u'views' u'createdate' u'orginalfilename' u'description_en' u'xbmc_type' u'commenttotal' u'date' u'fileurl' u'ID_TOPIC' u'author' u'idparent' """ list = [] # Retrieve json data jsondata = self._retrieve_json( requestURL, skipdescript ) dicdata = json.loads( jsondata ) # List the main categories at the root level for entry in dicdata: if Item.isSupported( categories[ entry['xbmc_type'] ] ): item = {} item['id'] = int( entry['id'] ) item['name'] = entry['title']#.encode( "utf8" ) item['parent'] = int( entry['idparent'] ) item['downloadurl'] = entry['fileurl'] item['type'] = entry['type']#'CAT' item['totaldownloads'] = entry['totaldownloads'] item['xbmc_type'] = categories[ entry['xbmc_type'] ] #item['cattype'] = entry if LANGUAGE_IS_FRENCH: item['description'] = self.strip_off_passionCDT( unescape( urllib.unquote( entry['description'] ) ) )#.encode("cp1252"). else: item['description'] = self.strip_off_passionCDT( unescape( urllib.unquote( entry['description_en'] ) ) )#.encode("cp1252").decode('string_escape') if item['description'] == 'None': item['description'] = _( 604 ) item['language'] = entry['script_language'] item['version'] = entry['version'] item['author'] = entry['author'] item['date'] = entry['createdate'] if entry['date'] != '': item['added'] = strftime( '%d-%m-%Y', localtime( int (entry['date'] ) ) ) else: item['added'] = entry['date'] if entry['filesize'] != '': item['filesize'] = int( entry['filesize'] ) else: item['filesize'] = 0 # '' item['thumbnail'] = Item.get_thumb( item['xbmc_type'] ) item['previewpictureurl'] = entry['image'] item['previewpicture'] = ""#Item.get_thumb( entry ) item['image2retrieve'] = False # Temporary patch for reseting the flag after downlaad (would be better in the thread in charge of the download) item['orginalfilename'] = entry['orginalfilename'] #TODO: deprecated??? Check server side item['fileexternurl'] = "None" self._setDefaultImages( item ) list.append(item) print item else: print "Type not supported by the installer:" print entry return list
def _createItemList( self, dom ) : """ Parse XML and create the list of item defined in the XML file """ list = [] # Parse XML... for category_node in dom.getElementsByTagName('Addon') : item = {} for child in category_node.childNodes: # Type if child.localName == "Type" : type = child.firstChild.data #item['xbmc_type'] = self._mapType_Server2Local( child.firstChild.data.decode("utf8") ) #TODO: find cleaner solution for defining xbmc_type if type == "Script": item['xbmc_type'] = self._mapType_Server2Local( type ) # Category elif child.localName == "Category" : try: category = child.firstChild.data except: category = None item['cattype'] = category #TODO: find cleaner solution for defining xbmc_type if "Plugin" in category: item['xbmc_type'] = self._mapType_Server2Local( category ) # ID elif child.localName == "ID" : try: id = child.firstChild.data except: id = 0 item['downloadurl'] = "http://xbmczone.com/download.asp?id=%s" % ( id ) # Name elif child.localName == "Name" : try: item['name'] = child.firstChild.data except: item['name'] = "" # File Name elif child.localName == "FileName" : try: item['filename'] = child.firstChild.data except: item['filename'] = "" # Version elif child.localName == "Version" : #version = child.firstChild.data try: item['version'] = child.firstChild.data except: item['version'] = "" # Author elif child.localName == "Author" : try: item['author'] = child.firstChild.data except: item['author'] = "" # Date elif child.localName == "Date" : try: date = child.firstChild.data date_elements = date.split("/") #item_date = "%s-%s-%s" % ( date_elements[1].zfill(2), date_elements[0].zfill(2), date_elements[2] ) item['date'] = "%s-%s-%s" % ( date_elements[1].zfill(2), date_elements[0].zfill(2), date_elements[2] ) except: item['date'] = "" # Description elif child.localName == "Description" : try: item['description'] = child.firstChild.data except: item['description'] = "" # Instructions # elif child.localName == "Instructions" : # if child.firstChild != None : # instructions = child.firstChild.data # else : # instructions = "" # Add entry... item['type'] = 'FIC' item['previewpictureurl'] = None item['language'] = "" 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) # # Set image # self._setDefaultImages( item ) list.append(item) print item return list
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
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()
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()