• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

ASP help needed

I am broadcasting to a Shoutcast Server and am pulling the data back to my website with the following code.

<%ip = "xxx.xxx.xxx.xxx"
port = "xxxx"
pass = "******"

sname = "http://" & ip & ":" & port
baseURL = sname & "/admin.cgi?"
pw = "pass=" & pass
extURL = baseURL & pw & "&mode=viewxml"
set xmlDoc = createObject("Msxml.DOMDocument")
xmlDoc.async = false
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load(extURL)
If (xmlDoc.parseError.errorCode <> 0) then
   response.write xmlDoc.parseError.errorCode & "<br>"
   response.write xmlDoc.ParseError.reason & "<br>"
   response.write xmlDoc.ParseError.line & "<br>"
   response.write xmlDoc.ParseError.SrcText
Else
  ServerStatus = xmlDoc.SelectSingleNode("//STREAMSTATUS").text
  If serverstatus = "1" Then
    ' Server is up
    MaxUsers = xmlDoc.SelectSingleNode("//MAXLISTENERS").Text
    Peak = xmlDoc.SelectSingleNode("//PEAKLISTENERS").Text
    Users = xmlDoc.SelectSingleNode("//CURRENTLISTENERS").Text
    'response.write Users & " players currently connected<br><br>"
    i = 1
    Set HistoryList = xmlDoc.SelectNodes("//SONG")
    For Each Item in HistoryList
      airtime = Item.SelectSingleNode("PLAYEDAT").text
      title = Item.SelectSingleNode("TITLE").text
      If i = 1 Then
        response.write "<font size='4' color='ffffff'>" & title & "</font>"
      'ElseIf i = 2 Then
        'response.write "<b>You Just Missed...</b><br>" & title & "<br>"
      'Else    
        'response.write title & "<br>"
      End If
      i = i + 1  
    Next  
  Else
    response.write "&nbsp; <font size='5'>Currently off the air</font>"        
  End If    
End If
Set xmlDoc = Nothing
%>

The code works great but what i need to do is pull only the last five songs played and display them seperatly.

Example:
<%lastplayed 1%>
<%lastplayed 2%>

You can view how I want to show the info by going to http://www.radionuevoamanecer.mx.
You will see how I have the site layed out and where I want to put the data.

there is also a page, http://www.radionuevoamanecer.mx/radio1.asp, which shows that i am pulling the info using the script above. i just can't get it to layout the way i want.

You help will be greatly appreciated.
0
Mark Wood
Asked:
Mark Wood
  • 4
  • 4
1 Solution
 
stalhwCommented:
what is the problem exactly?
you can do a simpel array, put the 5 you want in it, and then display the array any way you want.
<%
ip = "xxx.xxx.xxx.xxx"
port = "xxxx"
pass = "******"

redim lastSongs(4)
for yy=0 to 4
	lastSongs(yy)=""
next

sname = "http://" & ip & ":" & port
baseURL = sname & "/admin.cgi?"
pw = "pass=" & pass
extURL = baseURL & pw & "&mode=viewxml"
set xmlDoc = createObject("Msxml.DOMDocument")
xmlDoc.async = false
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load(extURL)
If (xmlDoc.parseError.errorCode <> 0) then
   response.write xmlDoc.parseError.errorCode & "<br>"
   response.write xmlDoc.ParseError.reason & "<br>"
   response.write xmlDoc.ParseError.line & "<br>"
   response.write xmlDoc.ParseError.SrcText
Else
  ServerStatus = xmlDoc.SelectSingleNode("//STREAMSTATUS").text
  If serverstatus = "1" Then
    ' Server is up
    MaxUsers = xmlDoc.SelectSingleNode("//MAXLISTENERS").Text
    Peak = xmlDoc.SelectSingleNode("//PEAKLISTENERS").Text
    Users = xmlDoc.SelectSingleNode("//CURRENTLISTENERS").Text
    'response.write Users & " players currently connected<br><br>"
    i = 1
    Set HistoryList = xmlDoc.SelectNodes("//SONG")
    For Each Item in HistoryList
      airtime = Item.SelectSingleNode("PLAYEDAT").text 
      title = Item.SelectSingleNode("TITLE").text

'SKIP first one because I understand you want the last 5 played, not the currently playing
	if ii>6 then exit for
	if ii>1 then lastSongs(ii-2)=title
      i = i + 1  
    Next   
  Else
    response.write "&nbsp; <font size='5'>Currently off the air</font>"         
  End If    
End If
Set xmlDoc = Nothing
%>
<div><%=lastSongs(0)%></div>
<div><%=lastSongs(1)%></div>
<div><%=lastSongs(2)%></div>
<div><%=lastSongs(3)%></div>
<div><%=lastSongs(4)%></div>

Open in new window

0
 
Mark WoodAuthor Commented:
doesn't work on my end .. see http://radionuevoamanecer.mx/radio2.asp

it does show when i am off the air but that is all
0
 
stalhwCommented:
oh sorry I made a stupid mistake in my code...
I put "ii" instead of your "i", I always use ii, so it was second nature to type it.

so juste replace the two lines:
	if i>6 then exit for
	if i>1 then lastSongs(i-2)=title

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Mark WoodAuthor Commented:
i will give you the shoutcast ip and such if it will help
0
 
stalhwCommented:
no need, if it worked when you did a response.write, it will work setting it in an array.
the problem was just that I used  ii  insteand of just  i
0
 
Mark WoodAuthor Commented:
now it works great .. thanks for the help!!!
0
 
Mark WoodAuthor Commented:
thanks so much
0
 
stalhwCommented:
My pleasure,
you did all the hard work of getting and parsing the xml :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now