Skip to content

Fixed an issue where low quality M4A files were being redownloaded every time because a .flac file was expected but didn't exist. #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bradyn12
Copy link

@bradyn12 bradyn12 commented Mar 6, 2025

Root Cause

  • The quality_audio parameter was missing when calling dl.item(), causing incorrect file extension guessing.
  • The downloader always looked for .flac, even when downloading m4a (<Quality.low_96k: 'LOW'>, <Quality.low_320k: 'HIGH'>), leading to unnecessary re-downloads.

Fix

  • quality_audio is now correctly passed to dl.item(), ensuring the proper extension is used when checking for existing files.
  • The check for skip_existing now correctly looks for the expected file type.

Impact

No more unnecessary redownloading of M4A files.
skip_existing now correctly prevents duplicate downloads.

bradyn12 added 2 commits March 6, 2025 13:35
… .flac when the extension should have been m4a. It would redownload content because the .flac file didn't exist.

Previously, 'quality_audio' wasn't passed to dl.item(), causing incorrect extension guessing.
Now it's correctly included in the download function and checks for the right file path.
This PR fixes two key issues:
	1.	skip_existing Bug – Previously, file extensions were incorrectly defaulting to .flac when checking for existing downloads, causing m4a files to be redownloaded. This is now fixed by ensuring quality_audio is correctly passed to dl.item(), allowing the extension to be determined properly.
	2.	Path Sanitization Issues – The path sanitization logic was incorrectly modifying filenames, sometimes stripping out the song name or replacing it with _01. The sanitization function has been fixed to retain proper filenames while still preventing invalid characters.
Copy link
Owner

@exislow exislow left a comment

Choose a reason for hiding this comment

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

What I basically did is, I have taken you cli.py changes and applied it to the code. Unfortunately you cannot simplify the path_file_sanitize as you did. I guess, you have not done extensive testing. But no worries, maybe you can check if the bug still persists with the latest master code.

dl.item(
media_id=item_id,
media_type=media_type,
file_template=file_template,
download_delay=download_delay,
quality_audio=quality_audio,
Copy link
Owner

Choose a reason for hiding this comment

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

You are absolutely right. Thanks for this.

@@ -208,82 +208,26 @@ def get_format_template(


def path_file_sanitize(path_file: pathlib.Path, adapt: bool = False, uniquify: bool = True) -> pathlib.Path:
Copy link
Owner

Choose a reason for hiding this comment

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

This method is quite complex, and cannot be simplified like this.

It handles a lot of cases, e.g. filename shortenings and base dir changes, if the names are longer than the operating system allows.

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.

2 participants