def getFromAmarok(self): try: import Amarok Dialogs.showState(translate("CoverTable", "Checking For Amarok..."), 0, 1) if Amarok.checkAmarok(): from Amarok import Operations directoriesAndValues = Operations.getDirectoriesAndValues() Dialogs.showState(translate("CoverTable", "Values Are Being Processed"), 1, 1) if directoriesAndValues is not None: for rowNo in range(self.rowCount()): if (getMainWindow().checkHiddenColumn("sourceCover") and getMainWindow().checkHiddenColumn("destinationCover")): if self.isChangeableItem(rowNo, "sourceCover"): directoryPath = fu.joinPath( fu.getDirName(fu.getDirName(self.values[rowNo]["path"])), str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text())) if directoryPath in directoriesAndValues: directoryAndValues = directoriesAndValues[directoryPath] self.item(rowNo, 3).setText( directoryAndValues["coverPath"][0].replace(directoryPath, ".")) self.item(rowNo, 4).setText("./" + Organizer.getIconName( directoryAndValues["artist"][0], directoryAndValues["album"][0], directoryAndValues["genre"][0], directoryAndValues["year"][0])) except: ReportBug.ReportBug()
def getFromAmarok(self): try: import Amarok Dialogs.showState( translate("CoverTable", "Checking For Amarok..."), 0, 1) if Amarok.checkAmarok(): from Amarok import Operations directoriesAndValues = Operations.getDirectoriesAndValues() Dialogs.showState( translate("CoverTable", "Values Are Being Processed"), 1, 1) if directoriesAndValues is not None: for rowNo in range(self.rowCount()): if (getMainWindow().checkHiddenColumn("sourceCover") and getMainWindow().checkHiddenColumn( "destinationCover")): if self.isChangeableItem(rowNo, "sourceCover"): directoryPath = fu.joinPath( fu.getDirName( fu.getDirName( self.values[rowNo]["path"])), str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text())) if directoryPath in directoriesAndValues: directoryAndValues = directoriesAndValues[ directoryPath] self.item(rowNo, 3).setText( directoryAndValues["coverPath"] [0].replace(directoryPath, ".")) self.item(rowNo, 4).setText( "./" + Organizer.getIconName( directoryAndValues["artist"][0], directoryAndValues["album"][0], directoryAndValues["genre"][0], directoryAndValues["year"][0])) except: ReportBug.ReportBug()
def refreshTable(self, _path): self.values = [] uni.startThreadAction() import Amarok Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1) if Amarok.checkAmarok(): isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: from Amarok import Operations directoriesAndValues = Operations.getDirectoriesAndValues(uni.MySettings[self.amarokFilterKeyName]) Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1) isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: if directoriesAndValues is not None: allItemNumber = len(directoriesAndValues) self.setRowCount(allItemNumber) rowNo = 0 for dirPath, dirRow in directoriesAndValues.items(): isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(dirPath, False, True) and fu.isReadableFileOrDir( fu.joinPath(dirPath, ".directory"), False, True): content = {} content["path"] = dirPath content["pathOfParentDirectory"] = fu.getDirName(dirPath) content["baseName"] = fu.getBaseName(dirPath) currentCover, isCorrectedFileContent = fu.getIconFromDirectory(dirPath) if currentCover is None: currentCover = "" content["currentCover"] = (currentCover) content["sourceCover"] = (dirRow["coverPath"][0].replace(dirPath, ".")) content["destinationCover"] = ("./" + Organizer.getIconName( dirRow["artist"][0], dirRow["album"][0], dirRow["genre"][0], dirRow["year"][0])) content["flagColor"] = {} if isCorrectedFileContent is False: content["flagColor"]["currentCover"] = 255, 163, 163 if fu.isFile(content["sourceCover"]) is False: content["flagColor"]["sourceCover"] = 255, 163, 163 self.values.append(content) newPathOfParentDirectory = Organizer.emend( self.values[rowNo]["pathOfParentDirectory"], "directory") self.createItem(rowNo, "pathOfParentDirectory", newPathOfParentDirectory, self.values[rowNo]["pathOfParentDirectory"]) newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "directory") self.createItem(rowNo, "pathOfParentDirectory", newBaseName, self.values[rowNo]["baseName"]) newCurrentCover = fu.getShortPath(self.values[rowNo]["currentCover"], self.values[rowNo]["path"]) itemCurrentCover = self.createItem(rowNo, "currentCover", newCurrentCover, newCurrentCover, True) self.setItemColor(itemCurrentCover, rowNo, 2, "currentCover") newSourceCover = fu.getShortPath(self.values[rowNo]["sourceCover"], self.values[rowNo]["path"]) itemSourceCover = self.createItem(rowNo, "sourceCover", newSourceCover, fu.getShortPath( self.values[rowNo]["currentCover"], self.values[rowNo]["path"])) self.setItemColor(itemSourceCover, rowNo, 3, "sourceCover") newDestinationCover = Organizer.emend( fu.getShortPath(self.values[rowNo]["destinationCover"], self.values[rowNo]["path"]), "file") itemDestinationCover = self.createItem(rowNo, "destinationCover", newDestinationCover, fu.getShortPath( self.values[rowNo]["currentCover"], self.values[rowNo]["path"])) self.setItemColor(itemDestinationCover, rowNo, 4, "destinationCover") rowNo += 1 else: allItemNumber -= 1 except: ReportBug.ReportBug() allItemNumber -= 1 else: allItemNumber = rowNo Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True) if isContinueThreadAction is False: break uni.finishThreadAction() self.setRowCount(len(self.values)) # In case of Non Readable Files and Canceled process
def refreshTable(self, _path): self.values = [] uni.startThreadAction() import Amarok Dialogs.showState( translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1) if Amarok.checkAmarok(): isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: from Amarok import Operations directoriesAndValues = Operations.getDirectoriesAndValues( uni.MySettings[self.amarokFilterKeyName]) Dialogs.showState( translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1) isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: if directoriesAndValues is not None: allItemNumber = len(directoriesAndValues) self.setRowCount(allItemNumber) rowNo = 0 for dirPath, dirRow in directoriesAndValues.items(): isContinueThreadAction = uni.isContinueThreadAction( ) if isContinueThreadAction: try: if fu.isReadableFileOrDir( dirPath, False, True) and fu.isReadableFileOrDir( fu.joinPath( dirPath, ".directory"), False, True): content = {} content["path"] = dirPath content[ "pathOfParentDirectory"] = fu.getDirName( dirPath) content["baseName"] = fu.getBaseName( dirPath) currentCover, isCorrectedFileContent = fu.getIconFromDirectory( dirPath) if currentCover is None: currentCover = "" content["currentCover"] = ( currentCover) content["sourceCover"] = ( dirRow["coverPath"][0].replace( dirPath, ".")) content["destinationCover"] = ( "./" + Organizer.getIconName( dirRow["artist"][0], dirRow["album"][0], dirRow["genre"][0], dirRow["year"][0])) content["flagColor"] = {} if isCorrectedFileContent is False: content["flagColor"][ "currentCover"] = 255, 163, 163 if fu.isFile(content["sourceCover"] ) is False: content["flagColor"][ "sourceCover"] = 255, 163, 163 self.values.append(content) newPathOfParentDirectory = Organizer.emend( self.values[rowNo] ["pathOfParentDirectory"], "directory") self.createItem( rowNo, "pathOfParentDirectory", newPathOfParentDirectory, self.values[rowNo] ["pathOfParentDirectory"]) newBaseName = Organizer.emend( self.values[rowNo]["baseName"], "directory") self.createItem( rowNo, "pathOfParentDirectory", newBaseName, self.values[rowNo]["baseName"]) newCurrentCover = fu.getShortPath( self.values[rowNo]["currentCover"], self.values[rowNo]["path"]) itemCurrentCover = self.createItem( rowNo, "currentCover", newCurrentCover, newCurrentCover, True) self.setItemColor( itemCurrentCover, rowNo, 2, "currentCover") newSourceCover = fu.getShortPath( self.values[rowNo]["sourceCover"], self.values[rowNo]["path"]) itemSourceCover = self.createItem( rowNo, "sourceCover", newSourceCover, fu.getShortPath( self.values[rowNo] ["currentCover"], self.values[rowNo]["path"])) self.setItemColor( itemSourceCover, rowNo, 3, "sourceCover") newDestinationCover = Organizer.emend( fu.getShortPath( self.values[rowNo] ["destinationCover"], self.values[rowNo]["path"]), "file") itemDestinationCover = self.createItem( rowNo, "destinationCover", newDestinationCover, fu.getShortPath( self.values[rowNo] ["currentCover"], self.values[rowNo]["path"])) self.setItemColor( itemDestinationCover, rowNo, 4, "destinationCover") rowNo += 1 else: allItemNumber -= 1 except: ReportBug.ReportBug() allItemNumber -= 1 else: allItemNumber = rowNo Dialogs.showState( translate("Tables", "Generating Table..."), rowNo, allItemNumber, True) if isContinueThreadAction is False: break uni.finishThreadAction() self.setRowCount(len( self.values)) # In case of Non Readable Files and Canceled process