Skip to Content
It is currently November 11th, 2019, 7:53 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: June 4th, 2015, 6:42 am 
Offline
New User
New User

Joined: June 4th, 2015, 6:17 am
Posts: 5
Ok, I'm actually just a listener :)
A few days ago, tho, my favourite station switched from radiotuna to spacial and now my "nowplaying" script for twitter stopped working, i.e. I just can't figure out how to poll track info.
Your api looks kinda promising, yet the only command I found so far is
/api/rest/station-info-service/get-sv-player-info
Is there a manual for this?
What I'd need to know is if something like "get-track-info" exists and its correct use :)
Any help is appreciated
Thanks


Top
 Profile  
Reply with quote  
PostPosted: June 4th, 2015, 6:00 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7880
Location: Aachen (Germany)
Spacial actually offers three types of streaming services.
SAM Vibe => Automation in the Cloud
Cheapeststream => Traditional Stream hosting with limited options and cheap prices
SpacialNet => Traditional Stream hosting with more options and higher prices

The first one has an API, but that's undocumented and thought for internal use only.
For reverse engineering that, you might want to have a look at the Web widget of SAM Vibe.

The other two have no API at all. They are just basic Shoutcast (v1/v2) or Windows Media Servers and expose the default statistics interfaces over HTTP as these servers always do.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 4th, 2015, 6:42 pm 
Offline
New User
New User

Joined: June 4th, 2015, 6:17 am
Posts: 5
Mastacheata wrote:

The first one has an API, but that's undocumented and thought for internal use only.
For reverse engineering that, you might want to have a look at the Web widget of SAM Vibe.

I did that.
But the only thing I was able to catch via fiddler was the initial station info.
All the other data seems to be polled "internally" with just a javascript event subscription to update specific html elements.
I also let wireshark loose on it and found that the info is also sent within the "lame" mp3 header frames.
It's just that it'd be total overkill to scavenge these bits of data that way.
So a nice clean request & json response would be very helpful 8)


Top
 Profile  
Reply with quote  
PostPosted: June 4th, 2015, 7:28 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7880
Location: Aachen (Germany)
Wow, looks like you dug deeper than I ever did.
The problem is that this is not a public API. It's a REST webservice, but only for internal use (the web widgets in particular).
Therefore no public documentation exists. (I have no idea if there is ANY documentation at all or if this knowledge is just shared "under the hand" between devs working on that part)

You COULD try and ask spacial support about the API. However chances are rather slim that they will reveal anything.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2015, 12:39 am 
Offline
New User
New User

Joined: June 4th, 2015, 6:17 am
Posts: 5
Oh well, thanks anyway :)

I might be able to draw info from their tunein, too. But I noticed they don't update it that regularly. Often enough it just displays the name of the show/DJ itself.

No real bigge. No one's life gonna change if I drop the station from my polling list for now :lol:
I will keep an eye on it if something crops up, tho :)

Never had this kind of problem with other stations, no matter which system they were using. Maybe I was just lucky. For example, BBC can be polled directly (http://polling.bbc.co.uk/radio/realtime ... _two.jsonp), radiotuna offers a "backpassage", as does streamlicensing.


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2015, 1:42 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7880
Location: Aachen (Germany)
I didn't have time to look into the Web widgets myself yesterday, but now I did.
In fact it's pretty easy to get all the info you like.

The API looks like this:

Queue/Coming up:
Code:
https://samweb.spacialaudio.com/webapi/station/<SID>/queue?token=<token>&top=<count>&format=json&callback=cb

Example: https://samweb.spacialaudio.com/webapi/ ... allback=cb

History/Recently played:
Code:
https://samweb.spacialaudio.com/webapi/station/<SID>/history?token=<token>&top=<count>&format=json&callback=cb

Example: https://samweb.spacialaudio.com/webapi/ ... allback=cb

Response Format is JSONP (a human can easily decode JSON from that, it's basically a JavaScript function call with an object containing the result as the sole parameter)


You can get the SID from the listen link for normal players. The token is the last part of the id of the div where the widget is rendered in.
This for example would be the widget for one of my SAM Vibe stations:
Code:
<div id='widgets-now--63a5dd2a3dcfe97a2488ee866e360404970353d4'></div>

The widget script extracts the token as whatever is written after the third - in the id attribute.

If you don't want to code yourself, the API script is pretty well readable (at least if you skip the first couple hundred lines that just contain a minified version of jQuery and only read the code written by Spacial)
http://media.spacial.com/widgets/samcloud-webapi.js

And this would be the widget script that calls the API functions and renders the Widget in HTML:
http://media.spacial.com/widgets/widget ... pe=defined

The API has different base URLs depending on the environment, but I think all the SAM Vibe instances "out in the wild" run on the production environment.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2015, 5:08 pm 
Offline
New User
New User

Joined: June 4th, 2015, 6:17 am
Posts: 5
Wow.
Thank you so much!

This part of the app is now up and tweeting again :D

These request not showing up in any sniffing tools puzzled me to no end. Having breakpoints in the respective functions (those that are handling the updates to the controls) didn't help much either. The script seems to get reloaded over and over, so the breakpoints become void.
Thanks again :mrgreen:


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2015, 6:41 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 7880
Location: Aachen (Germany)
Sometimes it helps just reading the code ;)

I'd be interested in seeing what you built from the API, though.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

We're offering custom PAL / PHP code and general SAM assistance at palscripts.com

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: June 5th, 2015, 11:05 pm 
Offline
New User
New User

Joined: June 4th, 2015, 6:17 am
Posts: 5
Mastacheata wrote:
I'd be interested in seeing what you built from the API, though.

Just a tiny .net/C# app, polling info from various stations, checking it against a "white list" of my favourite artists and songs, and firing off tweets whenever there's a match :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group