Skip to content

Add filename extension for music files with no extension during import#6457

Merged
snejus merged 10 commits intobeetbox:masterfrom
gaotue:master
Apr 2, 2026
Merged

Add filename extension for music files with no extension during import#6457
snejus merged 10 commits intobeetbox:masterfrom
gaotue:master

Conversation

@gaotue
Copy link
Copy Markdown
Contributor

@gaotue gaotue commented Mar 22, 2026

Description

Fixes #4881.

When user imports files with no extension, ffprobe is used to check the format of the file. If its in a music format, a copy of the file is created with the detected extension and that file is imported instead of the original. If it is not a music format, it change nothing (I believe non-music files are already filtered out somewhere else in the import pipeline). If there is a file in the same directory with the same name and has the same extension as the detected format, import that file instead.

To Do

  • Documentation.
  • Changelog.
  • Tests.

@gaotue gaotue requested a review from a team as a code owner March 22, 2026 19:50
@snejus snejus requested a review from Copilot March 23, 2026 01:49
Copy link
Copy Markdown
Contributor

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

PR try fix import for files with no extension by using ffprobe to guess format, then importing file with detected extension so beets keep suffix when building destination path.

Changes:

  • Add ImportTaskFactory.check_extension() to run ffprobe on no-extension files and import a .<format> path instead.
  • Add importer tests + new test resources for “no extension” file and “not music” file.
  • Add changelog entry for 🐛4881.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
beets/importer/tasks.py Add ffprobe-based extension detection + copy/redirect import to .<ext> path.
test/test_importer.py Add tests for extension recognition, already-existing ext file, and non-music file.
test/rsrc/no_ext Add binary test resource with no extension (mp3 content).
test/rsrc/no_ext_not_music Add non-music test resource with no extension.
docs/changelog.rst Add changelog line for 🐛4881.

Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread test/test_importer.py Outdated
Comment thread test/test_importer.py
Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread test/test_importer.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Mar 23, 2026

Dear maintainers, I have fixed the issues raised by copilot and the automatic checks, which I am surprised it caught some stuff because I have resolved all issues raised by running poe lint and poe check-format locally.
Anyways, I have fixed everything that I can think of. There are still a few failing checks but they are not from the code I wrote and I don't think they are caused by my code, please let me know if I'm wrong about this. Thank you for taking time to review my PR.

@snejus
Copy link
Copy Markdown
Member

snejus commented Mar 28, 2026

Something has gone wrong with the way you merged master into your branch and confused GitHub. I'd probably suggest removing the merge commits and instead rebasing each of your commits on top of the current master.

@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Mar 28, 2026

I have synced my fork with the master branch and pasted in my changes. This should have reverted all the merge commits. Hopefully this will work now

@gaotue gaotue reopened this Mar 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 71.73913% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.02%. Comparing base (712bada) to head (e8ff69b).
⚠️ Report is 11 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beets/util/extension.py 72.09% 7 Missing and 5 partials ⚠️
beets/importer/tasks.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6457   +/-   ##
=======================================
  Coverage   70.01%   70.02%           
=======================================
  Files         146      147    +1     
  Lines       18505    18551   +46     
  Branches     3010     3024   +14     
=======================================
+ Hits        12957    12990   +33     
- Misses       4920     4927    +7     
- Partials      628      634    +6     
Files with missing lines Coverage Δ
beets/util/__init__.py 79.02% <ø> (ø)
beets/importer/tasks.py 90.73% <66.66%> (-0.14%) ⬇️
beets/util/extension.py 72.09% <72.09%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Mar 28, 2026

I managed to get the checks to work correctly and I got all of them to pass. Thank you for the patience. This PR is ready to be reviewed.

Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
Comment thread beets/importer/tasks.py Outdated
@gaotue gaotue requested a review from snejus March 29, 2026 02:58
@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Mar 29, 2026

I have applied the improvements you suggested. Thank you for the constructive and instructive advice!

Copy link
Copy Markdown
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

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

A couple of more comments

Comment thread beets/util/__init__.py Outdated
Comment thread beets/util/__init__.py Outdated
Comment thread beets/util/__init__.py Outdated
Comment thread beets/util/__init__.py Outdated
Comment thread docs/reference/config.rst
Comment thread beets/util/__init__.py Outdated
Comment thread test/test_importer.py Outdated
Comment thread test/test_importer.py Outdated
@gaotue gaotue requested a review from snejus March 29, 2026 17:35
Copy link
Copy Markdown
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

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

Just the last small nit in the changelog to clarify we're dealing with imports and we're good

Comment thread docs/changelog.rst Outdated
@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Mar 31, 2026

Change committed. Thank you for helping me improve my code, I feel that it is much cleaner compared to the first version.

@snejus
Copy link
Copy Markdown
Member

snejus commented Mar 31, 2026

Looks great - I see there's now just an outstanding conflict left in the changelog

@gaotue
Copy link
Copy Markdown
Contributor Author

gaotue commented Apr 2, 2026

I took extra precaution when merging, considering last time I messed up the whole branch. In hindsight I should have worked on a branch instead of on Master so that I wont have to keep merging changelog. I think this fork is ready for merging. Thank you so much for your continuous support!

@snejus snejus merged commit ad20cc7 into beetbox:master Apr 2, 2026
16 checks passed
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.

Consider adding filename extensions to tracks without one

3 participants