def refreshTable(self, _path): self.values = [] fileAndDirectoryNames = fu.readDirectory(_path, "fileAndDirectory", uni.getBoolValue("isShowHiddensInFolderTable")) allItemNumber = len(fileAndDirectoryNames) uni.startThreadAction() baseNameOfDirectory = fu.getBaseName(_path) rowNo = 0 self.setRowCount(allItemNumber) for baseName in fileAndDirectoryNames: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True): details = fu.getExtendedDetails(fu.joinPath(_path, baseName)) content = {} content["path"] = fu.joinPath(_path, baseName) content["baseNameOfDirectory"] = baseNameOfDirectory content["baseName"] = baseName content.update(details) self.values.append(content) newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, content["baseNameOfDirectory"]) newBaseName = Organizer.emend(content["baseName"], fu.getObjectType(self.values[rowNo]["path"])) self.createItem(rowNo, "baseName", newBaseName, content["baseName"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) if not uni.isWindows: self.createItem(rowNo, "accessRights", content["accessRights"]) self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"]) self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"]) self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"]) 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 = [] allFilesAndDirectories = fu.readDirectoryWithSubDirectoriesThread(_path, int(uni.MySettings["subDirectoryDeep"]), "file", uni.getBoolValue( "isShowHiddensInSubFolderTable")) allItemNumber = len(allFilesAndDirectories) uni.startThreadAction() rowNo = 0 self.setRowCount(allItemNumber) for baseName in allFilesAndDirectories: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(baseName, False, True): details = fu.getExtendedDetails(fu.joinPath(_path, baseName)) content = {} content["path"] = baseName content["baseNameOfDirectory"] = str( str(fu.getBaseName(_path)) + str(fu.getDirName(baseName)).replace(_path, "")) content["baseName"] = fu.getBaseName(baseName) content.update(details) self.values.append(content) newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, content["baseNameOfDirectory"]) newBaseName = Organizer.emend(content["baseName"], "file") self.createItem(rowNo, "baseName", newBaseName, content["baseName"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) if not uni.isWindows: self.createItem(rowNo, "accessRights", content["accessRights"]) self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"]) self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"]) self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"]) 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 = [] self.setColumnWidth(6, 70) self.setColumnWidth(7, 40) 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 musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames( uni.MySettings[self.amarokFilterKeyName]) Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1) isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: if musicFileValuesWithNames is not None: allItemNumber = len(musicFileValuesWithNames) self.setRowCount(allItemNumber) rowNo = 0 for musicFileRow in musicFileValuesWithNames: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if (fu.isFile(musicFileRow["filePath"]) and fu.isReadableFileOrDir(musicFileRow["filePath"], False, True)): details = fu.getDetails(musicFileRow["filePath"]) content = {} if Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Amarok (Smart)": content["path"] = musicFileRow["filePath"] content["baseNameOfDirectory"] = fu.getBaseName( fu.getDirName(musicFileRow["filePath"])) content["baseName"] = fu.getBaseName(musicFileRow["filePath"]) content["artist"] = musicFileRow["artist"] content["title"] = musicFileRow["title"] content["album"] = musicFileRow["album"] content["albumArtist"] = musicFileRow["albumArtist"] content["trackNum"] = musicFileRow["trackNumber"] content["year"] = musicFileRow["year"] content["genre"] = musicFileRow["genre"] content["firstComment"] = musicFileRow["comment"] content["firstLyrics"] = musicFileRow["lyrics"] tagger = Taggers.getTagger() try: tagger.loadFile(musicFileRow["filePath"]) except: if tagger.isSupportInfo: content["length"] = "" content["bitrate"] = "" content["sampleRate"] = "" content["mode"] = "" else: if content["artist"].strip() == "": content["artist"] = tagger.getArtist() if content["title"].strip() == "": content["title"] = tagger.getTitle() if content["album"].strip() == "": content["album"] = tagger.getAlbum() if content["albumArtist"].strip() == "": content["albumArtist"] = tagger.getAlbumArtist() if str(content["trackNum"]).strip() == "": content["trackNum"] = tagger.getTrackNum() if str(content["year"]).strip() == "": content["year"] = tagger.getYear() if content["genre"].strip() == "": content["genre"] = tagger.getGenre() if content["firstComment"].strip() == "": content["firstComment"] = tagger.getFirstComment() if content["firstLyrics"].strip() == "": content["firstLyrics"] = tagger.getFirstLyrics() if tagger.isSupportInfo: content["length"] = tagger.getLength() content["bitrate"] = tagger.getBitrate() content["sampleRate"] = tagger.getSampleRate() content["mode"] = tagger.getMode() elif Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Only Amarok": content["path"] = musicFileRow["filePath"] content["baseNameOfDirectory"] = "" content["baseName"] = fu.getBaseName(musicFileRow["filePath"]) content["artist"] = musicFileRow["artist"] content["title"] = musicFileRow["title"] content["album"] = musicFileRow["album"] content["albumArtist"] = musicFileRow["albumArtist"] content["trackNum"] = musicFileRow["trackNumber"] content["year"] = musicFileRow["year"] content["genre"] = musicFileRow["genre"] content["firstComment"] = musicFileRow["comment"] content["firstLyrics"] = musicFileRow["lyrics"] tagger = Taggers.getTagger() if tagger.isSupportInfo: try: tagger.loadFile(musicFileRow["filePath"]) except: content["length"] = "" content["bitrate"] = "" content["sampleRate"] = "" content["mode"] = "" else: content["length"] = tagger.getLength() content["bitrate"] = tagger.getBitrate() content["sampleRate"] = tagger.getSampleRate() content["mode"] = tagger.getMode() else: tagger = Taggers.getTagger() try: tagger.loadFile(musicFileRow["filePath"]) except: Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"), str(translate("FileUtils/Musics", "\"%s\" : this file has the incorrect tag so can't read tags.") ) % Organizer.getLink(musicFileRow["filePath"])) content["path"] = musicFileRow["filePath"] content["baseNameOfDirectory"] = "" content["baseName"] = fu.getBaseName(musicFileRow["filePath"]) content["artist"] = tagger.getArtist() content["title"] = tagger.getTitle() content["album"] = tagger.getAlbum() content["albumArtist"] = tagger.getAlbumArtist() content["trackNum"] = tagger.getTrackNum() content["year"] = tagger.getYear() content["genre"] = tagger.getGenre() content["firstComment"] = tagger.getFirstComment() content["firstLyrics"] = tagger.getFirstLyrics() if tagger.isSupportInfo: content["length"] = tagger.getLength() content["bitrate"] = tagger.getBitrate() content["sampleRate"] = tagger.getSampleRate() content["mode"] = tagger.getMode() content["size"] = details[stat.ST_SIZE] content["lastAccessed"] = details[stat.ST_ATIME] content["lastModified"] = details[stat.ST_MTIME] content["lastMetadataChanged"] = details[stat.ST_CTIME] self.values.append(content) newBaseNameOfDirectory = Organizer.emend( self.values[rowNo]["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, self.values[rowNo]["baseNameOfDirectory"]) newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file") self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"]) newArtist = Organizer.emend(self.values[rowNo]["artist"]) self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"]) newTitle = Organizer.emend(self.values[rowNo]["title"]) self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"]) newAlbum = Organizer.emend(self.values[rowNo]["album"]) self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"]) newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"]) self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"]) newTrackNum = str(self.values[rowNo]["trackNum"]) self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"]) newYear = Organizer.emend(self.values[rowNo]["year"]) self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"]) newGenre = Organizer.emend(self.values[rowNo]["genre"]) self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"]) newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"]) self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"]) newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"]) self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"]) if Taggers.getTagger().isSupportInfo: self.createItem(rowNo, "length", content["length"]) self.createItem(rowNo, "bitrate", content["bitrate"]) self.createItem(rowNo, "sampleRate", content["sampleRate"]) self.createItem(rowNo, "mode", content["mode"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) 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 = [] self.setColumnWidth(6, 70) self.setColumnWidth(7, 40) 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 musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames( uni.MySettings[self.amarokFilterKeyName]) Dialogs.showState( translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1) isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: if musicFileValuesWithNames is not None: allItemNumber = len(musicFileValuesWithNames) self.setRowCount(allItemNumber) rowNo = 0 for musicFileRow in musicFileValuesWithNames: isContinueThreadAction = uni.isContinueThreadAction( ) if isContinueThreadAction: try: if (fu.isFile(musicFileRow["filePath"]) and fu.isReadableFileOrDir( musicFileRow["filePath"], False, True)): details = fu.getDetails( musicFileRow["filePath"]) content = {} if Amarok.getSelectedTagSourseType( "AmarokMusicTable" ) == "Amarok (Smart)": content["path"] = musicFileRow[ "filePath"] content[ "baseNameOfDirectory"] = fu.getBaseName( fu.getDirName(musicFileRow[ "filePath"])) content[ "baseName"] = fu.getBaseName( musicFileRow["filePath"]) content["artist"] = musicFileRow[ "artist"] content["title"] = musicFileRow[ "title"] content["album"] = musicFileRow[ "album"] content[ "albumArtist"] = musicFileRow[ "albumArtist"] content["trackNum"] = musicFileRow[ "trackNumber"] content["year"] = musicFileRow[ "year"] content["genre"] = musicFileRow[ "genre"] content[ "firstComment"] = musicFileRow[ "comment"] content[ "firstLyrics"] = musicFileRow[ "lyrics"] tagger = Taggers.getTagger() try: tagger.loadFile( musicFileRow["filePath"]) except: if tagger.isSupportInfo: content["length"] = "" content["bitrate"] = "" content["sampleRate"] = "" content["mode"] = "" else: if content["artist"].strip( ) == "": content[ "artist"] = tagger.getArtist( ) if content["title"].strip( ) == "": content[ "title"] = tagger.getTitle( ) if content["album"].strip( ) == "": content[ "album"] = tagger.getAlbum( ) if content[ "albumArtist"].strip( ) == "": content[ "albumArtist"] = tagger.getAlbumArtist( ) if str(content["trackNum"] ).strip() == "": content[ "trackNum"] = tagger.getTrackNum( ) if str(content["year"]).strip( ) == "": content[ "year"] = tagger.getYear( ) if content["genre"].strip( ) == "": content[ "genre"] = tagger.getGenre( ) if content[ "firstComment"].strip( ) == "": content[ "firstComment"] = tagger.getFirstComment( ) if content[ "firstLyrics"].strip( ) == "": content[ "firstLyrics"] = tagger.getFirstLyrics( ) if tagger.isSupportInfo: content[ "length"] = tagger.getLength( ) content[ "bitrate"] = tagger.getBitrate( ) content[ "sampleRate"] = tagger.getSampleRate( ) content[ "mode"] = tagger.getMode( ) elif Amarok.getSelectedTagSourseType( "AmarokMusicTable" ) == "Only Amarok": content["path"] = musicFileRow[ "filePath"] content[ "baseNameOfDirectory"] = fu.getBaseName( fu.getDirName(musicFileRow[ "filePath"])) content[ "baseName"] = fu.getBaseName( musicFileRow["filePath"]) content["artist"] = musicFileRow[ "artist"] content["title"] = musicFileRow[ "title"] content["album"] = musicFileRow[ "album"] content[ "albumArtist"] = musicFileRow[ "albumArtist"] content["trackNum"] = musicFileRow[ "trackNumber"] content["year"] = musicFileRow[ "year"] content["genre"] = musicFileRow[ "genre"] content[ "firstComment"] = musicFileRow[ "comment"] content[ "firstLyrics"] = musicFileRow[ "lyrics"] tagger = Taggers.getTagger() if tagger.isSupportInfo: try: tagger.loadFile( musicFileRow[ "filePath"]) except: content["length"] = "" content["bitrate"] = "" content["sampleRate"] = "" content["mode"] = "" else: content[ "length"] = tagger.getLength( ) content[ "bitrate"] = tagger.getBitrate( ) content[ "sampleRate"] = tagger.getSampleRate( ) content[ "mode"] = tagger.getMode( ) else: tagger = Taggers.getTagger() try: tagger.loadFile( musicFileRow["filePath"]) except: Dialogs.showError( translate( "FileUtils/Musics", "Incorrect Tag"), str( translate( "FileUtils/Musics", "\"%s\" : this file has the incorrect tag so can't read tags." )) % Organizer.getLink( musicFileRow[ "filePath"])) content["path"] = musicFileRow[ "filePath"] content[ "baseNameOfDirectory"] = fu.getBaseName( fu.getDirName(musicFileRow[ "filePath"])) content[ "baseName"] = fu.getBaseName( musicFileRow["filePath"]) content[ "artist"] = tagger.getArtist() content["title"] = tagger.getTitle( ) content["album"] = tagger.getAlbum( ) content[ "albumArtist"] = tagger.getAlbumArtist( ) content[ "trackNum"] = tagger.getTrackNum( ) content["year"] = tagger.getYear() content["genre"] = tagger.getGenre( ) content[ "firstComment"] = tagger.getFirstComment( ) content[ "firstLyrics"] = tagger.getFirstLyrics( ) if tagger.isSupportInfo: content[ "length"] = tagger.getLength( ) content[ "bitrate"] = tagger.getBitrate( ) content[ "sampleRate"] = tagger.getSampleRate( ) content[ "mode"] = tagger.getMode() content["size"] = details[stat.ST_SIZE] content["lastAccessed"] = details[ stat.ST_ATIME] content["lastModified"] = details[ stat.ST_MTIME] content[ "lastMetadataChanged"] = details[ stat.ST_CTIME] self.values.append(content) newBaseNameOfDirectory = Organizer.emend( self.values[rowNo] ["baseNameOfDirectory"], "directory") self.createItem( rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, self.values[rowNo] ["baseNameOfDirectory"]) newBaseName = Organizer.emend( self.values[rowNo]["baseName"], "file") self.createItem( rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"]) newArtist = Organizer.emend( self.values[rowNo]["artist"]) self.createItem( rowNo, "artist", newArtist, self.values[rowNo]["artist"]) newTitle = Organizer.emend( self.values[rowNo]["title"]) self.createItem( rowNo, "title", newTitle, self.values[rowNo]["title"]) newAlbum = Organizer.emend( self.values[rowNo]["album"]) self.createItem( rowNo, "album", newAlbum, self.values[rowNo]["album"]) newAlbumArtist = Organizer.emend( self.values[rowNo]["albumArtist"]) self.createItem( rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"]) newTrackNum = str( self.values[rowNo]["trackNum"]) self.createItem( rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"]) newYear = Organizer.emend( self.values[rowNo]["year"]) self.createItem( rowNo, "year", newYear, self.values[rowNo]["year"]) newGenre = Organizer.emend( self.values[rowNo]["genre"]) self.createItem( rowNo, "genre", newGenre, self.values[rowNo]["genre"]) newFirstComment = Organizer.emend( self.values[rowNo]["firstComment"]) self.createItem( rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"]) newFirstLyrics = Organizer.emend( self.values[rowNo]["firstLyrics"]) self.createItem( rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"]) if Taggers.getTagger().isSupportInfo: self.createItem( rowNo, "length", content["length"]) self.createItem( rowNo, "bitrate", content["bitrate"]) self.createItem( rowNo, "sampleRate", content["sampleRate"]) self.createItem( rowNo, "mode", content["mode"]) self.createItem( rowNo, "size", Organizer.getCorrectedFileSize( content["size"])) self.createItem( rowNo, "lastAccessed", Organizer.getCorrectedTime( content["lastAccessed"])) self.createItem( rowNo, "lastModified", Organizer.getCorrectedTime( content["lastModified"])) self.createItem( rowNo, "lastMetadataChanged", Organizer.getCorrectedTime( content["lastMetadataChanged"]) ) 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 = [] self.setColumnWidth(6, 70) self.setColumnWidth(7, 40) musicFileNames = fu.readDirectoryWithSubDirectoriesThread(_path, int(uni.MySettings["subDirectoryDeep"]), "music", uni.getBoolValue( "isShowHiddensInSubFolderMusicTable")) isCanNoncompatible = False allItemNumber = len(musicFileNames) uni.startThreadAction() rowNo = 0 self.setRowCount(allItemNumber) for filePath in musicFileNames: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(filePath, False, True): tagger = Taggers.getTagger() try: tagger.loadFile(filePath) except: Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"), str(translate("FileUtils/Musics", "\"%s\" : this file has the incorrect tag so can't read tags.") ) % Organizer.getLink(filePath)) if tagger.isAvailableFile() is False: isCanNoncompatible = True details = fu.getDetails(filePath) content = {} content["path"] = filePath content["baseNameOfDirectory"] = str( str(fu.getBaseName(_path)) + str(fu.getDirName(filePath)).replace(_path, "")) content["baseName"] = fu.getBaseName(filePath) content["artist"] = tagger.getArtist() content["title"] = tagger.getTitle() content["album"] = tagger.getAlbum() content["albumArtist"] = tagger.getAlbumArtist() content["trackNum"] = tagger.getTrackNum() content["year"] = tagger.getYear() content["genre"] = tagger.getGenre() content["firstComment"] = tagger.getFirstComment() content["firstLyrics"] = tagger.getFirstLyrics() if tagger.isSupportInfo: content["length"] = tagger.getLength() content["bitrate"] = tagger.getBitrate() content["sampleRate"] = tagger.getSampleRate() content["mode"] = tagger.getMode() content["size"] = details[stat.ST_SIZE] content["lastAccessed"] = details[stat.ST_ATIME] content["lastModified"] = details[stat.ST_MTIME] content["lastMetadataChanged"] = details[stat.ST_CTIME] self.values.append(content) newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, self.values[rowNo]["baseNameOfDirectory"]) newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file") self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"]) newArtist = Organizer.emend(self.values[rowNo]["artist"]) self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"]) newTitle = Organizer.emend(self.values[rowNo]["title"]) self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"]) newAlbum = Organizer.emend(self.values[rowNo]["album"]) self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"]) newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"]) self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"]) newTrackNum = str(self.values[rowNo]["trackNum"]) self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"]) newYear = Organizer.emend(self.values[rowNo]["year"]) self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"]) newGenre = Organizer.emend(self.values[rowNo]["genre"]) self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"]) newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"]) self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"]) newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"]) self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"]) if tagger.isSupportInfo: self.createItem(rowNo, "length", content["length"]) self.createItem(rowNo, "bitrate", content["bitrate"]) self.createItem(rowNo, "sampleRate", content["sampleRate"]) self.createItem(rowNo, "mode", content["mode"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) 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 if isCanNoncompatible: Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"), translate("FileUtils/Musics", "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))
def refreshTable(self, _path): self.values = [] self.setColumnWidth(6, 70) self.setColumnWidth(7, 40) musicFileNames = fu.readDirectory(_path, "music", uni.getBoolValue("isShowHiddensInMusicTable")) isCanNoncompatible = False allItemNumber = len(musicFileNames) uni.startThreadAction() baseNameOfDirectory = fu.getBaseName(_path) rowNo = 0 self.setRowCount(allItemNumber) for baseName in musicFileNames: isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True): tagger = Taggers.getTagger() try: tagger.loadFile(fu.joinPath(_path, baseName)) except: Dialogs.showError(translate("FileUtils/Musics", "Incorrect Tag"), str(translate("FileUtils/Musics", "\"%s\" : this file has the incorrect tag so can't read tags.") ) % Organizer.getLink(fu.joinPath(_path, baseName))) if tagger.isAvailableFile() is False: isCanNoncompatible = True details = fu.getDetails(fu.joinPath(_path, baseName)) content = {} content["path"] = fu.joinPath(_path, baseName) content["baseNameOfDirectory"] = baseNameOfDirectory content["baseName"] = baseName content["artist"] = tagger.getArtist() content["title"] = tagger.getTitle() content["album"] = tagger.getAlbum() content["albumArtist"] = tagger.getAlbumArtist() content["trackNum"] = tagger.getTrackNum() content["year"] = tagger.getYear() content["genre"] = tagger.getGenre() content["firstComment"] = tagger.getFirstComment() content["firstLyrics"] = tagger.getFirstLyrics() if tagger.isSupportInfo: content["length"] = tagger.getLength() content["bitrate"] = tagger.getBitrate() content["sampleRate"] = tagger.getSampleRate() content["mode"] = tagger.getMode() content["size"] = details[stat.ST_SIZE] content["lastAccessed"] = details[stat.ST_ATIME] content["lastModified"] = details[stat.ST_MTIME] content["lastMetadataChanged"] = details[stat.ST_CTIME] self.values.append(content) newBaseNameOfDirectory = Organizer.emend(self.values[rowNo]["baseNameOfDirectory"], "directory") self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory, self.values[rowNo]["baseNameOfDirectory"]) newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "file") self.createItem(rowNo, "baseName", newBaseName, self.values[rowNo]["baseName"]) newArtist = Organizer.emend(self.values[rowNo]["artist"]) self.createItem(rowNo, "artist", newArtist, self.values[rowNo]["artist"]) newTitle = Organizer.emend(self.values[rowNo]["title"]) self.createItem(rowNo, "title", newTitle, self.values[rowNo]["title"]) newAlbum = Organizer.emend(self.values[rowNo]["album"]) self.createItem(rowNo, "album", newAlbum, self.values[rowNo]["album"]) newAlbumArtist = Organizer.emend(self.values[rowNo]["albumArtist"]) self.createItem(rowNo, "albumArtist", newAlbumArtist, self.values[rowNo]["albumArtist"]) newTrackNum = str(self.values[rowNo]["trackNum"]) self.createItem(rowNo, "trackNum", newTrackNum, self.values[rowNo]["trackNum"]) newYear = Organizer.emend(self.values[rowNo]["year"]) self.createItem(rowNo, "year", newYear, self.values[rowNo]["year"]) newGenre = Organizer.emend(self.values[rowNo]["genre"]) self.createItem(rowNo, "genre", newGenre, self.values[rowNo]["genre"]) newFirstComment = Organizer.emend(self.values[rowNo]["firstComment"]) self.createItem(rowNo, "firstComment", newFirstComment, self.values[rowNo]["firstComment"]) newFirstLyrics = Organizer.emend(self.values[rowNo]["firstLyrics"]) self.createItem(rowNo, "firstLyrics", newFirstLyrics, self.values[rowNo]["firstLyrics"]) if tagger.isSupportInfo: self.createItem(rowNo, "length", content["length"]) self.createItem(rowNo, "bitrate", content["bitrate"]) self.createItem(rowNo, "sampleRate", content["sampleRate"]) self.createItem(rowNo, "mode", content["mode"]) self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"])) self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"])) self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"])) self.createItem(rowNo, "lastMetadataChanged", Organizer.getCorrectedTime(content["lastMetadataChanged"])) 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 if isCanNoncompatible: Dialogs.show(translate("FileUtils/Musics", "Possible ID3 Mismatch"), translate("FileUtils/Musics", "Some of the files presented in the table may not support ID3 technology.<br>Please check the files and make sure they support ID3 information before proceeding."))