| 1 |
FetchArt Plugin |
| 2 |
=============== |
| 3 |
|
| 4 |
The ``fetchart`` plugin retrieves album art images from various sources on the |
| 5 |
Web and stores them as image files. |
| 6 |
|
| 7 |
``fetchart`` supports fetching images in ``JPEG``, ``PNG``, and ``WebP`` |
| 8 |
formats. |
| 9 |
|
| 10 |
To use the ``fetchart`` plugin, first enable it in your configuration (see |
| 11 |
:ref:`using-plugins`). Then, install ``beets`` with ``fetchart`` extra |
| 12 |
|
| 13 |
.. code-block:: bash |
| 14 |
|
| 15 |
pip install "beets[fetchart]" |
| 16 |
|
| 17 |
Fetching Album Art During Import |
| 18 |
-------------------------------- |
| 19 |
|
| 20 |
When the plugin is enabled, it automatically tries to get album art for every |
| 21 |
album you import. |
| 22 |
|
| 23 |
By default, beets stores album art image files alongside the music files for an |
| 24 |
album in a file called ``cover.jpg``. To customize the name of this file, use |
| 25 |
the :ref:`art-filename` config option. To embed the art into the files' tags, |
| 26 |
use the :doc:`/plugins/embedart`. (You'll want to have both plugins enabled.) |
| 27 |
|
| 28 |
Configuration |
| 29 |
------------- |
| 30 |
|
| 31 |
To configure the plugin, make a ``fetchart:`` section in your configuration |
| 32 |
file. The available options are: |
| 33 |
|
| 34 |
- **auto**: Enable automatic album art fetching during import. Default: ``yes``. |
| 35 |
- **cautious**: Pick only trusted album art by ignoring filenames that do not |
| 36 |
contain one of the keywords in ``cover_names``. Default: ``no``. |
| 37 |
- **cover_names**: Prioritize images containing words in this list. Default: |
| 38 |
``cover front art album folder``. |
| 39 |
- **fallback**: Path to a fallback album art file if no album art was found |
| 40 |
otherwise. Default: ``None`` (disabled). |
| 41 |
- **fetch_for_asis**: Fetch album art from online sources during import, even |
| 42 |
when the as-is option is selected in the Auto-Tagger. When ``no``, only local |
| 43 |
filesystem sources of art are considered for as-is imports. Default: ``no``. |
| 44 |
- **minwidth**: Only images with a width bigger or equal to ``minwidth`` are |
| 45 |
considered as valid album art candidates. Default: 0. |
| 46 |
- **maxwidth**: A maximum image width to downscale fetched images if they are |
| 47 |
too big. The resize operation reduces image width to at most ``maxwidth`` |
| 48 |
pixels. The height is recomputed so that the aspect ratio is preserved. See |
| 49 |
the section on :ref:`cover-art-archive-maxwidth` below for additional |
| 50 |
information regarding the Cover Art Archive source. Default: 0 (no maximum is |
| 51 |
enforced). |
| 52 |
- **quality**: The JPEG quality level to use when compressing images (when |
| 53 |
``maxwidth`` is set). This should be either a number from 1 to 100 or 0 to use |
| 54 |
the default quality. 65–75 is usually a good starting point. The default |
| 55 |
behavior depends on the imaging tool used for scaling: ImageMagick tries to |
| 56 |
estimate the input image quality and uses 92 if it cannot be determined, and |
| 57 |
PIL defaults to 75. Default: 0 (disabled) |
| 58 |
- **max_filesize**: The maximum size of a target piece of cover art in bytes. |
| 59 |
When using an ImageMagick backend this sets ``-define |
| 60 |
jpeg:extent=max_filesize``. Using PIL this will reduce JPG quality by up to |
| 61 |
50% to attempt to reach the target filesize. Neither method is *guaranteed* to |
| 62 |
reach the target size, however in most cases it should succeed. Default: 0 |
| 63 |
(disabled) |
| 64 |
- **enforce_ratio**: Only images with a width:height ratio of 1:1 are considered |
| 65 |
as valid album art candidates if set to ``yes``. It is also possible to |
| 66 |
specify a certain deviation to the exact ratio to still be considered valid. |
| 67 |
This can be done either in pixels (``enforce_ratio: 10px``) or as a percentage |
| 68 |
of the longer edge (``enforce_ratio: 0.5%``). Default: ``no``. |
| 69 |
- **sources**: List of sources to search for images. An asterisk ``*`` expands |
| 70 |
to all available sources. Default: ``filesystem coverart itunes amazon |
| 71 |
albumart``, i.e., everything but ``wikipedia``, ``google``, ``fanarttv`` and |
| 72 |
``lastfm``. Enable those sources for more matches at the cost of some speed. |
| 73 |
They are searched in the given order, thus in the default config, no remote |
| 74 |
(Web) art source are queried if local art is found in the filesystem. To use a |
| 75 |
local image as fallback, move it to the end of the list. For even more |
| 76 |
fine-grained control over the search order, see the section on |
| 77 |
:ref:`album-art-sources` below. |
| 78 |
- **google_key**: Your Google API key (to enable the Google Custom Search |
| 79 |
backend). Default: None. |
| 80 |
- **google_engine**: The custom search engine to use. Default: The `beets custom |
| 81 |
search engine`_, which searches the entire web. |
| 82 |
- **fanarttv_key**: The personal API key for requesting art from fanart.tv. See |
| 83 |
below. |
| 84 |
- **lastfm_key**: The personal API key for requesting art from Last.fm. See |
| 85 |
below. |
| 86 |
- **store_source**: If enabled, fetchart stores the artwork's source in a |
| 87 |
flexible tag named ``art_source``. See below for the rationale behind this. |
| 88 |
Default: ``no``. |
| 89 |
- **high_resolution**: If enabled, fetchart retrieves artwork in the highest |
| 90 |
resolution it can find (warning: image files can sometimes reach >20MB). |
| 91 |
Default: ``no``. |
| 92 |
- **deinterlace**: If enabled, Pillow_ or ImageMagick_ backends are instructed |
| 93 |
to store cover art as non-progressive JPEG. You might need this if you use |
| 94 |
DAPs that don't support progressive images. Default: ``no``. |
| 95 |
- **cover_format**: If enabled, forced the cover image into the specified |
| 96 |
format. Most often, this will be either ``JPEG``, ``PNG``, or ``WEBP`` (see |
| 97 |
image-formats_). Also respects ``deinterlace``. Default: None (leave |
| 98 |
unchanged). |
| 99 |
|
| 100 |
Note: ``maxwidth`` and ``enforce_ratio`` options require either ImageMagick_ or |
| 101 |
Pillow_. |
| 102 |
|
| 103 |
.. note:: |
| 104 |
|
| 105 |
Previously, there was a ``remote_priority`` option to specify when to look |
| 106 |
for art on the filesystem. This is still respected, but a deprecation |
| 107 |
message will be shown until you replace this configuration with the new |
| 108 |
``filesystem`` value in the ``sources`` array. |
| 109 |
|
| 110 |
.. _image-formats: |
| 111 |
|
| 112 |
.. admonition:: Image formats |
| 113 |
|
| 114 |
Other image formats are available, though the full list depends on your |
| 115 |
system and what backend you are using. If you're using the ImageMagick |
| 116 |
backend, you can use ``magick identify -list format`` to get a full list of |
| 117 |
all supported formats, and you can use the Python function |
| 118 |
PIL.features.pilinfo() to print a list of all supported formats in Pillow |
| 119 |
(``python3 -c 'import PIL.features as f; f.pilinfo()'``). |
| 120 |
|
| 121 |
.. _beets custom search engine: https://cse.google.com/cse?cx=001442825323518660753:hrh5ch1gjzm |
| 122 |
|
| 123 |
Here's an example that makes plugin select only images that contain ``front`` or |
| 124 |
``back`` keywords in their filenames and prioritizes the iTunes source over |
| 125 |
others: |
| 126 |
|
| 127 |
:: |
| 128 |
|
| 129 |
fetchart: |
| 130 |
cautious: true |
| 131 |
cover_names: front back |
| 132 |
sources: itunes * |
| 133 |
|
| 134 |
Manually Fetching Album Art |
| 135 |
--------------------------- |
| 136 |
|
| 137 |
Use the ``fetchart`` command to download album art after albums have already |
| 138 |
been imported: |
| 139 |
|
| 140 |
:: |
| 141 |
|
| 142 |
$ beet fetchart [-f] [query] |
| 143 |
|
| 144 |
By default, the command will only look for album art when the album doesn't |
| 145 |
already have it; the ``-f`` or ``--force`` switch makes it search for art in Web |
| 146 |
databases regardless. If you specify a query, only matching albums will be |
| 147 |
processed; otherwise, the command processes every album in your library. |
| 148 |
|
| 149 |
Display Only Missing Album Art |
| 150 |
------------------------------ |
| 151 |
|
| 152 |
Use the ``fetchart`` command with the ``-q`` switch in order to display only |
| 153 |
missing art: |
| 154 |
|
| 155 |
:: |
| 156 |
|
| 157 |
$ beet fetchart [-q] [query] |
| 158 |
|
| 159 |
By default the command will display all albums matching the ``query``. When the |
| 160 |
``-q`` or ``--quiet`` switch is given, only albums for which artwork has been |
| 161 |
fetched, or for which artwork could not be found will be printed. |
| 162 |
|
| 163 |
.. _image-resizing: |
| 164 |
|
| 165 |
Image Resizing |
| 166 |
-------------- |
| 167 |
|
| 168 |
Beets can resize images using Pillow_, ImageMagick_, or a server-side resizing |
| 169 |
proxy. If either Pillow or ImageMagick is installed, beets will use those; |
| 170 |
otherwise, it falls back to the resizing proxy. If the resizing proxy is used, |
| 171 |
no resizing is performed for album art found on the filesystem---only downloaded |
| 172 |
art is resized. Server-side resizing can also be slower than local resizing, so |
| 173 |
consider installing one of the two backends for better performance. |
| 174 |
|
| 175 |
When using ImageMagick, beets looks for the ``convert`` executable in your path. |
| 176 |
On some versions of Windows, the program can be shadowed by a system-provided |
| 177 |
``convert.exe``. On these systems, you may need to modify your ``%PATH%`` |
| 178 |
environment variable so that ImageMagick comes first or use Pillow instead. |
| 179 |
|
| 180 |
.. _album-art-sources: |
| 181 |
|
| 182 |
Album Art Sources |
| 183 |
----------------- |
| 184 |
|
| 185 |
By default, this plugin searches for art in the local filesystem as well as on |
| 186 |
the Cover Art Archive, the iTunes Store, Amazon, and AlbumArt.org, in that |
| 187 |
order. You can reorder the sources or remove some to speed up the process using |
| 188 |
the ``sources`` configuration option. |
| 189 |
|
| 190 |
When looking for local album art, beets checks for image files located in the |
| 191 |
same folder as the music files you're importing. Beets prefers to use an image |
| 192 |
file whose name contains "cover", "front", "art", "album" or "folder", but in |
| 193 |
the absence of well-known names, it will use any image file in the same folder |
| 194 |
as your music files. |
| 195 |
|
| 196 |
For some of the art sources, the backend service can match artwork by various |
| 197 |
criteria. If you want finer control over the search order in such cases, you can |
| 198 |
use this alternative syntax for the ``sources`` option: |
| 199 |
|
| 200 |
:: |
| 201 |
|
| 202 |
fetchart: |
| 203 |
sources: |
| 204 |
- filesystem |
| 205 |
- coverart: release |
| 206 |
- itunes |
| 207 |
- coverart: releasegroup |
| 208 |
- '*' |
| 209 |
|
| 210 |
where listing a source without matching criteria will default to trying all |
| 211 |
available strategies. Entries of the forms ``coverart: release releasegroup`` |
| 212 |
and ``coverart: *`` are also valid. Currently, only the ``coverart`` source |
| 213 |
supports multiple criteria: namely, ``release`` and ``releasegroup``, which |
| 214 |
refer to the respective MusicBrainz IDs. |
| 215 |
|
| 216 |
When you choose to apply changes during an import, beets will search for art as |
| 217 |
described above. For "as-is" imports (and non-autotagged imports using the |
| 218 |
``-A`` flag), beets only looks for art on the local filesystem. |
| 219 |
|
| 220 |
Google custom search |
| 221 |
~~~~~~~~~~~~~~~~~~~~ |
| 222 |
|
| 223 |
To use the google image search backend you need to `register for a Google API |
| 224 |
key`_. Set the ``google_key`` configuration option to your key, then add |
| 225 |
``google`` to the list of sources in your configuration. |
| 226 |
|
| 227 |
.. _register for a google api key: https://console.cloud.google.com/apis/credentials |
| 228 |
|
| 229 |
Optionally, you can `define a custom search engine`_. Get your search engine's |
| 230 |
token and use it for your ``google_engine`` configuration option. The default |
| 231 |
engine searches the entire web for cover art. |
| 232 |
|
| 233 |
.. _define a custom search engine: https://programmablesearchengine.google.com/about/ |
| 234 |
|
| 235 |
Note that the Google custom search API is limited to 100 queries per day. After |
| 236 |
that, the fetchart plugin will fall back on other declared data sources. |
| 237 |
|
| 238 |
Fanart.tv |
| 239 |
~~~~~~~~~ |
| 240 |
|
| 241 |
Although not strictly necessary right now, you might think about `registering a |
| 242 |
personal fanart.tv API key`_. Set the ``fanarttv_key`` configuration option to |
| 243 |
your key, then add ``fanarttv`` to the list of sources in your configuration. |
| 244 |
|
| 245 |
.. _registering a personal fanart.tv api key: https://fanart.tv/get-an-api-key/ |
| 246 |
|
| 247 |
More detailed information can be found `on their Wiki`_. Specifically, the |
| 248 |
personal key will give you earlier access to new art. |
| 249 |
|
| 250 |
.. _on their wiki: https://wiki.fanart.tv/General/personal%20api/ |
| 251 |
|
| 252 |
Last.fm |
| 253 |
~~~~~~~ |
| 254 |
|
| 255 |
To use the Last.fm backend, you need to `register for a Last.fm API key`_. Set |
| 256 |
the ``lastfm_key`` configuration option to your API key, then add ``lastfm`` to |
| 257 |
the list of sources in your configuration. |
| 258 |
|
| 259 |
.. _register for a last.fm api key: https://www.last.fm/api/account/create |
| 260 |
|
| 261 |
Spotify |
| 262 |
~~~~~~~ |
| 263 |
|
| 264 |
Spotify backend is enabled by default and will update album art if a valid |
| 265 |
Spotify album id is found. |
| 266 |
|
| 267 |
.. _beautifulsoup: https://www.crummy.com/software/BeautifulSoup/bs4/doc/ |
| 268 |
|
| 269 |
.. _pip: https://pip.pypa.io |
| 270 |
|
| 271 |
Cover Art URL |
| 272 |
~~~~~~~~~~~~~ |
| 273 |
|
| 274 |
The ``fetchart`` plugin can also use a flexible attribute field |
| 275 |
``cover_art_url`` where you can manually specify the image URL to be used as |
| 276 |
cover art. Any custom plugin can use this field to provide the cover art and |
| 277 |
``fetchart`` will use it as a source. |
| 278 |
|
| 279 |
.. _cover-art-archive-maxwidth: |
| 280 |
|
| 281 |
Cover Art Archive Pre-sized Thumbnails |
| 282 |
-------------------------------------- |
| 283 |
|
| 284 |
The CAA provides pre-sized thumbnails of width 250, 500, and 1200 pixels. If you |
| 285 |
set the ``maxwidth`` option to one of these values, the corresponding image will |
| 286 |
be downloaded, saving ``beets`` the need to scale down the image. It can also |
| 287 |
speed up the downloading process, as some cover arts can sometimes be very |
| 288 |
large. |
| 289 |
|
| 290 |
Storing the Artwork's Source |
| 291 |
---------------------------- |
| 292 |
|
| 293 |
Storing the current artwork's source might be used to narrow down ``fetchart`` |
| 294 |
commands. For example, if some albums have artwork placed manually in their |
| 295 |
directories that should not be replaced by a forced album art fetch, you could |
| 296 |
do |
| 297 |
|
| 298 |
``beet fetchart -f ^art_source:filesystem`` |
| 299 |
|
| 300 |
The values written to ``art_source`` are the same names used in the ``sources`` |
| 301 |
configuration value. |
| 302 |
|
| 303 |
.. _imagemagick: https://imagemagick.org/ |
| 304 |
|
| 305 |
.. _pillow: https://github.com/python-pillow/Pillow |