ElvishArtisan / rivendell

A full-featured radio automation system targeted for use in professional broadcast and media environments
210 stars 64 forks source link

Can I pass metadata to a bash script with a macro cart? Possible Feature Request. #536

Open zotz opened 4 years ago

zotz commented 4 years ago

This is related to #532 but is nit the same.

Hello all, should I be able to pass metadata (expanded %t and %a in this test case) to a bash script via a RN line in a macro cart? RN /home/rduser/playvid.sh 700011 %t %a! RN /home/rduser/playvid.sh 700020 Fixing_My_Brain Brad_Sucks! In playvid.sh:

echo $0 $1 $2 $3 >> /tmp/passedparams.txt

In  /tmp/passedparams.txt:/home/rduser/playvid.sh 700011 %t %a /home/rduser/playvid.sh 700020 Fixing_My_Brain Brad_Sucks /home/rduser/playvid.sh 700011 %t %a

The metadata is not being expanded. The Fixing_My_Brain Brad_Sucks is being passed as indicated above but I cannot try passing like this:

RN /home/rduser/playvid.sh 700020 "Fixing My Brain" "Brad Sucks"!

as the entry box refuses to accept the quotes...

It would be nice if the metadata got expanded before sending on to the bash script.

all the best,

drew

ElvishArtisan commented 4 years ago

So the metadata in this case would be that of the containing cart? I'd need to know more about what you're actually trying to accomplish to be sure, but I'm wondering if it couldn't be done using a PyPAD script.

zotz commented 4 years ago

Fred,

thanks for the response.

I can't remember where all I have bits of this but elsewhere I mention that I am trying in a pypad script as well... (I modified the filewrite module.

The issue I am having with pypad is that it emits now/next info at times other than when a cart starts to play.

I have also learned that I can get file path wildcards to expand in this context. Appendix D. I was wanting E.1. expansion.

Please see other posts concerning a bug in the parameter passing in the 3.x code I am running.

all the best,

drew

ElvishArtisan commented 4 years ago

I can't remember where all I have bits of this but elsewhere I mention that I am trying in a pypad script as well... (I modified the filewrite module.

The issue I am having with pypad is that it emits now/next info at times other than when a cart starts to play.

It's a bit convoluted, but you can filter out the updates that change only the 'next' fields. Here's an example (extracted from the 'pypad_spinitron.py' script):

def ProcessPad(update):
    try:
        last_updates[update.machine()]
    except KeyError:
        last_updates[update.machine()]=None

    if update.hasPadType(pypad.TYPE_NOW) and (last_updates[update.machine()] != update.startDateTimeString(pypad.TYPE_NOW)):
        last_updates[update.machine()]=update.startDateTimeString(pypad.TYPE_NOW)
        #
        # Do the business here!
        #

Basically, we cache the start time of the previous 'NOW' event. Then, only if that start time has changed do we process the event. (The try / except block at the start is to initialize the cache variables).

FWIW, if I were designing Rivendell's PAD subsystem today, I'd leave the whole 'NEXT' component out of it. Virtually nobody uses it (mostly thanks to the RIAA/SoundEx gorillas).

Please see other posts concerning a bug in the parameter passing in the 3.x code I am running.

Just swatted it. See #532 for details.