Welcome Guest

Pages: 1
[Solved] Running External Scripts
PowderPostMay 16, 2013, 07:14
Pro
Posts: 116
Registered:
March 4, 2013, 18:53
Normal topic[Solved] Running External Scripts

Hi,

just wondered if it is possible to run external scripts. I would like to run a custom made application which either returns the musical key as a string or writes the tag itself.

/Artist - Title/
01_track1.mp3
02_track2.mp3

I would like to make an action which calls the custom script with the name of the mp3 which is currently being processed like this:
getkey "full_path_of_my_album/Artist - Title/01_track1.mp3"
It would be great if yate would wait for the script to finish and make the output of the script usable as a field (TKEY in this case).

These two functions could be called like this:

Run external script (with output) and
Run external script

Cheers,
Tim

2MR2PostMay 16, 2013, 07:28
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Running External Scripts

I'll take a look at it. I'd have to generalize the output by placing it into the 'User Defined Work Field' which is a placeholder for this type of stuff. The Copy function would easily move it to TKEY. I'll add it to the list and get back to you on what's possible and a potential ETA.

2MR2PostMay 17, 2013, 22:00
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Running External Scripts

Taking this as a challenge I've implemented a new action called 'Run External Script'. The function is supplied a script to run (typically a full path) and a parameter mode. The parameter mode can be 'none', 'path to file' or 'path to folder'. You can also specify that you want the script to run only once per set of files. Yate always waits for a script to terminate.

The output, if any, of the script is placed into the 'User Defined Work Field'. Many other script functions can manipulate the field, including Copy. I've also created a new function called Truncate which converts a field to the first non blank text line in the field and removes all line terminations.

It seems to work fine. For now I'm ignoring all errors that the script may generate including launching errors. On an error, the 'User Defined Work Field' will be set to the output at that point or empty.

How does it sound?

BTW directly writing the tag from the script is not a great idea because if you then saved the file in Yate you would get a 'file changed' notification and if you then went ahead and saved regardless you would lose the scripted update.

2MR2PostMay 18, 2013, 15:35
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Running External Scripts

Update: The function now stops the action on hard script errors such as unable to launch. Further, the Run External Script function now gives you the option of stopping on any error output.

PowderPostMay 19, 2013, 06:10
Pro
Posts: 116
Registered:
March 4, 2013, 18:53
Normal topicRe: Running External Scripts

Thanks a lot for the great support here!

Your implementation sounds very good to me! Will the changes be in v2.1.2.2 then?

2MR2PostMay 19, 2013, 08:37
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Running External Scripts

It'll be in v2.2 which is in test. Although it has been delayed due to the implementation of more feature requests 🙂 it should be out in about a week.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.017 seconds.