| 1 |
Duplicates Plugin |
| 2 |
================= |
| 3 |
|
| 4 |
This plugin adds a new command, ``duplicates`` or ``dup``, which finds and lists |
| 5 |
duplicate tracks or albums in your collection. |
| 6 |
|
| 7 |
Usage |
| 8 |
----- |
| 9 |
|
| 10 |
To use the ``duplicates`` plugin, first enable it in your configuration (see |
| 11 |
:ref:`using-plugins`). |
| 12 |
|
| 13 |
By default, the ``beet duplicates`` command lists the names of tracks in your |
| 14 |
library that are duplicates. It assumes that Musicbrainz track and album ids are |
| 15 |
unique to each track or album. That is, it lists every track or album with an ID |
| 16 |
that has been seen before in the library. You can customize the output format, |
| 17 |
count the number of duplicate tracks or albums, and list all tracks that have |
| 18 |
duplicates or just the duplicates themselves via command-line switches |
| 19 |
|
| 20 |
:: |
| 21 |
|
| 22 |
-h, --help show this help message and exit |
| 23 |
-f FMT, --format=FMT print with custom format |
| 24 |
-a, --album show duplicate albums instead of tracks |
| 25 |
-c, --count count duplicate tracks or albums |
| 26 |
-C PROG, --checksum=PROG |
| 27 |
report duplicates based on arbitrary command |
| 28 |
-d, --delete delete items from library and disk |
| 29 |
-F, --full show all versions of duplicate tracks or albums |
| 30 |
-s, --strict report duplicates only if all attributes are set |
| 31 |
-k, --key report duplicates based on keys (can be used multiple times) |
| 32 |
-M, --merge merge duplicate items |
| 33 |
-m DEST, --move=DEST move items to dest |
| 34 |
-o DEST, --copy=DEST copy items to dest |
| 35 |
-p, --path print paths for matched items or albums |
| 36 |
-t TAG, --tag=TAG tag matched items with 'k=v' attribute |
| 37 |
-r, --remove remove items from library |
| 38 |
|
| 39 |
Configuration |
| 40 |
------------- |
| 41 |
|
| 42 |
To configure the plugin, make a ``duplicates:`` section in your configuration |
| 43 |
file. The available options mirror the command-line options: |
| 44 |
|
| 45 |
- **album**: List duplicate albums instead of tracks. Default: ``no``. |
| 46 |
- **checksum**: Use an arbitrary command to compute a checksum of items. This |
| 47 |
overrides the ``keys`` option the first time it is run; however, because it |
| 48 |
caches the resulting checksum as ``flexattrs`` in the database, you can use |
| 49 |
``--key=name_of_the_checksumming_program --key=any_other_keys`` (or set the |
| 50 |
``keys`` configuration option) the second time around. Default: ``ffmpeg -i |
| 51 |
{file} -f crc -``. |
| 52 |
- **copy**: A destination base directory into which to copy matched items. |
| 53 |
Default: none (disabled). |
| 54 |
- **count**: Print a count of duplicate tracks or albums in the format |
| 55 |
``$albumartist - $album - $title: $count`` (for tracks) or ``$albumartist - |
| 56 |
$album: $count`` (for albums). Default: ``no``. |
| 57 |
- **delete**: Remove matched items from the library and from the disk. Default: |
| 58 |
``no`` |
| 59 |
- **format**: A specific format with which to print every track or album. This |
| 60 |
uses the same template syntax as beets' :doc:`path formats |
| 61 |
</reference/pathformat>`. The usage is inspired by, and therefore similar to, |
| 62 |
the :ref:`list <list-cmd>` command. Default: :ref:`format_item` |
| 63 |
- **full**: List every track or album that has duplicates, not just the |
| 64 |
duplicates themselves. Default: ``no`` |
| 65 |
- **keys**: Define in which track or album fields duplicates are to be searched. |
| 66 |
By default, the plugin uses the musicbrainz track and album IDs for this |
| 67 |
purpose. Using the ``keys`` option (as a YAML list in the configuration file, |
| 68 |
or as space-delimited strings in the command-line), you can extend this |
| 69 |
behavior to consider other attributes. Default: ``[mb_trackid, mb_albumid]`` |
| 70 |
- **merge**: Merge duplicate items by consolidating tracks and-or metadata where |
| 71 |
possible. |
| 72 |
- **move**: A destination base directory into which it will move matched items. |
| 73 |
Default: none (disabled). |
| 74 |
- **path**: Output the path instead of metadata when listing duplicates. |
| 75 |
Default: ``no``. |
| 76 |
- **strict**: Do not report duplicate matches if some of the attributes are not |
| 77 |
defined (ie. null or empty). Default: ``no`` |
| 78 |
- **tag**: A ``key=value`` pair. The plugin will add a new ``key`` attribute |
| 79 |
with ``value`` value as a flexattr to the database for duplicate items. |
| 80 |
Default: ``no``. |
| 81 |
- **tiebreak**: Dictionary of lists of attributes keyed by ``items`` or |
| 82 |
``albums`` to use when choosing duplicates. By default, the tie-breaking |
| 83 |
procedure favors the most complete metadata attribute set. If you would like |
| 84 |
to consider the lower bitrates as duplicates, for example, set ``tiebreak: |
| 85 |
items: [bitrate]``. Default: ``{}``. |
| 86 |
- **remove**: Remove matched items from the library, but not from the disk. |
| 87 |
Default: ``no``. |
| 88 |
|
| 89 |
Examples |
| 90 |
-------- |
| 91 |
|
| 92 |
List all duplicate tracks in your collection: |
| 93 |
|
| 94 |
:: |
| 95 |
|
| 96 |
beet duplicates |
| 97 |
|
| 98 |
List all duplicate tracks from 2008: |
| 99 |
|
| 100 |
:: |
| 101 |
|
| 102 |
beet duplicates year:2008 |
| 103 |
|
| 104 |
Print out a unicode histogram of duplicate track years using spark_: |
| 105 |
|
| 106 |
:: |
| 107 |
|
| 108 |
beet duplicates -f '$year' | spark |
| 109 |
▆▁▆█▄▇▇▄▇▇▁█▇▆▇▂▄█▁██▂█▁▁██▁█▂▇▆▂▇█▇▇█▆▆▇█▇█▇▆██▂▇ |
| 110 |
|
| 111 |
Print out a listing of all albums with duplicate tracks, and respective counts: |
| 112 |
|
| 113 |
:: |
| 114 |
|
| 115 |
beet duplicates -ac |
| 116 |
|
| 117 |
The same as the above but include the original album, and show the path: |
| 118 |
|
| 119 |
:: |
| 120 |
|
| 121 |
beet duplicates -acf '$path' |
| 122 |
|
| 123 |
Get tracks with the same title, artist, and album: |
| 124 |
|
| 125 |
:: |
| 126 |
|
| 127 |
beet duplicates -k title -k albumartist -k album |
| 128 |
|
| 129 |
Compute Adler CRC32 or MD5 checksums, storing them as flexattrs, and report back |
| 130 |
duplicates based on those values: |
| 131 |
|
| 132 |
:: |
| 133 |
|
| 134 |
beet dup -C 'ffmpeg -i {file} -f crc -' |
| 135 |
beet dup -C 'md5sum {file}' |
| 136 |
|
| 137 |
Copy highly danceable items to ``party`` directory: |
| 138 |
|
| 139 |
:: |
| 140 |
|
| 141 |
beet dup --copy /tmp/party |
| 142 |
|
| 143 |
Move likely duplicates to ``trash`` directory: |
| 144 |
|
| 145 |
:: |
| 146 |
|
| 147 |
beet dup --move ${HOME}/.Trash |
| 148 |
|
| 149 |
Delete items (careful!), if they're Nickelback: |
| 150 |
|
| 151 |
:: |
| 152 |
|
| 153 |
beet duplicates --delete -k albumartist -k albumartist:nickelback |
| 154 |
|
| 155 |
Tag duplicate items with some flag: |
| 156 |
|
| 157 |
:: |
| 158 |
|
| 159 |
beet duplicates --tag dup=1 |
| 160 |
|
| 161 |
Ignore items with undefined keys: |
| 162 |
|
| 163 |
:: |
| 164 |
|
| 165 |
beet duplicates --strict |
| 166 |
|
| 167 |
Merge and delete duplicate albums with different missing tracks: |
| 168 |
|
| 169 |
:: |
| 170 |
|
| 171 |
beet duplicates --album --merge --delete |
| 172 |
|
| 173 |
.. _spark: https://github.com/holman/spark |