• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

Events If Then type trigger

Started by numbers1thru9, May 03, 2018, 10:34:00 PM

numbers1thru9

So Id like to see about using the events setup to check to see if a condition exists and then do something if the condition meets my criteria. For example, if i want to check a data base for a certain value, or if an application triggered on the event returns a certain value. Is that possible at all?

For example, when the event gets triggered, id like to run a program or sql query to check something to see if it meets my requirements to do the remaining actions, or to skip the remaining actions.

He-j

#1
I have not seen a specific table which shows if an event actually loaded/started. The event table shows when an event will load (days, hours, minutes and seconds). So it doesn't really show if it actually has loaded/started (i.e. sometimes it can happen that you see an upcoming event, but it doesn't load for some kind of reason. I haven't seen a table which shows if an event has loaded/started or failed to load/start). So in that case it is in my opinion not possible. If loading days and times in the events table suite you, you could create a query that checks something and will perform an action or not. You have to figure out that query yourself.
Hej Radio ► Netherlands
https://hejradio.jimdofree.com/

Jhonny

You can run a sql query in a event, you have to make that query your self.

It will run as that event starts.
Currently on
RDJ V 2.0.4.8
MariaDB V 10.6.21
WIN 11 PRO

numbers1thru9

Triggering the event really isnt the issue. What Im getting at is say every 15 minutes my event gets triggered. I want to launch a program that does some things for me, and then sets a value in the SQL table. That part I know how to do easily. But what I want then is to run a sql query to check that value. Cool, i got that too. The part that I am trying to figure out is to evaluate if that query result meets my criteria to load a track into the playlist, or if it doesnt match my criteria, to do nothing. Make sense?

Capt_Fuzzy

Quote from: numbers1thru9 on May 04, 2018, 09:49:07 PM
Triggering the event really isnt the issue. What Im getting at is say every 15 minutes my event gets triggered. I want to launch a program that does some things for me, and then sets a value in the SQL table. That part I know how to do easily. But what I want then is to run a sql query to check that value. Cool, i got that too. The part that I am trying to figure out is to evaluate if that query result meets my criteria to load a track into the playlist, or if it doesnt match my criteria, to do nothing. Make sense?
I'm not all that great at writing SQL queries, but looking at this from just a logical standpoint, I'd say that your next step would be to define your criteria.
Once you have the conditions (your criteria) defined, then it shouldn't be too difficult to write a query to compare and react to the value from the event.
Steve 'Capt Fuzzy' Wade
Proud & Satisfied "Long-term" RadioDJ User
(Currently making the transition to v2)

WVRR - Ridgerunners Radio
The best mix of your favorites!

Jhonny

#5
you can use in a event run application (exe file).

Option.
Create a .bat file
let the .bat file perform different things

turn the .bat file into an .exe file with the bath to exe program

refer with the option run application to the .exe file (in the 15 minutes events)
Currently on
RDJ V 2.0.4.8
MariaDB V 10.6.21
WIN 11 PRO

He-j

Jhonny's solution by using the action Run Application could solve your issue.

Probably you can use some tricks out of this post as well:

http://www.radiodj.ro/community/index.php?topic=9617.msg55612#msg55612

Search the forum by using the words Run Application and maybe you will find more tricks.
Hej Radio ► Netherlands
https://hejradio.jimdofree.com/

numbers1thru9

I know what my criteria is :) and i know i can run an application. But, even if i run an application or perform a SQL query, if it matches my criteria i then want to insert tracks into the queue list at the top so they get played.

To give you a rundown of what im trying to do. Im going to have an event that at the half hour mark kick off a script in the first action i have written to query our site which will then return the on air DJ name. If that matches the current DJ using the computer (all of our DJs are around the world so they each have their own install) then Im going to set a value in a SQL Database to be True or 1, or whatever. Then Im going to launch a SQL query next in the event actions that checks to see if that value is true. If that value is true then i want to insert 3-4 tracks into the top of the queuelist so they play after the current song finishes. But if that value equals false to not do anything.

I think i have the SQL part figured out on how to do an an action if the value is true or false. But the part i cant figure out right now is how to add the tracks into the queue if that value is true. I see there is a queuelist table in the database, but based on the fact that the queries that are sent when tracks are added or removed it gets a TRUNCATE then adds the songs back in so that to me appears that the software maintains that list programatically and not in the database other than a copy in the queuelist table. Is it possible to add tracks into the queue via SQL? or with a batch file action?

THATS the problem im having that im trying to get help with :) Hopefully this explains it better.

Jhonny

I don't know how that query looks to put a request in the top of the playlist.
Currently on
RDJ V 2.0.4.8
MariaDB V 10.6.21
WIN 11 PRO

Capt_Fuzzy

Quote from: numbers1thru9 on May 05, 2018, 06:57:51 PM
I know what my criteria is :) and i know i can run an application. But, even if i run an application or perform a SQL query, if it matches my criteria i then want to insert tracks into the queue list at the top so they get played.

To give you a rundown of what im trying to do. Im going to have an event that at the half hour mark kick off a script in the first action i have written to query our site which will then return the on air DJ name. If that matches the current DJ using the computer (all of our DJs are around the world so they each have their own install) then Im going to set a value in a SQL Database to be True or 1, or whatever. Then Im going to launch a SQL query next in the event actions that checks to see if that value is true. If that value is true then i want to insert 3-4 tracks into the top of the queuelist so they play after the current song finishes. But if that value equals false to not do anything.

I think i have the SQL part figured out on how to do an an action if the value is true or false. But the part i cant figure out right now is how to add the tracks into the queue if that value is true. I see there is a queuelist table in the database, but based on the fact that the queries that are sent when tracks are added or removed it gets a TRUNCATE then adds the songs back in so that to me appears that the software maintains that list programatically and not in the database other than a copy in the queuelist table. Is it possible to add tracks into the queue via SQL? or with a batch file action?

THATS the problem im having that im trying to get help with :) Hopefully this explains it better.
This sounds to me like a "manual vs. auto" DJ issue.
When you remove songs from the quelist in 'auto DJ' mode, the program will add more tracks to fill in the missing tracks.
The best way to work around this is with an event command telling the software to switch to 'manual DJ' mode, therefore stopping it from adding the missing tracks back in. Then have it proceed with the query part and when that's finished, have the event re-enable 'auto DJ' mode if you wish.

In a nutshell, you are going to have to have an event do something like this:
At event 'fire time':

Set autodj to manual
execute SQL query (the query should contain the instructions for loading to the top of playlist queue)
wait 5 seconds (this will give the query time to complete and load any results, if needed)
Set manual to autodj
Steve 'Capt Fuzzy' Wade
Proud & Satisfied "Long-term" RadioDJ User
(Currently making the transition to v2)

WVRR - Ridgerunners Radio
The best mix of your favorites!

numbers1thru9

Quote from: Capt_Fuzzy on May 05, 2018, 09:28:07 PM
This sounds to me like a "manual vs. auto" DJ issue.
When you remove songs from the quelist in 'auto DJ' mode, the program will add more tracks to fill in the missing tracks.
The best way to work around this is with an event command telling the software to switch to 'manual DJ' mode, therefore stopping it from adding the missing tracks back in. Then have it proceed with the query part and when that's finished, have the event re-enable 'auto DJ' mode if you wish.

In a nutshell, you are going to have to have an event do something like this:
At event 'fire time':

Set autodj to manual

So its not an auto vs manual issue, we run manual 100% of the time. Its entirely up to the DJ to choose the songs to play. The tracks i want to auto add are our adverts that we want to play every so often without the DJ having to manually add them

Quote
execute SQL query (the query should contain the instructions for loading to the top of playlist queue)

This is the query im trying to figure out. HOW to add tracks to the top of the queue list? What does that query look like. Thats what i cant figure out as like i mentioned according to the SQL log it clears the queuelist table and then fills it back up as songs are added or played. Which is why i dont think that the queuelist table is how I add a song.

He-j

#11
I don't understand why you need a query to load adverts.

Use category commercials for adverts and create subcategories.

For exemple Advert 1 must be played at 6.00, 9.00, 12.00, 15.00 and 18.00
So create a subcategory named Adverts 6|9|12|15|18
When you import this advert you have to add it to Category commercials and Subcategory Adverts 6|9|12|15|18

Create a rotation and select Category commercials and subcategory Adverts 6|9|12|15|18. You could select Random so the adverts will be played in a different order every time. Save the rotation and name it Adverts 6|9|12|15|18.

Next add an event. Set the days and hours. Hours should be 5, 8, 11, 14 and 17. Event hour you have to set at 00:59:55.

You can use these actions:
First select action Enable AudoDJ (so RadioDJ goes in Auto mode)
Disable assisted
Load Rotation. Select rotation Adverts 6|9|12|15|18. Also select Top (in the field Position).
Enable assisted
disable AutoDJ (so RadioDJ goes in manual)

So now the adverts will be loaded at the top of the playlist at 5:59:55, 8:59:55 and so on.

After the adverts have played RadioDJ goes in manual mode again. It will not clear the playlist of the DJ which has put the tracks in it. The only thing which happens automatically is that the adverts are added to the playlist at the selected day and hours. The DJ can see in the events button in the bottom of the screen when an event will be loaded.

You can also set a start date and end date when you import an advert track. So the track will not be played anymore when the end date has passed.

Just try it out and maybe this will suite your situation.

Hej Radio ► Netherlands
https://hejradio.jimdofree.com/

PROducer

Quote from: numbers1thru9 on May 06, 2018, 02:09:12 AMThis is the query im trying to figure out. HOW to add tracks to the top of the queue list? What does that query look like. Thats what i cant figure out as like i mentioned according to the SQL log it clears the queuelist table and then fills it back up as songs are added or played. Which is why i dont think that the queuelist table is how I add a song.
I'm currently in the same boat... trying to figure out how to put a request intro & song request at the top of the queue by SQL query BUT only if there is a request that hasn't played.  I'm going to suggest you look at https://www.w3schools.com/sql/default.asp for some help.  If I get any progress on my own I'll post on the forums.

numbers1thru9

Quote from: PROducer on May 06, 2018, 11:00:43 PM
I'm currently in the same boat... trying to figure out how to put a request intro & song request at the top of the queue by SQL query BUT only if there is a request that hasn't played.  I'm going to suggest you look at https://www.w3schools.com/sql/default.asp for some help.  If I get any progress on my own I'll post on the forums.

I think i have the query mostly straight. My problem is that from the logs and the way that the software performs the actions on the queuelist table, it looks like the queue is maintained within the software and not within the database. Thats why im trying to see if anyone knows if its possible to manipulate the queue from the database such as a SQL query that can add a song, or an external program trigger. Otherwise if I might have to look at writing my own custom plugin that can manipulate the queue from the software side.

numbers1thru9

OK, so I think I FINALLY found what I was looking for. Was kind of hard to find but just an FYI, it looks like there used to be a plugin called TCP server that was renamed to REST Plugin. THIS is how I can interact with the software to load a track. I can write a custom script that gets launched that will do my checks and act accordingly with the tracks I want to add to the playlist.