By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

String Parsing question. (winamp.pls)

P: n/a
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 assistance.



Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Michael Hogan" <mi**********@tampabay.rr.com> wrote in message
news:Sf********************@twister.tampabay.rr.co 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 assistance.


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

Jul 17 '05 #2

P: n/a
Steve,

That will definatly get me started.
Thanks.

Michael

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:-o********************@comcast.com...

"Michael Hogan" <mi**********@tampabay.rr.com> wrote in message
news:Sf********************@twister.tampabay.rr.co 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 assistance.


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


Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.