Skip to content

convert: add format_map option - #7108

Open
zakharstudenttuke wants to merge 2 commits into
beetbox:masterfrom
zakharstudenttuke:convert-format-map
Open

zakharstudenttuke wants to merge 2 commits into
beetbox:masterfrom
zakharstudenttuke:convert-format-map

Conversation

@zakharstudenttuke

Copy link
Copy Markdown

Fixes #7040.

Adds an optional format_map setting to the convert plugin. It maps the format of a source file to the format it should be converted to, so one run can produce different formats depending on the input:

convert:
  format: mp3
  format_map:
    alac: flac
    wav: flac

How the target format of a file is chosen:

  1. -f/--format on the command line, if given (overrides everything).
  2. format_map, using the format of the source file.
  3. The existing format option.

Implementation notes:

  • The target format and command were computed once per run (fmt, command). They are now looked up per item (get_target_format, get_command), and should_transcode, get_item_destination, convert_item, the playlist code and convert_on_import use them.
  • The -f/--format option no longer has the config value as its default. It is None unless given, so the plugin can tell "not given" from "given". The option is otherwise unchanged.
  • Keys of format_map are case-insensitive. wav is accepted as an alias of WAVE, which is how beets names WAV files.
  • Without format_map the behaviour is unchanged.
  • A source file that is already in its target format is copied, as before.

Testing:

  • New tests in test/plugins/test_convert.py (the existing stub command is used, so ffmpeg is not needed).
  • I also ran it with real ffmpeg on wav/flac/ogg/mp3 files and checked the codecs of the results with ffprobe.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 11:46
@zakharstudenttuke
zakharstudenttuke requested a review from a team as a code owner October 21, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.47%. Comparing base (929788f) to head (ee8a3e7).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7108      +/-   ##
==========================================
- Coverage   80.49%   80.47%   -0.03%     
==========================================
  Files         149      149              
  Lines       21248    21259      +11     
  Branches     3282     3283       +1     
==========================================
+ Hits        17104    17108       +4     
- Misses       3315     3321       +6     
- Partials      829      830       +1     
Files with missing lines Coverage Δ
beetsplug/convert.py 76.75% <100.00%> (+0.71%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

Make convert handle source and target filetypes

2 participants