| from pathlib import Path | |
| import pandas as pd | |
| import shutil | |
| metadata = pd.read_csv("gaps_metadata.csv") | |
| audio_files = list(Path("./audio").glob("*.wav")) | |
| midi_files = list(Path("./midi").glob("*-fine-aligned.mid")) | |
| syncpoint_files = list(Path("./syncpoints").glob("*-syncpoints.json")) | |
| xml_files = list(Path("./musicxml").glob("*.xml")) | |
| match_files = list(Path("./match").glob("*.match")) | |
| row_dicts = [r[1].to_dict() for r in metadata.iterrows()] | |
| for row in row_dicts: | |
| scorehash = row["scorehash"] | |
| target_audio_path = row["audio_path"] | |
| target_midi_path = row["midi_path"] | |
| target_syncpoint_path = f"syncpoints/{row['id']}.json" | |
| target_xml_path = f"musicxml/{row['id']}.xml" | |
| target_match_path = f"match/{row['id']}.match" | |
| if not Path(target_audio_path).exists(): | |
| try: | |
| source_audio_path = [a for a in audio_files if a.stem == scorehash] | |
| if len(source_audio_path) == 0: | |
| print(f"Audio not found for {scorehash}") | |
| continue | |
| else: | |
| source_audio_path = source_audio_path[0] | |
| shutil.move(str(source_audio_path), target_audio_path) | |
| except: | |
| print("audio") | |
| breakpoint() | |
| if not Path(target_midi_path).exists(): | |
| try: | |
| source_midi_path = [m for m in midi_files if m.stem.replace("-fine-aligned", "") == scorehash] | |
| if len(source_midi_path) == 0: | |
| print(f"midi not found for {scorehash}") | |
| continue | |
| else: | |
| source_midi_path = source_midi_path[0] | |
| shutil.move(str(source_midi_path), target_midi_path) | |
| except: | |
| print("midi") | |
| breakpoint() | |
| if not Path(target_syncpoint_path).exists(): | |
| try: | |
| source_syncpoint_path = [s for s in syncpoint_files if s.stem.replace("-syncpoints", "") == scorehash] | |
| if len(source_syncpoint_path) == 0: | |
| print(f"Syncpoints not found for {scorehash}") | |
| continue | |
| else: | |
| source_syncpoint_path = source_syncpoint_path[0] | |
| shutil.move(str(source_syncpoint_path), target_syncpoint_path) | |
| except: | |
| print("syncpoint") | |
| breakpoint() | |
| if not Path(target_xml_path).exists(): | |
| try: | |
| source_xml_path = [x for x in xml_files if x.stem == scorehash] | |
| if len(source_xml_path) == 0: | |
| print(f"xml not found for {scorehash}") | |
| continue | |
| else: | |
| source_xml_path = source_xml_path[0] | |
| shutil.move(str(source_xml_path), target_xml_path) | |
| except: | |
| print("xml") | |
| breakpoint() | |
| if not Path(target_match_path).exists(): | |
| try: | |
| source_match_path = [m for m in match_files if m.stem == scorehash] | |
| if len(source_match_path) == 0: | |
| continue | |
| else: | |
| source_match_path = source_audio_path[0] | |
| shutil.move(str(source_match_path), target_match_path) | |
| except: | |
| print("match") | |
| breakpoint() | |