Jump to content
Sign in to follow this  

Live365 Current Song Grabber

Recommended Posts

Hello everyone,

I'm new around here. Though I've been browsing the site for awhile. Anyway. For those of you who use Live365 Internet Radio frequently but are not premium or gold members. You'll notice that if you play the .pls files through a mp3 stream player of some sort (winamp, qcd, etc.) your player won't display the song title. (Well, at least mine doesn't.) I'm a little lazy and I don't like to have to open a browser to find out the song being played. So I though AutoIt could help in this case. It's a tray program that will balloon (traytip) whenever a new song is played on a specified Live365 radio station. I also made a hotkey (CTRL + "\" ) to query the song info any time.

This isn't an online player. It won't play music, it just updates the song titles live. Though you can modify the script to create a hidden IE object that loads the IE-only-compaitble web-based player. To change a radio station just copy paste the Live365 Radio Station URL (ex. "http://www.live365.com/stations/pianoradio") into the $live365 link variable atl the top of the script. Enjoy. :lmao:

Let me know if there's anything wrong. Also, I'm not a very efficient programmer. Tips and suggestions on shortening the script would be greatly appreciated.

//Updated: Some bugs found with a few songs having an album name with the word "time" in it. Fixed. And removed the showing of a square box symbol after the Radio Station name. (Oct 10th, 2006)

; --------------------------------------------------------------------------------------------------------
;    Live 365 Current Song Balloon Tip
;           Author: Tso (Peter) Chen
; --------------------------------------------------------------------------------------------------------

; variable declarations
    Dim $songTitle, $songTime, $trimRight, $songArtist, $songAlbum, $songTitleOld, $link
    Dim $live365link = "http://www.live365.com/stations/pianoradio"

; hotkey to show traytip of song information
    HotKeySet("^\", "Update")
    HotKeySet("^{Backspace}", "Close")

    TrayTip("", "Retrieving details...", 5)

; initiate HTTP Request to get playlist link
    $HTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $HTTP.open("GET", $live365link)

; get Station Name using the Title Tag
    $getTitleLeft = StringTrimLeft(string($HTTP.responseText), StringinStr(string($HTTP.responseText), "<TITLE>"))
    $getTitleRight = StringTrimRight($getTitleLeft, stringlen($getTitleLeft) - StringinStr($getTitleLeft, "</TITLE>") + 2)
    $getTitle = StringTrimLeft($getTitleRight, StringinStr($getTitleRight, "Live365") - 1)

; trim the entire script by half. (hopefully increasing search speed)
; if no use or something goes wrong, uncomment the line below and comment out the other $cutInHalf definition
;   $cutInHalf = string($HTTP.responseText)
    $cutInHalf = StringTrimLeft(string($HTTP.responseText), stringLen(string($HTTP.responseText)) / 2)
; find and trim what's before of <IFRAME>   
    $findFrameStartTag = StringTrimLeft($cutInHalf, StringInStr($cutInHalf, "IFRAME") - 2)

; find and trim what's after of </IFRAME>
    $findFrameEndTag = StringTrimRight($findFrameStartTag, StringLen($findFrameStartTag) - StringInStr($findFrameStartTag, "/IFRAME") + 2)

; find SRC attribute and trim what's before it
    $findSRC = StringTrimLeft($findFrameEndTag, StringInStr($findFrameEndTag, "SRC") - 1)

; find quotes and trim what's before it
    $findStartQuote = StringTrimLeft($findSRC, StringInStr($findSRC, CHR(34)))
; find end quotes and trim what's after it
    $findEndQuote = StringTrimRight($findStartQuote, StringLen($findStartQuote) - StringInStr($findStartQuote, CHR(34)) + 1)

; final link
    $link = "http://www.live365.com" & $findEndQuote

; get http request and connect to the playlist link
    $HTTP.open("GET", $link)
; Function GetSongInformation (gets raw javascript from playlist)
        Func GetSongInfo()
; HTTP send
; retrieves raw javascript  
            $theString = string($HTTP.responseText)
; look for "one" and trims whatever script is before that point
            $trimLeft = StringTrimLeft($theString, StringInStr($theString, "one") - 1)
; look for "two" and trims whatever script is after that point to narrow down the song info search detail
            $trimRight = StringTrimRight($trimLeft, StringLen($trimLeft) - StringInStr($trimLeft, "two") + 1)

; polish the raw script to look for each of the properties of song
            $songTitle = polishInfo("title:")
            $songArtist = polishInfo("artist:")
            $songAlbum = polishInfo("album:")
            $songTime = polishInfo("time:")
; check if current song is a new song, if it is, update the tip, or else.
            If $songTitleOld <> $songTitle Then
; Function to polish the raw script
        Func polishInfo($property)
; prepare to get rid of the leftside quotation mark
            $leftQuoteOff = StringTrimLeft($trimRight, StringInStr($trimRight, $property) - 1)
; got rid of left quote, prepare to get rid of the rightside quotation mark 
            $rightQuoteOff = StringTrimLeft($leftQuoteOff, StringInStr($leftQuoteOff, CHR(34)))
; final info detail
            $finalInfo = StringTrimRight($rightQuoteOff, StringLen($rightQuoteOff) - StringInStr($rightQuoteOff, CHR(34)) + 1)
            return $finalInfo

; Function to Close script

        Func Close()
            Exit 1

; Function to show tray ballon tip.
        Func Update()
; save the old song title
            $songTitleOld = $songTitle
; display balloon tip
            TrayTip($getTitle, "[" & $songAlbum & "] " & $songArtist & " - " & $songTitle & " (" & $songTime & ")", 5)

; Main Program code is here. --------------------------------------------------------------------------------------------------
        #region Main Loop


; The main loop, never broken.
            While 1

        #endregion Main Loop
; Main Program code ends here. ------------------------------------------------------------------------------------------------
Edited by chen_tso

Share this post

Link to post
Share on other sites

Very nice! Is there a way to log in?



Is this a machine? I don't talk to machines! [Click]

hmmm.. good question. i'm not sure how live365 requires login. because sometimes they ask, sometimes they don't. but i guess i'll implement it to detect if login is required.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...