Skip to content

Conversation

Silverarmor
Copy link
Member

@Silverarmor Silverarmor commented Aug 16, 2025

Title

Description

  • Prevent duplicate m3u entries on detect_formats
  • Prevent IndexError when attempting to create default named m3u file with no playlist.

Related Issue

#2446
#2448

How Has This Been Tested?

Ran m3u tests

PS C:\Programming\spotify-downloader> uv run pytest .\tests\utils\test_m3u.py -vv
============================================================================================= test session starts ==============================================================================================
platform win32 -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0 -- C:\Programming\spotify-downloader\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Programming\spotify-downloader
configfile: pyproject.toml
plugins: anyio-3.7.1, pyfakefs-5.7.4, asyncio-0.21.2, cov-6.0.0, mock-3.14.0, recording-0.13.2, subprocess-1.5.3
asyncio: mode=Mode.AUTO
collected 2 items                                                                                                                                                                                                

tests/utils/test_m3u.py::test_create_m3u_content PASSED                                                                                                                                                   [ 50%]
tests/utils/test_m3u.py::test_create_m3u_file PASSED                                                                                                                                                      [100%]

============================================================================================== 2 passed in 6.50s ===============================================================================================

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests passed

@Silverarmor Silverarmor requested a review from Copilot August 16, 2025 02:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses two bugs in M3U playlist functionality: preventing duplicate entries during format detection and handling cases where an M3U filename contains list placeholders but no playlists are provided.

  • Fixes the logic in create_m3u_content to avoid duplicate entries when detecting file formats
  • Adds early exit handling in gen_m3u_files when no lists are provided but filename contains list placeholders
  • Adds logging support to provide warning messages for the error condition

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -116,6 +121,10 @@ def gen_m3u_files(
lists_object[song.list_name] = []

lists_object[song.list_name].append(song)

if not lists_object and "{list" in file_name:
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for '{list' instead of '{list}'. This will not properly detect the full placeholder pattern and may miss valid cases where the filename contains '{list}' with the closing brace.

Suggested change
if not lists_object and "{list" in file_name:
if not lists_object and "{list}" in file_name:

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional - this catches {list[0]} in this case.

@Silverarmor Silverarmor merged commit 3e29f18 into dev Aug 16, 2025
0 of 16 checks passed
@Silverarmor Silverarmor deleted the m3u-bugfixes branch August 16, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant