From 9807a344dd17ced716f548a35664e8706dadcf6d Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Mon, 20 Oct 2025 09:47:21 -0400 Subject: [PATCH] fix loading bug when songs dont parse --- libs/song_hash.py | 23 ++++++++++++----------- scenes/song_select.py | 5 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libs/song_hash.py b/libs/song_hash.py index 69f88a7..cd6a54f 100644 --- a/libs/song_hash.py +++ b/libs/song_hash.py @@ -114,18 +114,19 @@ def build_song_hashes(output_dir=Path("cache")): tja = TJAParser(tja_path) all_notes = NoteList() diff_hashes = dict() - - try: - for diff in tja.metadata.course_data: - diff_notes, _, _, _ = TJAParser.notes_to_position(TJAParser(tja.file_path), diff) - diff_hashes[diff] = tja.hash_note_data(diff_notes) - all_notes.play_notes.extend(diff_notes.play_notes) - all_notes.bars.extend(diff_notes.bars) - except Exception as e: - print(f"Failed to parse TJA {tja_path}: {e}") - continue - if all_notes == []: + try: + for diff in tja.metadata.course_data: + diff_notes, _, _, _ = TJAParser.notes_to_position(TJAParser(tja.file_path), diff) + diff_hashes[diff] = tja.hash_note_data(diff_notes) + all_notes.play_notes.extend(diff_notes.play_notes) + all_notes.bars.extend(diff_notes.bars) + except Exception as e: + print(f"Failed to parse TJA {tja_path}: {e}") + continue + + if all_notes == NoteList(): + print(tja_path) continue hash_val = tja.hash_note_data(all_notes) diff --git a/scenes/song_select.py b/scenes/song_select.py index ec875bc..ccc8109 100644 --- a/scenes/song_select.py +++ b/scenes/song_select.py @@ -1939,7 +1939,7 @@ class FileNavigator: # Create SongFile objects for tja_path in sorted(tja_files): song_key = str(tja_path) - if song_key not in self.all_song_files: + if song_key not in self.all_song_files and tja_path in global_data.song_paths: song_obj = SongFile(tja_path, tja_path.name, texture_index) song_obj.box.get_scores() for course in song_obj.tja.metadata.course_data: @@ -1970,7 +1970,8 @@ class FileNavigator: self.new_items.append(SongFile(tja_path, tja_path.name, SongBox.DEFAULT_INDEX, name_texture_index=texture_index)) self.all_song_files[song_key] = song_obj - content_items.append(self.all_song_files[song_key]) + if song_key in self.all_song_files: + content_items.append(self.all_song_files[song_key]) self.directory_contents[dir_key] = content_items self.crown_cache_dirty.add(dir_key)