def update_artwork(self): log.info('update_artwork') control = self.getControlById(CONTROL_LIST_ROMCOLLECTIONS) selected_romcollection_name = control.getSelectedItem().getLabel() romcollection_id = 0 #32120 = All if selected_romcollection_name != util.localize(32120): romcollection = self.gui.config.getRomCollectionByName( selected_romcollection_name) romcollection_id = romcollection.id control = self.getControlById(CONTROL_LIST_ARTWORKTYPES) selected_filetype_name = control.getSelectedItem().getLabel() filetype_id = 0 #32120 = All if selected_filetype_name != util.localize(32120): filetype, errormessage = self.gui.config.get_filetype_by_name( selected_filetype_name, self.gui.config.tree) filetype_id = filetype.id progressDialog = dialogprogress.ProgressDialogGUI() #32950 = Scan Artwork progressDialog.create(util.localize(32950)) updater = ArtworkUpdater(progressDialog, self.gui.gdb, self.gui.config) updater.update_artwork_cache(romcollection_id, filetype_id)
def exportLibrary(self, gdb, romCollections): Logutil.log("Begin exportLibrary", util.LOG_LEVEL_INFO) progressDialog = dialogprogress.ProgressDialogGUI() progressDialog.writeMsg(util.localize(32169), "", "") continueExport = True rccount = 1 for romCollection in romCollections.values(): progDialogRCHeader = util.localize(32170) + " (%i / %i): %s" % ( rccount, len(romCollections), romCollection.name) rccount = rccount + 1 Logutil.log("export Rom Collection: " + romCollection.name, util.LOG_LEVEL_INFO) gameCount = 1 #get all games for this Rom Collection games = Game(gdb).getGamesByFilter(romCollection.id, 0, 0, 0, False, '0 = 0') progressDialog.itemCount = len(games) + 1 for game in games: continueExport = progressDialog.writeMsg( progDialogRCHeader, util.localize(32171) + ": " + str(game.name), "", gameCount) if (not continueExport): Logutil.log('Game export canceled by user', util.LOG_LEVEL_INFO) break gameCount = gameCount + 1 gamenameFromFile = romCollection.getGamenameFromFilename( game.firstRom) artworkfiles = {} artworkurls = [] genreList = [] if game.genre: for genre in game.genre.split(', '): if genre != 'None': genreList.append(genre) self.createNfoFromDesc( game.name, game.plot, romCollection.name, game.publisher, game.developer, game.year, game.maxplayers, game.rating, game.votes, game.url, game.region, game.media, game.perspective, game.controllerType, game.originalTitle, game.alternateTitle, game.version, genreList, game.isFavorite, game.playcount, game.firstRom, gamenameFromFile, artworkfiles, artworkurls) progressDialog.writeMsg("", "", "", -1) del progressDialog
def exportLibrary(self, gdb, romCollections): Logutil.log("Begin exportLibrary", util.LOG_LEVEL_INFO) progressDialog = dialogprogress.ProgressDialogGUI() #32169 = Export library... progressDialog.create(util.localize(32169)) continueExport = True rccount = 1 for romCollection in list(romCollections.values()): #32170 = Exporting Rom Collection messageRomCollections = "%s (%i / %i): %s" % (util.localize( 32170), rccount, len(romCollections), romCollection.name) rccount = rccount + 1 Logutil.log("export Rom Collection: " + romCollection.name, util.LOG_LEVEL_INFO) gameCount = 1 #get all games for this Rom Collection games = GameView(gdb).getFilteredGames(romCollection.id, 0, 0, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0) progressDialog.itemCount = len(games) + 1 for game in games: #32171 = Export game message = "%s[CR]%s: %s" % (messageRomCollections, util.localize(32171), str(game[GameView.COL_NAME])) continueExport = progressDialog.writeMsg(message, gameCount) if not continueExport: Logutil.log('Game export canceled by user', util.LOG_LEVEL_INFO) break gameCount = gameCount + 1 romfiles = File(gdb).getRomsByGameId(game[GameView.COL_ID]) first_rom = romfiles[0] gamenameFromFile = romCollection.getGamenameFromFilename( first_rom[0]) artworkfiles = {} artworkurls = [] self.createNfoFromDesc(game, romCollection.name, first_rom[0], gamenameFromFile, artworkfiles, artworkurls) progressDialog.writeMsg("", -1) del progressDialog
def exportLibrary(self, gdb, romCollections): Logutil.log("Begin exportLibrary", util.LOG_LEVEL_INFO) progressDialog = dialogprogress.ProgressDialogGUI() progressDialog.writeMsg(util.localize(32169), "", "") continueExport = True rccount = 1 for romCollection in romCollections.values(): progDialogRCHeader = util.localize(32170) + " (%i / %i): %s" % ( rccount, len(romCollections), romCollection.name) rccount = rccount + 1 Logutil.log("export Rom Collection: " + romCollection.name, util.LOG_LEVEL_INFO) gameCount = 1 #get all games for this Rom Collection games = GameView(gdb).getFilteredGames(romCollection.id, 0, 0, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0) progressDialog.itemCount = len(games) + 1 for game in games: continueExport = progressDialog.writeMsg( progDialogRCHeader, util.localize(32171) + ": " + str(game[GameView.COL_NAME]), "", gameCount) if not continueExport: Logutil.log('Game export canceled by user', util.LOG_LEVEL_INFO) break gameCount = gameCount + 1 romfiles = File(gdb).getRomsByGameId(game[GameView.COL_ID]) first_rom = romfiles[0] gamenameFromFile = romCollection.getGamenameFromFilename( first_rom[0]) artworkfiles = {} artworkurls = [] self.createNfoFromDesc(game, romCollection.name, first_rom[0], gamenameFromFile, artworkfiles, artworkurls) progressDialog.writeMsg("", "", "", -1) del progressDialog
def exportLibrary(self, gui): Logutil.log("Begin exportLibrary", util.LOG_LEVEL_INFO) gdb = gui.gdb romCollections = gui.config.romCollections progressDialog = dialogprogress.ProgressDialogGUI() progressDialog.writeMsg(util.localize(32169), "", "") continueExport = True rccount = 1 for romCollection in gui.config.romCollections.values(): progDialogRCHeader = util.localize(32170) + " (%i / %i): %s" % ( rccount, len(romCollections), romCollection.name) rccount = rccount + 1 Logutil.log("export Rom Collection: " + romCollection.name, util.LOG_LEVEL_INFO) gameCount = 1 #get all games for this Rom Collection games = Game(gdb).getFilteredGames(romCollection.id, 0, 0, 0, False, '0 = 0') progressDialog.itemCount = len(games) + 1 for gameRow in games: gamename = self.getGameProperty(gameRow[util.ROW_NAME]) continueExport = progressDialog.writeMsg( progDialogRCHeader, util.localize(32171) + ": " + str(gamename), "", gameCount) if (not continueExport): Logutil.log('Game export canceled by user', util.LOG_LEVEL_INFO) break gameCount = gameCount + 1 plot = self.getGameProperty(gameRow[util.GAME_description]) publisher = self.getGamePropertyFromCache( gameRow, gui.publisherDict, util.GAME_publisherId, util.ROW_NAME) developer = self.getGamePropertyFromCache( gameRow, gui.developerDict, util.GAME_developerId, util.ROW_NAME) year = self.getGamePropertyFromCache(gameRow, gui.yearDict, util.GAME_yearId, util.ROW_NAME) genreList = [] try: cachingOptionStr = self.Settings.getSetting( util.SETTING_RCB_CACHINGOPTION) if (cachingOptionStr == 'CACHEALL'): genre = gui.genreDict[gameRow[util.ROW_ID]] else: genres = Genre(gdb).getGenresByGameId( gameRow[util.ROW_ID]) if (genres != None): for i in range(0, len(genres)): genreRow = genres[i] genreList.append(genreRow[util.ROW_NAME]) except: pass players = self.getGameProperty(gameRow[util.GAME_maxPlayers]) rating = self.getGameProperty(gameRow[util.GAME_rating]) votes = self.getGameProperty(gameRow[util.GAME_numVotes]) url = self.getGameProperty(gameRow[util.GAME_url]) region = self.getGameProperty(gameRow[util.GAME_region]) media = self.getGameProperty(gameRow[util.GAME_media]) perspective = self.getGameProperty( gameRow[util.GAME_perspective]) controller = self.getGameProperty( gameRow[util.GAME_controllerType]) originalTitle = self.getGameProperty( gameRow[util.GAME_originalTitle]) alternateTitle = self.getGameProperty( gameRow[util.GAME_alternateTitle]) version = self.getGameProperty(gameRow[util.GAME_version]) #user settings isFavorite = self.getGameProperty( gameRow[util.GAME_isFavorite]) launchCount = self.getGameProperty( gameRow[util.GAME_launchCount]) romFiles = File(gdb).getRomsByGameId(gameRow[util.ROW_ID]) romFile = '' if (romFiles != None and len(romFiles) > 0): romFile = romFiles[0][0] gamenameFromFile = helper.getGamenameFromFilename( romFile, romCollection) artworkfiles = {} artworkurls = [] self.createNfoFromDesc( gamename, plot, romCollection.name, publisher, developer, year, players, rating, votes, url, region, media, perspective, controller, originalTitle, alternateTitle, version, genreList, isFavorite, launchCount, romFile, gamenameFromFile, artworkfiles, artworkurls) progressDialog.writeMsg("", "", "", -1) del progressDialog
def Update(self): self.log('Update') self.SVNFileList = [] current = SVNDir(self, "") #SVNLookup self.SVNThreads.append(current) current.start() for t in self.SVNThreads: t.join() self.log( "Total Files: "+str(len(self.SVNFileList))) self.UpdatableFiles = [] self.UpdateFailed = [] XbtFiles = [] #TODO File revision self.log("check which files already exist") for File in self.SVNFileList: if not re.findall(".xbt", File): #check if file already exists testFile = File.replace(self.SVNPathAddress,"") testFile = os.path.join(self.UpdateTargetPath,testFile) if os.path.isfile(testFile.decode('utf-8')): self.log("file exists: " +testFile) else: self.UpdatableFiles.append(urllib.unquote(File)) else: XbtFiles.append(urllib.unquote(File)) LenFiles = len(self.UpdatableFiles) self.DownloadedFiles = [] self.DownloadFailedFiles = [] self.BackedUpFiles = [] progressDialog = dialogprogress.ProgressDialogGUI() progressDialog.itemCount = len(self.UpdatableFiles) progressDialog.writeMsg(self.Language(31970).decode('utf-8'), "", "", 0) continueDownload = True for count, file in enumerate(self.UpdatableFiles): self.BackedUpFiles.append(self.MakeBackup(file)) Flag = 1 while Flag: if activeCount() < 20: file = file.replace(self.SVNPathAddress,"") continueDownload = progressDialog.writeMsg(self.Language(31970).decode('utf-8'), self.Language(31974).decode('utf-8') +file.decode('utf-8'), "", count) if not continueDownload: self.log("Download cancelled by user") break current = SVNDownload(self, file) self.SVNThreads.append(current) current.start() Flag = 0 if not continueDownload: break for t in self.SVNThreads: t.join() self.log('join Threads') self.log('Threads joined') Errors = 0 for f in self.UpdatableFiles: if not f in self.DownloadedFiles: Errors = 1 if not Errors: LenFiles = len(self.DownloadedFiles) for count, file in enumerate(self.DownloadedFiles): MVStatus = self.MoveUpdate(file) if not MVStatus: Errors = 1 print 'Errors (after MoveUpdate): ' +str(Errors) if not Errors: return 1 else: return 0