Debian Codegraph @

docs/plugins/duplicates.rst

raw
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. The command is not run
51 through a shell: it is split into arguments (respecting shell-like quoting)
52 and ``{file}`` is then replaced with the item's path within each argument, so
53 paths containing spaces need no extra quoting. **Note: shell features such as
54 pipes or redirection cannot be used.** The command's entire output is used as
55 the checksum, so it must not contain anything that differs between copies of
56 the same file, such as the file's path. Default: ``ffmpeg -i {file} -f crc
57 -``.
58 - **copy**: A destination base directory into which to copy matched items.
59 Default: none (disabled).
60 - **count**: Print a count of duplicate tracks or albums in the format
61 ``$albumartist - $album - $title: $count`` (for tracks) or ``$albumartist -
62 $album: $count`` (for albums). Default: ``no``.
63 - **delete**: Remove matched items from the library and from the disk. Default:
64 ``no``
65 - **format**: A specific format with which to print every track or album. This
66 uses the same template syntax as beets' :doc:`path formats
67 </reference/pathformat>`. The usage is inspired by, and therefore similar to,
68 the :ref:`list <list-cmd>` command. Default: :ref:`format_item`
69 - **full**: List every track or album that has duplicates, not just the
70 duplicates themselves. Default: ``no``
71 - **keys**: Define in which track or album fields duplicates are to be searched.
72 By default, the plugin uses the musicbrainz track and album IDs for this
73 purpose. Using the ``keys`` option (as a YAML list in the configuration file,
74 or as space-delimited strings in the command-line), you can extend this
75 behavior to consider other attributes. Default: ``[mb_trackid, mb_albumid]``
76 - **merge**: Merge duplicate items by consolidating tracks and-or metadata where
77 possible.
78 - **move**: A destination base directory into which it will move matched items.
79 Default: none (disabled).
80 - **path**: Output the path instead of metadata when listing duplicates.
81 Default: ``no``.
82 - **strict**: Do not report duplicate matches if some of the attributes are not
83 defined (ie. null or empty). Default: ``no``
84 - **tag**: A ``key=value`` pair. The plugin will add a new ``key`` attribute
85 with ``value`` value as a flexattr to the database for duplicate items.
86 Default: ``no``.
87 - **tiebreak**: Dictionary of lists of attributes keyed by ``items`` or
88 ``albums`` to use when choosing duplicates. By default, the tie-breaking
89 procedure favors the most complete metadata attribute set. If you would like
90 to consider the lower bitrates as duplicates, for example, set ``tiebreak:
91 items: [bitrate]``. Default: ``{}``.
92 - **remove**: Remove matched items from the library, but not from the disk.
93 Default: ``no``.
94
95 Examples
96 --------
97
98 List all duplicate tracks in your collection:
99
100 ::
101
102 beet duplicates
103
104 List all duplicate tracks from 2008:
105
106 ::
107
108 beet duplicates year:2008
109
110 Print out a unicode histogram of duplicate track years using spark_:
111
112 ::
113
114 beet duplicates -f '$year' | spark
115 ▆▁▆█▄▇▇▄▇▇▁█▇▆▇▂▄█▁██▂█▁▁██▁█▂▇▆▂▇█▇▇█▆▆▇█▇█▇▆██▂▇
116
117 Print out a listing of all albums with duplicate tracks, and respective counts:
118
119 ::
120
121 beet duplicates -ac
122
123 The same as the above but include the original album, and show the path:
124
125 ::
126
127 beet duplicates -acf '$path'
128
129 Get tracks with the same title, artist, and album:
130
131 ::
132
133 beet duplicates -k title -k albumartist -k album
134
135 Compute Adler CRC32 checksums, storing them as flexattrs, and report back
136 duplicates based on those values:
137
138 .. code-block:: bash
139
140 beet dup -C 'ffmpeg -i {file} -f crc -'
141
142 Note that ``beet dup -C 'md5sum {file}'`` would not work: the command's entire
143 output is used as the checksum, and ``md5sum`` prints the file's path after the
144 hash, so copies of the same file at different paths would never match. Instead,
145 wrap the command in a script that prints only the hash:
146
147 .. code-block:: bash
148
149 #!/bin/sh
150 md5sum "$1" | awk '{print $1}'
151
152 and use that script as the checksum command:
153
154 .. code-block:: bash
155
156 beet dup -C 'myscript {file}'
157
158 Copy highly danceable items to ``party`` directory:
159
160 ::
161
162 beet dup --copy /tmp/party
163
164 Move likely duplicates to ``trash`` directory:
165
166 ::
167
168 beet dup --move ${HOME}/.Trash
169
170 Delete items (careful!), if they're Nickelback:
171
172 ::
173
174 beet duplicates --delete -k albumartist -k albumartist:nickelback
175
176 Tag duplicate items with some flag:
177
178 ::
179
180 beet duplicates --tag dup=1
181
182 Ignore items with undefined keys:
183
184 ::
185
186 beet duplicates --strict
187
188 Merge and delete duplicate albums with different missing tracks:
189
190 ::
191
192 beet duplicates --album --merge --delete
193
194 .. _spark: https://github.com/holman/spark