Now Playing (ASP / PHP ) RegEx
  • Hi all happy music lovers!

    I been try to get out "now play" from Icecast for some time and made my own "hack"
    Maybe some one can help out to make a PHP-version of this?

    Only make a asp-file and upload to your server and change what server name or IP you have :)
    I will try to make a PHP version of this as well

    **** Start Copy *****

    <%
    // I made a little RegEx hack on a Icecast server ver. 2.3.3 
    // im not sure if its working on other but it should be easy to rewrite to your type
    // This is for a IIS server but it would not be a problem to make same against a Apache (PHP) 
    // Tyrone Fröberg – tyrfro@gmail.com

    Function GetText(URI)
    Dim Request
    Set Request = CreateObject(”WinHttp.WinHttpRequest.5.1″)
    Request.Open ”GET”, URI, False
    Request.Send
    GetText = Request.ResponseText
    End Function

    // REPLACE on found stuff
    Function SONGNAME(s) 
    s = Replace(s,”Current Song:”,””) // replace from string
    s = Replace(s,”</td>”,””) // replace from string
    s = Replace(s,”<td>”,””) // replace from string
    s = Replace(s,”\n”,””) // replace from string
    s = Replace(s,”\r”,””) // replace from string
    s = Replace(s,” ”,” ”) //if there is a misstake in rename file we clean it up a bit //
    s = Replace(s, vbCrLf, ”” ) // replace from string (just in case)
    s = Replace(s,”<td class=””streamdata””>”,” ”) // replace from string
    s = Replace(s, Chr(13), ” ”) // replace from string (just in case)
    SONGNAME = s
    End Function

    targetString = GetText(”http://www.domain.com:8000/”)
    Dim re, targetString, colMatch, objMatch
    Set re = New RegExp
    With re
    .Pattern = ”<td>Current Song:</td>\n<td class=””streamdata””>.*</td>”
    .Global = False 
    .IgnoreCase = True
    End With

    Set colMatch = re.Execute(targetString)
    For each objMatch in colMatch
    SongArtist = SONGNAME(objMatch.Value) 
    Next 
    %>

    <!– We put out song to a page that we can use a IFRAME to get in to what ever website u have, put some graphic stuff around it –>
    <%=Trim(SongArtist)%>

    *** END ***

    I hope this can help someone else as well 

    http://www.tyrone.nu/program/icecast-airtime-now-playing/


    Post edited by Tyrone Fröberg at 2015-01-25 05:58:18
  • 1 Comment sorted by
  • Too Much unnecessary work.

    The Problem of using RegEx to parse any markup language is that when the application changes you maybe left dead in the water. like changes from Icecast v2.3  and v2.4

    One approach for Icecast is to create a custom xsl ,you can even linked it to your webroot.
    Look also for json,I think 2.4 now includes one

    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.