mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
GH-69/GC-450: docs, changelog, simplification
This commit is contained in:
parent
c50289d34d
commit
128a881bb4
5 changed files with 18 additions and 23 deletions
|
|
@ -1562,17 +1562,19 @@ class Album(BaseAlbum):
|
|||
items, so the album must contain at least one item or
|
||||
item_dir must be provided.
|
||||
"""
|
||||
|
||||
image = bytestring_path(image)
|
||||
item_dir = item_dir or self.item_dir()
|
||||
|
||||
if not isinstance(self._library.art_filename,Template):
|
||||
self._library.art_filename = Template(self._library.art_filename)
|
||||
|
||||
sanitized_art_filename = util.sanitize_for_path(self.evaluate_template(self._library.art_filename),os.path)
|
||||
_, ext = os.path.splitext(image)
|
||||
subpath = util.sanitize_path(util.sanitize_for_path(
|
||||
self.evaluate_template(self._library.art_filename)
|
||||
))
|
||||
subpath = bytestring_path(subpath)
|
||||
|
||||
dest = os.path.join(item_dir, util.sanitize_path(sanitized_art_filename) + ext)
|
||||
_, ext = os.path.splitext(image)
|
||||
dest = os.path.join(item_dir, subpath + ext)
|
||||
|
||||
return bytestring_path(dest)
|
||||
|
||||
|
|
|
|||
|
|
@ -516,20 +516,6 @@ def _get_path_formats(config):
|
|||
|
||||
return path_formats
|
||||
|
||||
def _get_art_filename(config):
|
||||
"""Returns a string of album art format; reflecting
|
||||
the config's specified album art filename.
|
||||
"""
|
||||
legacy_art_filename = config_val(config, 'beets', 'art_filename', None)
|
||||
if legacy_art_filename:
|
||||
# Old art filename format override the default value.
|
||||
art_filename = Template(legacy_art_filename)
|
||||
else:
|
||||
# If no legacy art filename format, use the default instead.
|
||||
art_filename = DEFAULT_ART_FILENAME
|
||||
|
||||
return art_filename
|
||||
|
||||
def _pick_format(config=None, album=False, fmt=None):
|
||||
"""Pick a format string for printing Album or Item objects,
|
||||
falling back to config options and defaults.
|
||||
|
|
@ -785,7 +771,8 @@ def _raw_main(args, configfh):
|
|||
directory = options.directory or \
|
||||
config_val(config, 'beets', 'directory', default_dir)
|
||||
path_formats = _get_path_formats(config)
|
||||
art_filename = _get_art_filename(config)
|
||||
art_filename = Template(config_val(config, 'beets', 'art_filename',
|
||||
DEFAULT_ART_FILENAME))
|
||||
lib_timeout = config_val(config, 'beets', 'timeout', DEFAULT_TIMEOUT)
|
||||
replacements = _get_replacements(config)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -476,11 +476,13 @@ def truncate_path(path, pathmod=None, length=MAX_FILENAME_LENGTH):
|
|||
|
||||
return pathmod.join(*out)
|
||||
|
||||
def sanitize_for_path(value, pathmod, key=None):
|
||||
def sanitize_for_path(value, pathmod=None, key=None):
|
||||
"""Sanitize the value for inclusion in a path: replace separators
|
||||
with _, etc. Doesn't guarantee that the whole path will be valid;
|
||||
you should still call sanitize_path on the complete path.
|
||||
"""
|
||||
pathmod = pathmod or os.path
|
||||
|
||||
if isinstance(value, basestring):
|
||||
for sep in (pathmod.sep, pathmod.altsep):
|
||||
if sep:
|
||||
|
|
@ -500,6 +502,7 @@ def sanitize_for_path(value, pathmod, key=None):
|
|||
value = u'%ikHz' % ((value or 0) // 1000)
|
||||
else:
|
||||
value = unicode(value)
|
||||
|
||||
return value
|
||||
|
||||
def str2bool(value):
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Changelog
|
|||
* The output of the :ref:`update-cmd`, :ref:`remove-cmd`, and :ref:`modify-cmd`
|
||||
commands now respects the :ref:`list_format_album` and
|
||||
:ref:`list_format_item` config options. Thanks to Mike Kazantsev.
|
||||
* The :ref:`art-filename` option can now be a template rather than a simple
|
||||
string. Thanks to Jarrod Beardwood.
|
||||
* Fix album queries for ``artpath`` and other non-item fields.
|
||||
* Null values in the database can now be matched with the empty-string regular
|
||||
expression, ``^$``.
|
||||
|
|
|
|||
|
|
@ -157,9 +157,10 @@ art_filename
|
|||
~~~~~~~~~~~~
|
||||
|
||||
When importing album art, the name of the file (without extension) where the
|
||||
cover art image should be placed. Defaults to ``cover`` (i.e., images will
|
||||
be named ``cover.jpg`` or ``cover.png`` and placed in the album's
|
||||
directory).
|
||||
cover art image should be placed. This is a template string, so you can use any
|
||||
of the syntax available to :doc:`/reference/pathformat`. Defaults to ``cover``
|
||||
(i.e., images will be named ``cover.jpg`` or ``cover.png`` and placed in the
|
||||
album's directory).
|
||||
|
||||
plugins
|
||||
~~~~~~~
|
||||
|
|
|
|||
Loading…
Reference in a new issue