def main(): """Main function""" # Build program config from command line and config file. config = Config.Config() warnings = [] # Recursively tranverse from the provided root directory looking for mp3s: # * dirname gives the path to the current directory # * dirnames gives the list of subdirectories in the folder # * filenames gives the list of files in the folder Progress.state(SEARCHING_STATUS_STRING) track_list = [] for dirname, subdirnames, filenames in os.walk(config.directory): # Extract and clean filenames of all mp3s cleaned_mp3_filenames = extract_mp3s_and_clean(filenames) for f in cleaned_mp3_filenames: # Extract all the information possible from the song and add it. file_path = os.path.join(dirname, f.original) new_file = TrackFile.TrackFile(file_path, f.cleaned) track_list.append(new_file) track_count = len(track_list) # create storage system music_collection = TrackCollection.TrackCollection() # Add all located files to the collection. for i in range(track_count): track_list[i].load_all_data() #print track_list[i] track_list[i].finalise_data() music_collection.add(track_list[i]) Progress.report(INDEXING_STATUS_STRING, track_count, i+1) print_warnings(warnings) # Remove all duplicate files from the collection. def progress_stub1(total_units, done_units): """Stub for encapsulating the 'processing'' formatter""" Progress.report(PROCESSING_STATUS_STRING, total_units, done_units) music_collection.remove_duplicates(warnings, progress_stub1) print_warnings(warnings) # Standardise track data on the remaining files. def progress_stub2(total_units, done_units): """Stub for encapsulating the 'standardising'' formatter""" Progress.report(STANDARDISING_STATUS_STRING, total_units, done_units) music_collection.standardise_album_tracks(warnings, progress_stub2) print_warnings(warnings) if config.verbose: music_collection.sort_songs_by_track() print music_collection if config.dry_run: Progress.skip(REWRITING_STATUS_STRING) else: print "TBD" # write the newly corrected data to a new file system with new tags #new_folder = generate_new_filepath(args.directory) #print "Creating new directory structure in %s." % (new_folder) #music_collection.create_new_filesystem(new_folder) # done print "Finished."