mirror of
https://github.com/beetbox/beets.git
synced 2026-11-30 10:14:33 -06:00
duplicates: improve the checksum option docs (#6913)
Fixes #3979. The docs suggested `beet dup -C 'md5sum {file}'` as a checksum command, but it can never match anything: the plugin uses the command's entire output as the checksum, and md5sum prints the file's path after the hash, so two copies of the same file always look different. The docs also didn't explain how the command is run (split shlex-style with `{file}` substituted per argument, no shell, so no pipes or redirection). Reworded the `checksum` option description to cover that, dropped the broken md5sum example and added a small wrapper-script recipe for commands like md5sum. I checked the recipe end to end on a throwaway library with duplicate files (paths with spaces included); the duplicates plugin tests pass and sphinx-lint/docstrfmt are clean on the changed files.
This commit is contained in:
+7
-3
@@ -21,9 +21,13 @@ Unreleased
|
||||
For plugin developers
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
..
|
||||
Other changes
|
||||
~~~~~~~~~~~~~
|
||||
Other changes
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
- :doc:`plugins/duplicates`: Improve the documentation of the ``checksum``
|
||||
option: explain how the external command is run, remove the broken ``md5sum
|
||||
{file}`` example and show how to use such commands through a wrapper script.
|
||||
:bug:`3979`
|
||||
|
||||
2.14.0 (September 07, 2026)
|
||||
---------------------------
|
||||
|
||||
@@ -47,8 +47,14 @@ file. The available options mirror the command-line options:
|
||||
overrides the ``keys`` option the first time it is run; however, because it
|
||||
caches the resulting checksum as ``flexattrs`` in the database, you can use
|
||||
``--key=name_of_the_checksumming_program --key=any_other_keys`` (or set the
|
||||
``keys`` configuration option) the second time around. Default: ``ffmpeg -i
|
||||
{file} -f crc -``.
|
||||
``keys`` configuration option) the second time around. The command is not run
|
||||
through a shell: it is split into arguments (respecting shell-like quoting)
|
||||
and ``{file}`` is then replaced with the item's path within each argument, so
|
||||
paths containing spaces need no extra quoting. **Note: shell features such as
|
||||
pipes or redirection cannot be used.** The command's entire output is used as
|
||||
the checksum, so it must not contain anything that differs between copies of
|
||||
the same file, such as the file's path. Default: ``ffmpeg -i {file} -f crc
|
||||
-``.
|
||||
- **copy**: A destination base directory into which to copy matched items.
|
||||
Default: none (disabled).
|
||||
- **count**: Print a count of duplicate tracks or albums in the format
|
||||
@@ -126,13 +132,28 @@ Get tracks with the same title, artist, and album:
|
||||
|
||||
beet duplicates -k title -k albumartist -k album
|
||||
|
||||
Compute Adler CRC32 or MD5 checksums, storing them as flexattrs, and report back
|
||||
Compute Adler CRC32 checksums, storing them as flexattrs, and report back
|
||||
duplicates based on those values:
|
||||
|
||||
::
|
||||
.. code-block:: bash
|
||||
|
||||
beet dup -C 'ffmpeg -i {file} -f crc -'
|
||||
beet dup -C 'md5sum {file}'
|
||||
|
||||
Note that ``beet dup -C 'md5sum {file}'`` would not work: the command's entire
|
||||
output is used as the checksum, and ``md5sum`` prints the file's path after the
|
||||
hash, so copies of the same file at different paths would never match. Instead,
|
||||
wrap the command in a script that prints only the hash:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
#!/bin/sh
|
||||
md5sum "$1" | awk '{print $1}'
|
||||
|
||||
and use that script as the checksum command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
beet dup -C 'myscript {file}'
|
||||
|
||||
Copy highly danceable items to ``party`` directory:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user