Jump to content

WPBK FM

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by WPBK FM

  1. Hey there,

     

    I gotta say I am new to this forum and new to PHP. I found a script online that sends NOW PLAYING data, from a text file, to a shout cast server.

    We're not using shout cast and I need to modify this script to make it work with TuneIn AIR API.

     

    The script is based on this server URL:

    Quote

    http://myusername:pass@192.168.1.22:8543/admin/metadata?mount=/live&mode=updinfo&song=somesongandartist

     

    Though TuneIn uses a different URL and API

    Quote

    http://dev.radiotime.com/opml/playing.ashx?partnerId=<p_id>&partnerKey=<p_key>&id=<id>&title=Larry+Song&artist=Larry+Artist

     

    I currently don't have the PartnerID and PartnerKey but that should be easy to replace in the script.

     

    I'm calling everyone on this forum to help me out with this and change the code to make this script work.

    I would appreciate it very much!!

     

    The text file I am using also uses a different format:  Name/Artist/Title/Album/Genre/Year/Time

     

    ("/" is the seperator)

     

    I don't want to send the name, album, genre and time

     

    Heres more information on the TuneIN API: http://tunein.com/broadcasters/api/

     

    I'm a radio guy and not not a coder. Thats why I ask for this big favor.

     

    Thank you very much.

     

    WPBK FM

     

    This is the script:

    I don't think a server login is required with TuneIn. The data is formatted sent to the URL including the unique ID's etc.

     

    <?php

    /**

    * This program will check a file every 5 seconds to see if it has changed...if it has, the new metadata will be sent to the icecast server(s)

    */

     

    //the path to the file where your song information is placed...please see below notes for formatting of metadata

    DEFINE('songfile', "C:\Users\pvcsnathan\Desktop\file.txt");

     

     

    //simply copy and paste this code block for each server you need to add

    $serv["host"][] = "127.0.0.1"; //ip or hostname the server is running on

    $serv["port"][] = 8000; //port the server is running on

    $serv["mount"][] = "/mount"; //this format: /mount

    $serv["user"][] = "user"; //icecast server username

    $serv["passwd"][] = "changeme"; //icecast server password

     

     

    while(1)

    {

        $t=time();

        clearstatcache();

        $mt=@filemtime(songfile);

        if ($mt===FALSE || $mt<1)

        {

            echo "file not found, will retry in 5 seconds";

            sleep(5);

            continue;

        }

     

        if ($mt==$lastmtime)

        {

            //file unchanged, will retry in 5 seconds

            sleep(5);

            continue;

        }

       

        $da="";

        $f=@fopen(songfile, "r");

        if ($f!=0)

        {

            $da=@fread($f, 4096);

            fclose($f);

     

            /**

            * Assuming that the file is in this format:

            *

            * Title: Superhero

            * Artist: Jane's Addiction

            * Time: N/A

            */

           

            //separate our file by lines

            $explode_da=explode("\n", $da);

           

            if(is_array($explode_da))

            {

                //remove "Title: "

                $title=preg_replace("/Title: /", '', $explode_da[0]);

               

                //remove "Artist: "

                $artist=preg_replace("/Artist: /", '', $explode_da[1]);

               

                //our metatdata to send to the server

                $final_metadata=urlencode(trim($artist.' - '.$title));

            }

            else

            {

                $final_metadata=urlencode("Parse Error - Please Check Your Output File");

            }

        }

        else

        {

            echo "error opening songfile, will retry in 5";

            sleep(5);

            continue;

        }

       

        $lastmtime=$mt;

       

        for($count=0; $count < count($serv["host"]); $count++)

        {

            $mysession = curl_init();

            curl_setopt($mysession, CURLOPT_URL, "http://".$serv["host"][$count].":".$serv["port"][$count]."/admin/metadata?mount=".$serv["mount"][$count]."&mode=updinfo&song=".$final_metadata);

            curl_setopt($mysession, CURLOPT_HEADER, false);

            curl_setopt($mysession, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($mysession, CURLOPT_POST, false);

            curl_setopt($mysession, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

            curl_setopt($mysession, CURLOPT_USERPWD, $serv["user"][$count].":".$serv["passwd"][$count]);

            curl_setopt($mysession, CURLOPT_FOLLOWLOCATION, true);

            curl_setopt($mysession, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");

            curl_setopt($mysession, CURLOPT_CONNECTTIMEOUT, 2);

            curl_exec($mysession);

            curl_close($mysession);

        }

       

        echo "song updated";

       

        sleep(5);

    }

    ?>

  2. Hey there,

     

    I gotta say I am new to this forum and new to PHP. I found a script online that sends NOW PLAYING data, from a text file, to a shout cast server.

    We're not using shout cast and I need to modify this script to make it work with TuneIn AIR API.

     

    The script is based on this server URL:

     

    Though TuneIn uses a different URL and API

     

    I currently don't have the PartnerID and PartnerKey but that should be easy to replace in the script.

     

    I'm calling everyone on this forum to help me out with this and change the code to make this script work.

    I would appreciate it very much!!

     

    I'm a radio guy and not not a coder. Thats why I ask for this big favor.

     

    Thank you very much.

     

    WPBK FM

     

     

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.