"Michael Hogan" <EMAIL REMOVED> wrote in message
news:Sf4wb.28169$EMAIL REMOVED m...
> I want to pars a playlist file for three different varibles, so I can
save
> them as mp3 files. I am using:
>
> strTEMPURL = GetUrlSource(Text1.Text)
>
> to put the entire .pls file into a strTEMPURL varible.
> I want to grab .pls files from shoutcast and break them into varibles.
>
> ----------------Begin winamp.pls file-------------------
> [playlist]
> numberofentries=1
> File1=http://152.2.63.108:8000
> Title1=(#1 - 25/58) WUNC FM 91.5 Chapel Hill, NC
> Length1=-1
> Version=2
> ----------------Begin winamp.pls file-------------------
>
>
> Private function ParsePLSPlayList(strTEMPURL as string, streamIP as
string,
> streamPort as string, streamTitle as string)
> strTEMPURL = GetUrlSource(Text1.Text)
>
> 'Text1.Text has the url for the http://www.somesite.com/winamp.pls
> 'this is what I want as the end result
> 'Can someone point me in the right direction to parse the above
file to
> get the following?
>
> streamIP = 152.2.63.108
> streamPort = 8000
> streamTitle = (#1 - 25/58) WUNC FM 91.5 Chapel Hill, NC
>
> End Function
>
>
>
>
>
> Thanks in advance for any ***istance.
>
I don't know beans about winamp, etc. but it looks like typical string
parsing to me.
First, you can split strTEMPURL into an array of lines, using something
like:
dim strLines() as String
....
strLines = Split(strTEMPURL, vbCrLf)
You might have to check whether the text has vbLf instead of vbCrLf as
the line break.
Then you can loop through the lines, using something like:
For n = 0 to UBound(strLines)
...
You could then loop until you find a line that reads "[playlist]", and
if you plan to read multiple titles, find one that starts with
"numberofentries".
You can parse each of the lines that contain a parameter/value pair with
something like:
nPos = InStr(1, strLines(n), "=")
if nPos > 0 then
strParm = Left(strLines(n), nPos - 1)
strValue = Right(strLines(n), Len(strLines(n)) - nPos)
end if
Hope that gets you started.
Steve