Execute JavaScript after tags have been added/removed
This commit is contained in:
parent
57b6d38e43
commit
9aca90538d
|
@ -370,11 +370,11 @@ Here are some Bash examples which illustrate getting and setting tag information
|
|||
- The `utility` object exposes useful methods, e.g. for logging and controlling the event loop.
|
||||
- Checkout the file `testfiles/http.js` in this repository for an example of using XHR and
|
||||
controlling the event loop.
|
||||
- The script runs after tags are added/removed (according to options like `--id3v1-usage`).
|
||||
So the tags present during script execution don't necessarily represent tags that are actually
|
||||
already present in the file.
|
||||
- The script is executed before any other modifications are applied. So if you also specify
|
||||
values as usual (via `--values`) then these values override values changes by the script.
|
||||
- The script runs so far before tags are added/removed (according to options like
|
||||
`--id3v1-usage`). This may change in future versions. A JavaScript API to deal with such
|
||||
changes still needs to be implemented.
|
||||
values as usual (via `--values`) then these values override values changed by the script.
|
||||
|
||||
##### Further useful commands
|
||||
* Let the tag editor return with a non-zero exit code even if only non-fatal problems have been encountered
|
||||
|
|
|
@ -734,27 +734,6 @@ void setTagInfo(const SetTagInfoArgs &args)
|
|||
fileInfo.parseTracks(diag, parsingProgress);
|
||||
fileInfo.parseAttachments(diag, parsingProgress);
|
||||
|
||||
// process tag fields via the specified JavaScript
|
||||
#ifdef TAGEDITOR_USE_JSENGINE
|
||||
if (js) {
|
||||
const auto res = js->callMain(fileInfo, diag);
|
||||
if (res.isError() || diag.has(DiagLevel::Fatal)) {
|
||||
if (!quiet) {
|
||||
std::cout << " - Skipping file due to fatal error when executing JavaScript.\n";
|
||||
}
|
||||
continueWithNextFile(diag);
|
||||
continue;
|
||||
}
|
||||
if (!res.isUndefined() && !res.toBool()) {
|
||||
if (!quiet) {
|
||||
std::cout << " - Skipping file because JavaScript returned a falsy value other than undefined.\n";
|
||||
}
|
||||
continueWithNextFile(diag);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// remove tags with the specified targets
|
||||
if (!targetsToRemove.empty()) {
|
||||
tags.clear();
|
||||
|
@ -828,6 +807,27 @@ void setTagInfo(const SetTagInfoArgs &args)
|
|||
}
|
||||
}
|
||||
|
||||
// process tag fields via the specified JavaScript
|
||||
#ifdef TAGEDITOR_USE_JSENGINE
|
||||
if (js) {
|
||||
const auto res = js->callMain(fileInfo, diag);
|
||||
if (res.isError() || diag.has(DiagLevel::Fatal)) {
|
||||
if (!quiet) {
|
||||
std::cout << " - Skipping file due to fatal error when executing JavaScript.\n";
|
||||
}
|
||||
continueWithNextFile(diag);
|
||||
continue;
|
||||
}
|
||||
if (!res.isUndefined() && !res.toBool()) {
|
||||
if (!quiet) {
|
||||
std::cout << " - Skipping file because JavaScript returned a falsy value other than undefined.\n";
|
||||
}
|
||||
continueWithNextFile(diag);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// alter tags
|
||||
tags.clear();
|
||||
fileInfo.tags(tags);
|
||||
|
|
Loading…
Reference in New Issue