Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
String Parsing question. (winamp.pls)
Old
  (#1)
Michael Hogan
Guest
 
Posts: n/a
Default String Parsing question. (winamp.pls) - 06-04-2007, 08:50 AM

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.







   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: String Parsing question. (winamp.pls)
Old
  (#2)
Steve Gerrard
Guest
 
Posts: n/a
Default Re: String Parsing question. (winamp.pls) - 06-04-2007, 08:51 AM


"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





   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: String Parsing question. (winamp.pls)
Old
  (#3)
Michael Hogan
Guest
 
Posts: n/a
Default Re: String Parsing question. (winamp.pls) - 06-04-2007, 08:51 AM

Steve,

That will definatly get me started.
Thanks.

Michael

"Steve Gerrard" <EMAIL REMOVED> wrote in message
news:-oudnR5XZaEOilyiRVn-EMAIL REMOVED...
>
> "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
>
>
>
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top