mirror of
https://github.com/beetbox/beets.git
synced 2026-02-23 07:44:38 +01:00
refinements to artpath modification patch
That's 371cc72f2d09 in hg. This makes the patch slightly more general by reusing our type conversion infrastructure. It also uses "bytes" as a synonym for "str" that I find a little bit clearer.
This commit is contained in:
parent
4d44e11a32
commit
6334f4d1a5
4 changed files with 11 additions and 10 deletions
|
|
@ -45,9 +45,9 @@ from datetime import datetime
|
|||
# - Is the field writable?
|
||||
# - Does the field reflect an attribute of a MediaFile?
|
||||
ITEM_FIELDS = [
|
||||
('id', int, False, False),
|
||||
('path', str, False, False),
|
||||
('album_id', int, False, False),
|
||||
('id', int, False, False),
|
||||
('path', bytes, False, False),
|
||||
('album_id', int, False, False),
|
||||
|
||||
('title', unicode, True, True),
|
||||
('artist', unicode, True, True),
|
||||
|
|
@ -116,7 +116,7 @@ ITEM_KEYS = [f[0] for f in ITEM_FIELDS]
|
|||
# identically-named field in the items table.
|
||||
ALBUM_FIELDS = [
|
||||
('id', int, False),
|
||||
('artpath', str, False),
|
||||
('artpath', bytes, False),
|
||||
('added', datetime, True),
|
||||
|
||||
('albumartist', unicode, True),
|
||||
|
|
@ -157,7 +157,7 @@ SQLITE_TYPES = {
|
|||
int: 'INT',
|
||||
float: 'REAL',
|
||||
datetime: 'FLOAT',
|
||||
str: 'BLOB',
|
||||
bytes: 'BLOB',
|
||||
unicode: 'TEXT',
|
||||
bool: 'INT',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,8 +381,8 @@ def _colordiff(a, b, highlight='red'):
|
|||
else:
|
||||
return colorize(highlight, a), colorize(highlight, b)
|
||||
|
||||
if not isinstance(a, unicode) or not isinstance(b, unicode):
|
||||
# This is probably a path
|
||||
if isinstance(a, bytes) or isinstance(b, bytes):
|
||||
# A path field.
|
||||
a = util.displayable_path(a)
|
||||
b = util.displayable_path(b)
|
||||
|
||||
|
|
|
|||
|
|
@ -1089,6 +1089,8 @@ def _convert_type(key, value, album=False):
|
|||
return time.mktime(time.strptime(value, fmt))
|
||||
except ValueError:
|
||||
raise ui.UserError(u'{0} must have format {1}'.format(key, fmt))
|
||||
elif typ is bytes: # A path.
|
||||
return util.bytestring_path(value)
|
||||
else:
|
||||
try:
|
||||
return typ(value)
|
||||
|
|
@ -1107,9 +1109,6 @@ def modify_items(lib, mods, query, write, move, album, confirm):
|
|||
key, value = mod.split('=', 1)
|
||||
if key not in allowed_keys:
|
||||
raise ui.UserError('"%s" is not a valid field' % key)
|
||||
|
||||
if key == 'artpath':
|
||||
value = util.bytestring_path(value)
|
||||
fsets[key] = _convert_type(key, value, album)
|
||||
|
||||
# Get the items to modify.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ Changelog
|
|||
* Album art filenames now respect the :ref:`replace` configuration.
|
||||
* Friendly error messages are now printed when trying to read or write files
|
||||
that go missing.
|
||||
* The :ref:`modify-cmd` command can now change albums' album art paths (i.e.,
|
||||
``beet modify artpath=...`` works).
|
||||
* Various UI enhancements to the importer due to Tai Lee:
|
||||
|
||||
* More consistent format and colorization of album and track metadata.
|
||||
|
|
|
|||
Loading…
Reference in a new issue