From b07e647c40303e179e16db7be647d477b43ae563 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:42:32 +0000 Subject: [PATCH 2/3] Fix M3U generation to only include .cue files when present in bin/cue ROM packages Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com> --- backend/endpoints/roms/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/endpoints/roms/__init__.py b/backend/endpoints/roms/__init__.py index 1008d6847..34fe6cffe 100644 --- a/backend/endpoints/roms/__init__.py +++ b/backend/endpoints/roms/__init__.py @@ -953,8 +953,14 @@ async def get_rom_content( # Add M3U file if not already present if not rom.has_m3u_file(): + # If .cue files are present, only list those in the M3U + # (avoids invalid entries like raw .bin tracks) + cue_files = [ + f for f in files if f.file_extension.lower() == "cue" + ] + m3u_files = cue_files if cue_files else files m3u_encoded_content = "\n".join( - [f.file_name_for_download(hidden_folder) for f in files] + [f.file_name_for_download(hidden_folder) for f in m3u_files] ).encode() m3u_filename = f"{rom.fs_name}.m3u" m3u_info = ZipInfo( @@ -996,8 +1002,12 @@ async def get_rom_content( ] if not rom.has_m3u_file(): + # If .cue files are present, only list those in the M3U + # (avoids invalid entries like raw .bin tracks) + cue_files = [f for f in files if f.file_extension.lower() == "cue"] + m3u_files = cue_files if cue_files else files m3u_encoded_content = "\n".join( - [f.file_name_for_download(hidden_folder) for f in files] + [f.file_name_for_download(hidden_folder) for f in m3u_files] ).encode() m3u_base64_content = b64encode(m3u_encoded_content).decode() m3u_line = ZipContentLine( From 8a76391935473c3ee46757b5c3a38ea57b004363 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 9 Mar 2026 18:21:01 -0400 Subject: [PATCH 3/3] do code once --- backend/endpoints/roms/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backend/endpoints/roms/__init__.py b/backend/endpoints/roms/__init__.py index 34fe6cffe..cae81edc3 100644 --- a/backend/endpoints/roms/__init__.py +++ b/backend/endpoints/roms/__init__.py @@ -905,6 +905,11 @@ async def get_rom_content( f"User {hl(current_username, color=BLUE)} is downloading {hl(rom.fs_name)}" ) + # If .cue files are present, only list those in the M3U + # (avoids invalid entries like raw .bin tracks) + cue_files = [f for f in files if f.file_extension.lower() == "cue"] + m3u_files = cue_files if cue_files else files + # Serve the file directly in development mode for emulatorjs if DEV_MODE: if len(files) == 1: @@ -953,12 +958,6 @@ async def get_rom_content( # Add M3U file if not already present if not rom.has_m3u_file(): - # If .cue files are present, only list those in the M3U - # (avoids invalid entries like raw .bin tracks) - cue_files = [ - f for f in files if f.file_extension.lower() == "cue" - ] - m3u_files = cue_files if cue_files else files m3u_encoded_content = "\n".join( [f.file_name_for_download(hidden_folder) for f in m3u_files] ).encode() @@ -1002,10 +1001,6 @@ async def get_rom_content( ] if not rom.has_m3u_file(): - # If .cue files are present, only list those in the M3U - # (avoids invalid entries like raw .bin tracks) - cue_files = [f for f in files if f.file_extension.lower() == "cue"] - m3u_files = cue_files if cue_files else files m3u_encoded_content = "\n".join( [f.file_name_for_download(hidden_folder) for f in m3u_files] ).encode()