Author Topic: Plugin REST Server for RDJ 1.7.5+  (Read 61716 times)

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Plugin REST Server for RDJ 1.7.5+
« on: November 04, 2014, 02:10:52 PM »
Due the problems with TCP Server plugin, i decided myself to re-write it and make it more powerful.

This plugin will replace soon the TCP server plugin, as it's much easier to use and allows you to interact in a more advanced way with RadioDJ.

The plugin settings are kept simple, you must enter the local IP:port to which the plugin will listen for commands, eg: http://127.0.0.1:7000 for localhost. Also, you must enter a password for command validation, like in plugin TCP server.

There are 4 implemented sections:
1. Commands section, which can be accessed like this:
http://127.0.0.1:7000/opt?auth=[password]&command=[command]&arg=[argument]

You must replace the brackets and its content with the password, command and when needed with the argument, like this:
http://127.0.0.1:7000/opt?auth=changeme&command=PlayPlaylistTrack&arg=0

The implemented commands so far are:

Code: [Select]
        PlayPlaylistTrack 'Zero based track number from playlist
        RemovePlaylistTrack 'Zero based track number from playlist
        StopPlayer
        PausePlayer 'arg=0 to unpause, 1 to pause
        RestartPlayer
        PlayFromIntro
        ClearPlaylist
        LoadTrackToTop 'Song ID as argument
        LoadTrackToBottom 'Song ID as argument
        LoadPlaylist 'Playlist ID as argument
        EnableAutoDJ 'arg=0 to disable, 1 to enable
        EnableAssisted 'arg=0 to disable, 1 to enable
        EnableEvents 'arg=0 to disable, 1 to enable
        RefreshEvents
        EnableInput 'arg=0 to disable, 1 to enable
        PlaycartByNumber 'cart number as argument
        StatusAutoDJ 'Get the status of AutoDJ option as boolean
        StatusAssisted 'Get the status of Assisted option as boolean
        StatusInput 'Get the status of Input option as boolean
        StatusQueue 'Get queue playlist number of tracks
        ShowMessage 'Display a message in RadioDJ. Message as argument

The second section is for getting the now playing details and can be accessed like this:
http://127.0.0.1:7000/np?auth=[password]

The third section is for getting the playlist:
http://127.0.0.1:7000/p?auth=[password]

[UPDATE] From version 1.1 of the plugin, the playlist will contain at the first position the now playing track in order to avoid multiple queries.

And, the last section is for getting details about a specific track from the playlist:
http://127.0.0.1:7000/pitem?auth=[password]&arg=[zero based track number from the playlist]

For each section the response is XML formatted, so it's much easier to parse it.

For example the now playing section will return something like:

Code: (xml) [Select]
<?xml version="1.0" encoding="UTF-8"?>
<SongData xmlns="http://schemas.datacontract.org/2004/07/rdjInterface" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <Album>Bravo Hits Vol. 86</Album>
   <AlbumArt />
   <Artist>Clean Bandit Feat. Sharna Bass</Artist>
   <ArtistPlayed>2014-11-04T19:01:24</ArtistPlayed>
   <AutoFree>true</AutoFree>
   <AutoStop>false</AutoStop>
   <BPM>0</BPM>
   <BuyLink />
   <Comments />
   <Composer />
   <Copyright />
   <CountPlayed>0</CountPlayed>
   <CueTimes>&amp;sta=0.01&amp;xta=254.382358276644&amp;end=255.872358276644&amp;fin=0&amp;fou=1.49000000000001</CueTimes>
   <DatePlayed>2002-01-01T00:00:01</DatePlayed>
   <DateRequested>0001-01-01T00:00:00</DateRequested>
   <DiscNo>0</DiscNo>
   <Duration>254.372358276644</Duration>
   <Elapsed>194.80102040816328</Elapsed>
   <Enabled>true</Enabled>
   <EndDate>2002-01-01T00:00:01</EndDate>
   <FadeIn>0</FadeIn>
   <FadeOut>1.49000000000001</FadeOut>
   <FadeType>0</FadeType>
   <HasHooks>false</HasHooks>
   <HighPrecision>0</HighPrecision>
   <ID>268</ID>
   <IDGenre>168</IDGenre>
   <IDSubcat>6</IDSubcat>
   <Isrc />
   <LimitAction>0</LimitAction>
   <OriginalArtist />
   <Path>Y:\music\03 Club &amp; House\17 - HOUSE 2014\Clean Bandit Feat. Sharna Bass - Extraordinary.mp3</Path>
   <PlayLimit>0</PlayLimit>
   <PlayOnMainMixer>true</PlayOnMainMixer>
   <PlayerID>-1342177134</PlayerID>
   <Position>194.81102040816327</Position>
   <Publisher />
   <Remaining>59.571337868480725</Remaining>
   <RequestMessage />
   <RequestUser />
   <StartDate>2002-01-01T00:00:01</StartDate>
   <Sweepers />
   <Title>Extraordinary</Title>
   <TrackNo>0</TrackNo>
   <TrackType>Music</TrackType>
   <Weight>50</Weight>
   <WithLoop>false</WithLoop>
   <Year>2014</Year>
   <bCueDuration>45134120</bCueDuration>
   <bCueEnd>45135884</bCueEnd>
   <bCueIntro>0</bCueIntro>
   <bCueLoopIn>0</bCueLoopIn>
   <bCueLoopOut>0</bCueLoopOut>
   <bCueNext>44873048</bCueNext>
   <bCueOutro>0</bCueOutro>
   <bCueStart>1764</bCueStart>
   <bPosition>34364664</bPosition>
   <bcueHookIN>0</bcueHookIN>
   <bcueHookOut>0</bcueHookOut>
   <cueEnd>255.872358276644</cueEnd>
   <cueHookIN>0</cueHookIN>
   <cueHookOut>0</cueHookOut>
   <cueIntro>0</cueIntro>
   <cueLoopIn>0</cueLoopIn>
   <cueLoopOut>0</cueLoopOut>
   <cueNext>254.382358276644</cueNext>
   <cueOutro>0</cueOutro>
   <cueStart>0.01</cueStart>
   <isOverlay>0</isOverlay>
   <isPodcast>0</isPodcast>
   <swFirst>false</swFirst>
   <swID>-100</swID>
   <swName />
   <swPlay>0</swPlay>
   <vtID>0</vtID>
   <vtName />
   <vtPlay>-100</vtPlay>
</SongData>

As you see, it exposes all internal data about the track.

The plugin can be downloaded from the downloads page.

PS: In order to use this plugin from the internet, you will need to make sure that the used port is open on your firewalls.

PS2: The ShowMessage command will only work with the next version of RadioDJ.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #1 on: November 04, 2014, 03:16:11 PM »
A simple now playing info implementation using this plugin (needs php5+) (Updated for plugin Rest Server v1.1):

Code: [Select]
<!DOCTYPE html>
<head>
    <title>Now Playing Info</title>
<meta charset="utf-8">
</head>
<body>

<?php

$xml
=simplexml_load_file("http://127.0.0.1:7000/np?auth=changeme");
//print_r($xml) . "<br>";
echo "Artist: " $xml->Artist "<br>";
echo 
"Title: " $xml->Title "<br>";
echo 
"Album: " $xml->Album "<br>";
echo 
"Track Type: " $xml->TrackType "<br>";
echo 
"Remaining: " gmdate("H:i:s"round($xml->Remaining)) . "<br>";
?>


</body>
</html>

The output is this:
Code: [Select]
Artist: Skepta Feat D Double E, Tempa T, President T, Sox & Jay
Title: That's Not Me (Remix)(Explicit Edit)
Album: The Official Uk Top 40 Singles Chart 15-06-2014
Track Type: Music
Remaining: 00:02:24
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

TQ

  • Sr. Member

  • Online
  • ****
  • 291
  • Personal Text
    Perseverance is everything!
    • Emen Valley Radio
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #2 on: November 04, 2014, 03:45:25 PM »
Bravo Marius
TQ
A problem is only a problem if you can't find the solution.

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #3 on: November 05, 2014, 09:28:38 PM »
I released a new version (v1.1) which is more faster and i added to the archive also the Monitor utility.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

nemoradio

  • Full Member

  • Offline
  • ***
  • 213
    • NEMO Radio
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #4 on: November 05, 2014, 09:58:24 PM »
Hi Marius !
Great job as usually ! I cannot get it working, see the attached windows error). What can i do ? Thank you !

[attachment deleted by admin]
www.nemoradio.fr

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #5 on: November 05, 2014, 10:20:34 PM »
Try to run rdj as administrator. It seems that the plugin doesn't have the necessary rights to run.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

aus10hollis

  • Full Member

  • Offline
  • ***
  • 182
    • Victory 91.5fm
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #6 on: November 06, 2014, 12:35:27 AM »
From quickly testing it, I like the idea! The monitor is really neat :) Do you plan on putting any buttons into the monitor? Thanks for what you do!!
Austin Hollis
Victory 91.5fm
https://victory.radio

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #7 on: November 06, 2014, 11:04:59 AM »
Hmm, the idea of the monitor is not to control the system, but having the option to see what is playing and what is will play next. Maybe useful for bigger studios where the presenter is not at the rdj computer. For that scenario may be unpleasant if someone else would modify the playlist or start/stop the system by accident...

But reading your needs from the other topic, i will figure out a way to safely combine them
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

aus10hollis

  • Full Member

  • Offline
  • ***
  • 182
    • Victory 91.5fm
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #8 on: November 07, 2014, 12:45:13 AM »
Just wanted to say thanks again for adding the REST plugin.

I'm going to start working on a web interface for our radio station tomorrow and when I finish, I'll upload the source code for others to use.
Austin Hollis
Victory 91.5fm
https://victory.radio

starm

  • Jr. Member

  • Offline
  • **
  • 90
    • https://j2sd.fr
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #9 on: November 07, 2014, 11:07:26 AM »
I have a probleme

i am french, my english is very bad

i am Windows Vista sp2

[attachment deleted by admin]
https://j2sd.fr

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #10 on: November 07, 2014, 12:10:23 PM »
Please press details button when the error appears and post the content here.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

starm

  • Jr. Member

  • Offline
  • **
  • 90
    • https://j2sd.fr
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #11 on: November 07, 2014, 12:16:12 PM »
Code: [Select]
Consultez la fin de ce message pour plus de détails sur l'appel du débogage
juste-à-temps (JIT) à la place de cette boîte de dialogue.

************** Texte de l'exception **************
System.InvalidCastException: La conversion de la chaîne "157.90009070294747" en type 'Double' n'est pas valide. ---> System.FormatException: Le format de la chaîne d'entrée est incorrect.
   à Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
   à Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   --- Fin de la trace de la pile d'exception interne ---
   à Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   à Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value)
   à RadioDJ_Monitor.MainForm.UpdateData()
   à RadioDJ_Monitor.MainForm.Timer1_Tick(Object sender, EventArgs e)
   à System.Windows.Forms.Timer.OnTick(EventArgs e)
   à System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Assemblys chargés **************
mscorlib
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4253 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
RadioDJ Monitor
    Version de l'assembly : 1.0.0.0
    Version Win32 : 1.0.0.0
    CodeBase : file:///E:/RadioDJ/Plugins/RadioDJ%20Monitor/RadioDJ%20Monitor.exe
----------------------------------------
Microsoft.VisualBasic
    Version de l'assembly : 8.0.0.0
    Version Win32 : 8.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4253 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Windows.Forms.resources
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_fr_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
System.Data
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4253 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4252 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
mscorlib.resources
    Version de l'assembly : 2.0.0.0
    Version Win32 : 2.0.50727.4253 (VistaSP2GDR.050727-4200)
    CodeBase : file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualBasic.resources
    Version de l'assembly : 8.0.0.0
    Version Win32 : 8.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase : file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic.resources/8.0.0.0_fr_b03f5f7f11d50a3a/Microsoft.VisualBasic.resources.dll
----------------------------------------

************** Débogage JIT **************
Pour activer le débogage juste-à-temps (JIT), le fichier de configuration pour cette
application ou cet ordinateur (machine.config) doit avoir la valeur
jitDebugging définie dans la section system.windows.forms.
L'application doit également être compilée avec le débogage
activé.

Par exemple :

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Lorsque le débogage juste-à-temps est activé, les exceptions non gérées
seront envoyées au débogueur JIT inscrit sur l'ordinateur
plutôt que d'être gérées par cette boîte de dialogue.

https://j2sd.fr

Marius

  • Administrator
  • Hero Member

  • Offline
  • *****
  • 5479
    • Radio DJ Romania
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #12 on: November 07, 2014, 01:08:04 PM »
The only way i could replicate the problem was to set my location to France, so it could be something related to your locales. However i fixed it.
Please download RadioDJ monitor v1.1 from here: http://www.radiodj.ro/download/beta-utils/RadioDJMonitorV1.1.zip
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

nemoradio

  • Full Member

  • Offline
  • ***
  • 213
    • NEMO Radio
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #13 on: November 07, 2014, 01:24:09 PM »
Hi !

I'm also french and i also couldn't make it work yesterday. RDJ interface was frozen while le music was keep playing when i tried to connect. But without any error message from my windows 7 pro 64bits. I'll try this new version ASAP ! Thanks Marius !
www.nemoradio.fr

starm

  • Jr. Member

  • Offline
  • **
  • 90
    • https://j2sd.fr
Re: Plugin REST Server for RDJ 1.7.5+
« Reply #14 on: November 07, 2014, 02:27:29 PM »
Thank you Marius
The software works well with this version

 ;D
https://j2sd.fr