It was to be expected (lacking coding skills) that I wouldn’t be able to fix this on my own.
Please only answer if it’s not too much asked.
I’ve created a new is_1644
inline statement like this (my whole inline section is at the bottom for reference)
is_1644: 1 if bitdepth == 16 and my_samplerate == 44 else 0
And I’ve changed this part of my path from
%if{$is_flac,($format $bitdepth-$my_samplerate),($format $av_bitrate)}
to
%if{$is_1644,,%if{$is_flac,($format $bitdepth-$my_samplerate),($format $av_bitrate)}}
When i do
beet move 'Rickie Lee Jones'
I get the following error
beet move 'Rickie Lee Jones'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beetsplug/inline.py", line 112, in _expr_func
return eval(code, values)
File "inline", line 1, in <module>
NameError: name 'bitdepth' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 598, in substitute
res = self.compiled(values, functions)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 622, in wrapper_func
args[VARIABLE_PREFIX + varname] = values[varname]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/library.py", line 415, in __getitem__
value = self._get(key)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/library.py", line 404, in _get
return self._get_formatted(self.album, key)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 81, in _get_formatted
value = model._type(key).format(model.get(key))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 443, in get
return self[key]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 354, in __getitem__
return getters[key](self)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beetsplug/inline.py", line 114, in _expr_func
raise InlineError(python_code, exc)
beetsplug.inline.InlineError: error in inline path field code:
1 if bitdepth == 16 and my_samplerate == 44 else 0
NameError: name 'bitdepth' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beetsplug/inline.py", line 112, in _expr_func
return eval(code, values)
File "inline", line 1, in <module>
NameError: name 'bitdepth' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/beet", line 11, in <module>
load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/commands.py", line 1551, in move_func
opts.timid, opts.export)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/commands.py", line 1498, in move_items
objs = [o for o in objs if (isalbummoved if album else isitemmoved)(o)]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/commands.py", line 1498, in <listcomp>
objs = [o for o in objs if (isalbummoved if album else isitemmoved)(o)]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/ui/commands.py", line 1496, in <lambda>
isitemmoved = lambda item: item.path != item.destination(basedir=dest)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/library.py", line 873, in destination
subpath = self.evaluate_template(subpath_tmpl, True)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 602, in evaluate_template
self._template_funcs())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 600, in substitute
res = self.interpret(values, functions)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 592, in interpret
return self.expr.evaluate(Environment(values, functions))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 282, in evaluate
out.append(part.evaluate(env))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 217, in evaluate
arg_vals = [expr.evaluate(env) for expr in self.args]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 217, in <listcomp>
arg_vals = [expr.evaluate(env) for expr in self.args]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 282, in evaluate
out.append(part.evaluate(env))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/util/functemplate.py", line 184, in evaluate
if self.ident in env.values:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_collections_abc.py", line 666, in __contains__
self[key]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/library.py", line 415, in __getitem__
value = self._get(key)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/library.py", line 404, in _get
return self._get_formatted(self.album, key)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 81, in _get_formatted
value = model._type(key).format(model.get(key))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 443, in get
return self[key]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/dbcore/db.py", line 354, in __getitem__
return getters[key](self)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beetsplug/inline.py", line 114, in _expr_func
raise InlineError(python_code, exc)
beetsplug.inline.InlineError: error in inline path field code:
1 if bitdepth == 16 and my_samplerate == 44 else 0
NameError: name 'bitdepth' is not defined
On the internet I found that these errors occur when a name has not been defined before it is referenced. But that’s as far as I’ve come. Could well be that my syntax for the inline statement is incorrect and that my path needs adjustments.
Any suggestions are welcome.
My whole inline section fro reference
# Inline plugin template
item_fields:
multidisc: 1 if disctotal > 1 else 0
my_samplerate: round(samplerate / 1000)
is_flac: 1 if format == "FLAC" else 0
album_fields:
format: |
formatList = []
for item in items:
formatList.append(item.format)
return formatList
av_bitrate: |
total = 0
for item in items:
total += item.bitrate
return round(total / len(items) / 1000)
album_bitdepth: |
total = 0
for item in items:
total += item.bitdepth
return round(total / len(items))
album_samplerate: |
total = 0
for item in items:
total += item.samplerate
return round(total / len(items) / 1000)
is_1644: 1 if bitdepth == 16 and my_samplerate == 44 else 0