× Warning! This forum is in archival status. New contributions may not work.
Parse data from Airtime API
  • I am sure this is a simple task, I am just a little more simple. I am trying to parse the data (php)  returned from Airtime API 1.1  Live Info. I only need the title of the current track. Any suggestions?
  • 10 Comments sorted by
  • Thank you, That is the format of my data.  I need to Parse "current" "name" from it
  • Wow.If all my textbook was like that.

    Its Like the other day I stop to ask someone directions and This was the answer."isn't that a GPS navigation system"

    Come on write some Notes.
    I want to learn 
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Alright: Here it is :
      The goal is too have a form submit where users can rate a track and submit it.
    Form Submit => PHP (this is where the php has to get the current track and append it too their rating) => CSV.

    I was trying to use this guide http://sourcefabric.booktype.pro/airtime-25-for-broadcasters/exporting-the-schedule/
      The goal was to fit inside of a PHP script a way to return CURRENT=>NAME from the live info API.  I could not seem to get a valid response parsing it as "object" or "array".  Here is what I finally got to work.

    <?php
    $string = file_get_contents("/tmp/live-info"); //get my contents

    //there are a couple of extra charecters that needed to get stripped the first and last "(" and ")"
    $json = str_replace('***(', $callback, $string); 
    $json = rtrim($json, ')');

    $json_a = json_decode($json, true);
    echo $json_a['current'][name];
    ?>


    What I don't understand is that guide instructs calling the json string with the *** and then in the bash script strips it away. Can any one explain what is the reasoning? Is there a better way of doing this? Is their something I missed?
  • I am not too sure would have to do some research but I think my first reading of jsonp the *** was part of the information extracted from an array.
    This was different from json which was not cross browser  compatible.

    I might be wrong

    I do not use that approach

    Liquidsoap comes already with

    of_json

    where I can extract almost any data I want and guess what I do not have to worry about whether I  have a schedule Item or information from my modscript.

    I can extract all my songs or whatever played and the biggest plus,I only do one output script for

    tunein,mixcloud (experimental),soundcloud (experimental) and my history.

    I hope to adapt this to be include in the Gui this summer

    I tried your approach earlier and sought help,but no one could give me sufficient information 

    If I am not correct,I almost sure if you look at version 2 of the Api in 2.5.2,The **** is not extracted

    Good luck
    Noisses
    oops
    Voisses


    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • I can call without adding the "***" and it works.  If you can advise me on a better way to process this, I am open to any advice.  I have only been working with Airtime for about a month and could use the guidance.

    I am still on 2.5.1   I wanted to give 2.5.2 a minute to make sure it is stable.  If I install over top of my current install is there concern?
  • Oy... the only folks that should have access to that private Airtime server are you and your team. That's it! Setting it up where a public browser directly queries what decidedly should be a private airtime server is a recipe for security disaster.
  • Roger can you elaborate?
    Post edited by Tom Ruh at 2015-04-11 16:05:28
  • Although the question was directed to Roger let me shed a light light to the security issues.

    The world is not level (don't believe me ask a donkey,he was the one who said the world is not level),Therefore the day you set up any service that the public have direct contact with,you have to set up protection or security to prevent


    1. Unauthorised logins
    2. Malicious injections of codes and software
    3. Thieves,yes crooks from stealing your information
    4. Peeping toms who want to know exactly what you are doing to cod the same and better
    5. But worst of all those who will issue denial of service (DDOS) attacks that no-one else can see your servers or what you are showing. and even put there own propaganda on your servers.

    You therefore have to limit who can interface with your server

    The recommended approach  is Pushing schedule information via SFTP or SSH although the manual suggest Pushing schedule information via FTP or SSH to your public servers like a hosting company or website

    You should not have anything parsing data directly from Airtime,trolls will follow even with a web service like $_GET and $_POST. Read here http://sourcefabric.booktype.pro/airtime-25-for-broadcasters/exporting-the-schedule/

    I use to send data directly to a particular Rest API, everytime their severs go down mine locked up,so now I parse to a local server and send to them and any other .

    For Many months I used a simple raspberry pi with wheezy to do all my push and trust me it worked splendidly.

    So for those who cannot get a RPI , just get any old computer and put Xbuntu on it and you are set

    On the point of to use something else,The greatest beauty of open source is that you can have it your way.

    Whatever works for you,go ahead and use it.

    In my opinion 2.5.2 do not seems to ready for stable recommendation,its fancier but like any pretty things it comes with lot of complications.

    Give me a terminal where I can fix things anytime than thinking everything is perfect ang give me a stupid gui which none of the suggestions works to fixed my unique problem.

    So jump in the depth of 2.5.2,hope you donot drown




    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.