Is there a script that sends Artist and Title via an curl command?
Like
curl http://127.0.0.1:8010/?cmd=NOW:You%20are%20listening%20to%20Queen%20-%20Show%20must%20go%20on
Is there a script that sends Artist and Title via an curl command?
Like
curl http://127.0.0.1:8010/?cmd=NOW:You%20are%20listening%20to%20Queen%20-%20Show%20must%20go%20on
I tried this:
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
ShellExecute(‘curl’ , ‘http://127.0.0.1:8010/?cmd=NOW:%a%20-%20%b’ );
end;begin
end.
But nothing happens
curl http://127.0.0.1:8010/?cmd=NOW:You%20are%20listening%20to%20Queen%20-%20Show%20must%20go%20on
Works fine from the command prompt.
See oas:api [AstraStudio Wiki]
Any ideas? (I suck with Scripting)
The %
-variables do not work if built into a script. Maybe you should try
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
ShellExecute('curl', 'http://127.0.0.1:8010/?cmd=NOW: ' + Item.GetArtist + ' - ' + Item.GetTitle);
end;
begin
end.
(Untested. You try.)
You might have a shot at ShellExecuteHidden
, if convenient.
(Please make sure that code gets the appropriate format on posting as the clever forum software is handling the apostrophes in its very own way. And else.)
Formatted regards
TSD
Just found Ansteuerung des OnAirScreen
Got it running now
Got only one issue…
I only want to display the Tags of Dummy, Music and News
This is disabled in my normal Textfile Logging…
Is this possible?
const
iMax = 5; // Hier die maximale Senderanzahl einsetzen
IP = '192.168.51.103'; // <-- IP-Adresse
PORT = '3310'; // <-- Port
PATH = 'C:\ProgramData\mAirList\6.1\sfk174.exe'; // <-- Pfad
var
sl: TStringList;
pi: IPlaylistItem;
idx, c, i: integer;
EncoderState: array[0 .. iMax] of integer;
procedure PostOnAirScreen(Befehl: string);
begin
ShellExecuteHidden (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Befehl + Chr(34) + Chr(32) + '-quiet');
//ShellExecute (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Befehl + Chr(34));
end;
procedure OnLoad;
begin
// Eigentlich muss das nicht mal bei jedem Ladevorgang neu passieren aber so sind wir sicher, dass da keiner was verfummelt hat
// und man kann relativ komfortabel die Konfiguration anpassen ohne dass man an die eigentliche Anzeige ran muss
PostOnAirScreen('CONF:LED2:autoflash=True'); // Diese Anzeige soll blinken, blinkede Anzeigen sehen immer wichtig aus.
PostOnAirScreen('CONF:LED2:text=EOF'); // Auf dem Button soll EOF stehen.
PostOnAirScreen('CONF:CONF:APPLY=TRUE');
PostOnAirScreen('LED1:OFF');
PostOnAirScreen('LED2:OFF');
PostOnAirScreen('LED3:OFF');
PostOnAirScreen('LED4:OFF');
PostOnAirScreen('AIR4:OFF');
PostOnAirScreen('AIR4:RESET');
end;
procedure OnRuntimeDataChange(Key, Value: string);
begin
if Key = 'EncoderStatus' then begin
if Value = ('false') then begin
PostOnAirScreen('AIR4:OFF');
PostOnAirScreen('AIR4:RESET');
end
else begin
PostOnAirScreen('AIR4:ON');
end;
end
else if Key = 'GamepadStatus' then begin
PostOnAirScreen(Value);
end
else if Key = 'EncoderError' then begin
PostOnAirScreen(Value);
end;
end;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Das war kein Element aus unserer Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(pi.GetArtist + Chr(32) + '-' + Chr(32) + pi.GetTitle );
c := c + 1;
idx := idx + 1;
end;
PostOnAirScreen('NOW:' + sl[0] );
PostOnAirScreen('NEXT:' + sl[1] );
sl.Free;
end;
procedure OnOnAir;
begin
PostOnAirScreen('LED1:ON');
end;
procedure OnOffAir;
begin
PostOnAirScreen('LED1:OFF');
end;
procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
begin
PostOnAirScreen('LED2:ON');
end;
//procedure OnPlayerStop(PlaylistIndex: integer; PlayerIndex: integer; Duration: TTimeValue; Item: IPlaylistItem);
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
PostOnAirScreen('LED2:OFF');
end;
procedure OnShutdown; // Sollte den Rechner mit den OnAirScreen herunterfahren, funktioniert bisher aber nicht.
begin
PostOnAirScreen('CMD:SHUTDOWN');
end;
begin
end.
EDIT by Mod: formatted to code
. Please use </>
on marked up text.
Thank you.
Should be:
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
ShellExecute('curl', 'http://127.0.0.1:8010/?cmd=NOW: ' + Item.GetArtist + ' - ' + Item.GetTitle);
end;
begin
end.
Or else?
Edit: Too late, or Sunday evening too busy …
Excellent, Thank you!
Now using the code below, it is putting the Artist and Title, however when Artist is: Blue Öyster Cult it won’t (goes for all with special characters)
Any thoughts?
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(pi.GetArtist + Chr(32) + '-' + Chr(32) + pi.GetTitle );
c := c + 1;
idx := idx + 1;
end;
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
PostOnAirScreen('NOW:' + sl[0] );
sl.Free;
end;
Try rounding up the usual suspects that way:
Ouch that’s way over my Head…
Afraid i ruin the whole script…
function Escape(Oldstring: string): string;
var
Newstring, Part: string;
i: integer;
begin
Newstring := '';
for i := 1 to Length(Oldstring) do
begin
Part := Copy(Oldstring, i, 1);
if Part = 'ä' then
Part := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'Ã¥' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Ã…' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
else if Part = 'ñ' then
Part := 'n'
else if Part = 'Ñ' then
Part := 'N';
Newstring := Newstring + Part;
end;
Result := Newstring;
end;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(Escape(pi.GetArtist) + Chr(32) + '-' + Chr(32) + Escape(pi.GetTitle));
c := c + 1;
idx := idx + 1;
end;
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
PostOnAirScreen('NOW:' + sl[0]);
sl.Free;
end;
Please post code completely, otherwise it is impossible to track errors.
const
iMax = 5;
IP = '10.0.0.151';
PORT = '3310';
PATH = 'C:\sfk174.exe';
var
sl: TStringList;
pi: IPlaylistItem;
idx, c, i: integer;
EncoderState: array[0 .. iMax] of integer;
procedure PostOnAirScreen(Command: string);
begin
ShellExecuteHidden (PATH, 'udpsend ' + IP + Chr(32) + PORT + Chr(32) + Chr(34) + Command + Chr(34) + Chr(32) + '-quiet');
end;
procedure OnLoad;
begin
// PostOnAirScreen('CONF:LED2:autoflash=True');
// PostOnAirScreen('CONF:LED2:text=EOF');
// PostOnAirScreen('CONF:CONF:APPLY=TRUE');
// PostOnAirScreen('LED1:OFF');
// PostOnAirScreen('LED2:OFF');
// PostOnAirScreen('LED3:OFF');
// PostOnAirScreen('LED4:OFF');
PostOnAirScreen('AIR4:ON');
// PostOnAirScreen('AIR4:RESET');
end;
procedure OnRuntimeDataChange(Key, Value: string);
begin
if Key = 'EncoderStatus' then begin
if Value = ('false') then begin
PostOnAirScreen('AIR4:OFF');
PostOnAirScreen('AIR4:RESET');
end
else begin
PostOnAirScreen('AIR4:ON');
end;
end
else if Key = 'GamepadStatus' then begin
PostOnAirScreen(Value);
end
else if Key = 'EncoderError' then begin
PostOnAirScreen(Value);
end;
end;
function Escape(Oldstring: string): string;
var
Newstring, Part: string;
i: integer;
begin
Newstring := '';
for i := 1 to Length(Oldstring) do
begin
Part := Copy(Oldstring, i, 1);
if Part = 'ä' then
Part := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'Ã¥' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Ã…' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
else if Part = 'ñ' then
Part := 'n'
else if Part = 'Ñ' then
Part := 'N';
Newstring := Newstring + Part;
end;
Result := Newstring;
end;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
idx := CurrentPlaylist.IndexOf(item);
if idx = -1 then begin
SystemLog('Niets in de Playlist ...');
exit;
end;
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 2) do begin
pi := CurrentPlaylist.GetItem(idx);
sl.Add(Escape(pi.GetArtist) + Chr(32) + '-' + Chr(32) + Escape(pi.GetTitle));
c := c + 1;
idx := idx + 1;
end;
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
PostOnAirScreen('AIR4:RESET');
PostOnAirScreen('NOW:' + sl[0]);
sl.Free;
end;
// procedure OnOnAir;
// begin
// PostOnAirScreen('LED1:ON');
// end;
// procedure OnOffAir;
// begin
// PostOnAirScreen('LED1:OFF');
// end;
procedure OnPlayerEOFWarning(PlaylistIndex: integer; PlayerIndex: integer);
begin
PostOnAirScreen('LED2:ON');
end;
procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
begin
PostOnAirScreen('LED2:OFF');
end;
begin
end.
Yep. Should work now, doesn’t it?
Looks like it is, only got suddenly the Jingles displayed again.
So I moved the pitMusic and other pit entries a few steps up in the script.
It’s promising
Thanks for your assistance
Working great…
Only one more issue.
When having:
Song 1
Jingle
Song 2
Song 3
When the Jingle starts, it writes the contents of Song3
When Song 2 Starts, the data for song 2 is displayed.
Little oversight?
BTW: I use 2 Players in this sytem
found the issue…
sl := TStringList.Create;
c := 0;
while (idx < CurrentPlaylist.GetCount) and (c < 1) do begin **// was: (c < 2)**
pi := CurrentPlaylist.GetItem(idx);
sl.Add(Escape(pi.GetArtist) + Chr(32) + '-' + Chr(32) + Escape(pi.GetTitle));
c := c + 1;
idx := idx + 1;
end;
Did you try the code I gave you here: Now playing via CURL command?
Initially you asked for some method to send strings via curl, which you got meanwhile. Later on you came up with some complicated code using a very different programme (sfk174.exe). Debugging the latter (most of which you probably do not need anyway) ist taking too much time, so may I ask you to try it with the lightweight version first, please?
The complete code should look like this:
function Escape(Oldstring: string): string;
var
Newstring, Part: string;
i: integer;
begin
Newstring := '';
for i := 1 to Length(Oldstring) do
begin
Part := Copy(Oldstring, i, 1);
if Part = 'ä' then
Part := 'ae'
else if (Part = 'ö') OR (Part = 'ø') OR (Part = 'œ') then
Part := 'oe'
else if Part = 'ü' then
Part := 'ue'
else if Part = 'Ã¥' then
Part := 'aa'
else if Part = 'Ä' then
Part := 'Ae'
else if (Part = 'Ö') OR (Part = 'Ø') OR (Part = 'Œ') then
Part := 'Oe'
else if Part = 'Ü' then
Part := 'Ue'
else if Part = 'Ã…' then
Part := 'aa'
else if Part = 'ß' then
Part := 'ss'
else if Part = 'ñ' then
Part := 'n'
else if Part = 'Ñ' then
Part := 'N';
Newstring := Newstring + Part;
end;
Result := Newstring;
end;
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer;
Item: IPlaylistItem);
begin
if (Item.GetItemType = pitMusic) OR
(Item.GetItemType = pitDummy) OR
(Item.GetItemType = pitNews) then
ShellExecuteHidden('curl', 'http://127.0.0.1:8010/?cmd=NOW: '
+ Escape(Item.GetArtist) + ' - ' + Escape(Item.GetTitle));
end;
begin
end.
I stopped using CURL
It’s working perfect now… see my last reply.
Changed (c < 2) into (c < 1)
Too slow … again!
How do you mean Slow?