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

Plugin REST Server for RDJ 1.7.5+

Started by Marius, November 04, 2014, 02:10:52 PM

DJAntares

After I'ive installed the db server on a Virtualbox VM I 've configurated all plugins that i want bute this presents a problem very irritating.  :(
Tested in two different machines with the same db, with windows 10 x64 if RDJ go lanch normally it start very great   8) but the rest plugin don't start...
If i launch the RDJ "as administrator", the REST plugin start normally but RDJ is down (don't play anything) and the files that's catalogated as startion id comes disactived and can't be reactived.
If i close RDJ as administrator and if i reset these flags to database and then I launch RDJ normally from an user of administartor group, it starts normally but no the plugin.
Windows suggest this http://go.micorsoft.com/fwlink/?Linkld=70353 for this inconvenient but enabling also the .net 3.5 and the 2.0 on my machine this problem isn't solved  :'(

Marcob88

Hello

I wanted today to get the rest server working i thought it would be easy....serves me right .

Be as simple as i can.

I have just tried this on the local pc before worrying about network

I added Restserver from disabled plug ins to  the plug ins folder

I opened RDJ and went to the options and set a password, saved, closed RDJ, and rebooted RDJ

I went to the monitor utility opened up added the password and it comes up with  error...remote server returned an error( 400) bad request

I have done this opening RDJ normally as administrator and same with the monitor - if the ip is wrong it says it cannot connect to server , if i change the password it doesnt liek it and wants to close

I have just left default settings and changed password  in the rdj plug in options and matched it with monitor
monitor doesnt have http:// but i think that snormal
its not clear if you should be changing the ip to somehting specific, or it works with any ip or the default, the same with the port

i didnt think this would be sucha difficult task on a local machine

please help!

Marcob88

REolved!

For anyone with the same problem, make sure you are not over thinking this

I got the error because nothing was playing!

Now thats working i would like the rest server to listen to commands from another problem...this will be fun...sleep first...

DJAntares

Problem Solved!!!
It's necessary start a cmd as administrator and lunch this command:

netsh http add urlacl url="http://+:7000" user=user

;D

cutmaster

Hi everybody,
Tried to create a WordPress Web plugin to control RadioDJ but I'm facing an issue I don't actually know how to handle.
When I call RDJ, through a web interface, by calling its URL, say for exemple http://1.2.3.4:1234/np?auth=ThePassword the result is good, the page shows an XML with the now playing info.
Now, if I call the same URL through an ajax jQuery GET call, I get the following error :
XMLHttpRequest cannot load http://1.2.3.4:1234/np?auth=ThePassword. http://1.2.3.4 is not allowed by Access-Control-Allow-Origin
How is it possible to fix this ?
Thanks for your help.
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

Marius

Quote from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORSFor security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts.  For example, XMLHttpRequest follows the same-origin policy. So, a web application using XMLHttpRequest could only make HTTP requests to its own domain.

I'm not a js expert, so sadly i cannot give you a solution, but from what i read, you can use JSONP for GET requests methods, or CORS which has more methods, but i never test it.
DOWNLOADS PAGE

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

cutmaster

Yes think this is the way... It seems to be a common problem with REST servers using jQuery calls (or ajax one)... The problem seems to be the asynchronous call and the solution seems to be found in frames calling... I'm investigating and let everybody know the results here...
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

Valdis

Quote from: cutmaster on May 29, 2016, 10:40:20 AM
Now, if I call the same URL through an ajax jQuery GET call, I get the following error :
XMLHttpRequest cannot load http://1.2.3.4:1234/np?auth=ThePassword. http://1.2.3.4 is not allowed by Access-Control-Allow-Origin
How is it possible to fix this ?

Same-origin policy of AJAX calls is there for a reason - security. In theory RadioDJ REST server could allow cross-site AJAX calls by sending Access-Control-Allow-Origin: * response header, but that would require modifications of REST server plugin.
Easiest workaround would be to make all AJAX calls to a PHP script which forwards HTTP requests to RadioDJ server. PHP doesn't care about HTTP access control. You should take care to not expose the password in JavaScript and don't allow to call any random URLs using the PHP script.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

cutmaster

#98
Hi Marius,
Is there a way for you to make 2 or 3 modifications in the plugin REST like :
- Sending Allow-Control-Allow-Origin:*
- Add a command like command=wvf&id=[id of song] that will return say 512 values from 0 to 128 to represent briefly the waveform ?
- Add a command that lists the available playlist (meaning there's one to change it but no one to get them)
- Same for genres & subgenres ?
- Add a search command ?
- Maybe Add a command to get an xml returning only the artist name, title & id of a specified category ?
I'm trying to create an iOS app to control RadioDJ distantly and it would help to have a very sexy application around RadioDJ.
Thanks a lot :)
Have a nice day

[EDIT] also the ability to get the name of the instant players to add the ability to create a "touchable-launcher" should be great :)
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

cutmaster

Hi Guys (and Marius),
As explained in my post here : http://www.radiodj.ro/community/index.php?topic=8757.0
I'm creating an iOS App for controlling RDJ through the REST plugin.
It is actually working not bad, but it should be very great if REST can do a little bit more (for exemple getting the name & colors of the Instant players, or the actual state of RDJ regarding the mode AutoDJ, etc).
Marius, is there a way for you to add such functionalities... or for us to help you so ?
Thanks a lot to all.
Best :)

Laurent.
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

Feiko

Hi There,

Is it possible to start a rotation with the RestServer ??

Tnx
Feiko

cutmaster

As I actually know, it isn't possible unfortunately...
Really looking for more options on it too.
Marius, maybe can you provide us the source so we will be able to enhance it as a team ?
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

Valdis

Quote from: cutmaster on August 11, 2016, 09:45:07 PM
As I actually know, it isn't possible unfortunately...
Really looking for more options on it too.
Marius, maybe can you provide us the source so we will be able to enhance it as a team ?
I'm developing an improved RESTful server plugin. It responds with JSON, CORS (Access-Control-Allow-Origin and other headers) is already implemented and there is also basic authentication support. I'm currently working on command calls. This would be a good time to write down your wishlist.
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/

cutmaster

Hi Valdis,
This is really interesting. Well actually what can be a sort of help should be to add to the actual REST plugin commands (meaning don't remove the old one) :
- Get All Status in one command (and results to one xml) to limit the calls meaning :
    - Calling something like action=getAllStatus
    - Receiving XML having the information on actually playing or not, what is the current title (and time, remaining, etc same way like the actual REST plugin), AutoDJ is ON/OFF, Automated is ON/OFF, Input is ON/OFF, Instant Players informations (player id, song id, artist, title, duration)
    - Having the ability to request a search and get a result, even with limiting its contents per page (for example if the answer should return more than 100 tracks, add a <TotalResults>355</TotalResults> and a <StartedResultsFrom>0</StartedResultsFrom> so we can move on the page
    - Having the category list (id, name)
    - Having the ability to get the tracks contained in a category
    - Having the ability to get the rotation list and to change it
    - Having the ability to add a sweeper to a track
    - Being able to get the song history (limited by 100 maybe)

I think it should be sooooooo great :)

Thanks for that...
The Revival of WOW FM with Radio DJ

http://www.cloudrad.io/cutmaster

Best Dance Music from 80's, 90's to today

Valdis

Quote from: cutmaster on August 12, 2016, 07:16:03 PM
This is really interesting. Well actually what can be a sort of help should be to add to the actual REST plugin commands (meaning don't remove the old one) :
I've intended to retain commands from original REST plugin and add new ones.

Quote from: cutmaster on August 12, 2016, 07:16:03 PM
- Get All Status in one command (and results to one xml) to limit the calls meaning :
    - Calling something like action=getAllStatus
    - Receiving XML having the information on actually playing or not, what is the current title (and time, remaining, etc same way like the actual REST plugin), AutoDJ is ON/OFF, Automated is ON/OFF, Input is ON/OFF, Instant Players informations (player id, song id, artist, title, duration)
Combined status is available in original plugin. It is returned from /state URI, but does not have main player playing/stopped status and no current track. I have that in my plugin and I found a way to detect if main player is playing or stopped. I'm not sure if is possible to get paused status.

I have already implemented access to cart players (aka instant players) under /carts/{id} endpoint in my plugin.
The endpoint returns following JSON:

[
  {
    "Artist": "Radio Station",
    "ButtonIndex": 1,
    "CartID": 15,
    "Color": -32704,
    "Duration": 5.28771,
    "Title": "Some jingle",
    "TrackID": 31
  },
  {
    "Artist": "Radio Station",
    "ButtonIndex": 2,
    "CartID": 16,
    "Color": -65281,
    "Duration": 2.40365,
    "Title": "Other Jingle",
    "TrackID": 35
  }
]

It should be enough to reflect same information as RadioDJ carts plugin.

It makes sense to combined interface status with current track data and instant players. I'll add it to my TODO list.

Quote from: cutmaster on August 12, 2016, 07:16:03 PM
    - Having the ability to request a search and get a result, even with limiting its contents per page (for example if the answer should return more than 100 tracks, add a <TotalResults>355</TotalResults> and a <StartedResultsFrom>0</StartedResultsFrom> so we can move on the page
    - Having the category list (id, name)
    - Having the ability to get the tracks contained in a category
    - Having the ability to get the rotation list and to change it
    - Having the ability to add a sweeper to a track
    - Being able to get the song history (limited by 100 maybe)
Some of these are already implemented and I've added track search with pagination to my TODO list.

I have no plans to implement XML responses. To add optional XML responses, I would have to duplicate code all over the place, because I'm using WCF WebServiceHost with ServiceContract bindings. Using WCF is a pain and there are no alternatives for developing REST services on .NET 3.5.

I prefer JSON, because it is compact compared to XML and widely supported.

Do you prefer XML over JSON? If so, why?
I am, therefore I think.
I design and develop web apps, and have created few RadioDJ plugins - https://axellence.lv/downloads/