Solved

ASP Session.SessionID help needed

Posted on 2014-04-27
38
480 Views
Last Modified: 2014-04-30
IIS 6.0
ASP Classic
SQL 2008

My ASP code create a M3U file with the session.sessionID as part of the name
I then created a Button to open that file
But When I click on the Playlist button Windows Media Play says it can not open the file
When I go to the folder and double click on the file it plays no problem
I believe the session.sessionID might be changing before the playlist button try's to retrieve it.


My code is as follows:

<%
if request.form<>"" then
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)
strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%="/Playlist/myplaylist_"&Session.SessionID&".m3u"%>'"> Playlist </button>

Open in new window


Any suggestions
0
Comment
Question by:Thomas Grassi
  • 14
  • 14
  • 6
  • +1
38 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Your rendered button could would be something like below.

<button value="Playlist" onclick="window.location = '/Playlist/myplaylist_12345.m3u'"> Playlist </button>

Open in new window


Try and create a new button using an actual value saved.

If your domain is mydomain.com, does the file exist in mydomain.com/playlist/myplaylist_1234.m3u?  In other words, what happens if you place that full url in the browser?

I wonder if your files are not located inside of your domain?
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
wondering if it's some kind of timing issue. what if you did something like this:

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window

0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
M3u Playlists only work if the playlist is in the directory of the files to be played. Many Players have a limit of 65535 characters in the playlist

#EXTM3U
#EXTINF:132,Song Name
Filename.mp3

Open in new window


Since this is an ASP area, what is your intention to do with this play list once generated? Play it through the website? Play it locally? Have a user on a different machine select the files to play and then play them?
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Dave

I have playlist that are in different folders and on different drives and always have worked
Where are you getting this information from?

What is the #EXTM3U #EXITINF:132,Song Name Filename.mp3 mean ?

My playlist simply contains the filename of the mp3 song

To answer your questions
1. I want users to play the playlist on there Computer, MAC, tablet or smart phone
2. Play it thru the Website using what ever media player they have
3. Yes anyone can do a search and select which songs they wish to play they can play them from the search results page or click on the playlist and it will play all the songs they selected.

Check my site out www.tomsmp3.com
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Big Monty

I tried your new code.

do not believe it is creating the correct m3u file now

I am getting errors on ipad saying Bad URL
I am getting on Windows 7 using IE Medai Player cannot open files

check the site out www.tomsmp3.com


This is the error when I click on playlist

Windows Media player cannot connect to the server the server name might not be correct the server might not be available or your proxy settings might not be correct
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
The links work if you click on them, they play.  But the m3u file does not work.

This is what it looks like

<a href="%2Fmp3%5CMP3MusicAlbums%5CBruce+Chandler%5CBillboard+Top+100+%2D+1962%5C01%2DBillboard+Top+100+%2D+1962%2D13+Duke+Of+Earl%2Emp3">M:\Music\MP3MusicAlbums\Bruce Chandler\Billboard Top 100 - 1962\01-Billboard Top 100 - 1962-13 Duke Of Earl.mp3</a>
<a href="+%2Fmp3%5CMP3MusicAlbums%5CBruce+Springsteen%5CThe+Wild+The+Innocent+%26+The+E+Street+Shuffle%5C07%2DThe+Wild+The+Innocent+%26+The+E+Street+Shuffle%2DNew+York+City+Serenade%2Emp3"> M:\Music\MP3MusicAlbums\Bruce Springsteen\The Wild The Innocent & The E Street Shuffle\07-The Wild The Innocent & The E Street Shuffle-New York City Serenade.mp3</a>
<a href="+%2Fmp3%5CMP3MusicAlbums%5CVarious+Artists%5CDeadicated%5C02%2DDeadicated%2DJack+Straw+%2D+Bruce+Hornsby+%26+the+Range%2Emp3"> M:\Music\MP3MusicAlbums\Various Artists\Deadicated\02-Deadicated-Jack Straw - Bruce Hornsby & the Range.mp3</a>
<a href="+%2Fmp3%5CMP3MusicAlbums%5CVarious+Artists%5CPhiladelphia%5C10%2DPhiladelphia%2DStreets+Of+Philadelphia+%2D+Bruce+Springsteen%2Emp3"> M:\Music\MP3MusicAlbums\Various Artists\Philadelphia\10-Philadelphia-Streets Of Philadelphia - Bruce Springsteen.mp3</a>

Open in new window


As I suggested before, hard code an m3u file, get the hard coded version to work, then move on to generating it dynamically.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
An m3u file should in this format

http://en.wikipedia.org/wiki/M3U

#EXTM3U
#EXTINF:419,Alice In Chains - Rotten Apple
Alice In Chains_Jar Of Flies_01_Rotten Apple.mp3
#EXTINF:260,Alice In Chains - Nutshell
Alice In Chains_Jar Of Flies_02_Nutshell.mp3
#EXTINF:255,Alice In Chains - I Stay Away
Alice In Chains_Jar Of Flies_03_I Stay Away.mp3
#EXTINF:256,Alice In Chains - No Excuses
Alice In Chains_Jar Of Flies_04_No Excuses.mp3
#EXTINF:157,Alice In Chains - Whale And Wasp
Alice In Chains_Jar Of Flies_05_Whale And Wasp.mp3
#EXTINF:263,Alice In Chains - Don't Follow
Alice In Chains_Jar Of Flies_06_Don't Follow.mp3
#EXTINF:245,Alice In Chains - Swing On This
Alice In Chains_Jar Of Flies_07_Swing On This.mp3

Open in new window


Try and hard code the same format manually, post that to your site and try.  Once we know you have a good working file, we can back in the classic asp / vbs
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Yes Scott

It looks like I need to code this

#EXTM3U
#EXTINF:123, Sample artist - Sample title
Sample.mp3
#EXTINF:321,Example Artist - Example title
Greatest Hits\Example.ogg

#EXTM3U  needed only once

I have all the info in the database for the above except for the time
Not sure what to do with the time field

Scott yes I saw that link too
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
I don't know enough about the file type.  Try and leave it out and see what happens.   You will need to find several audio files and just hard code them.  Forget about the database for now, just make an m3u file work first.
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott

Just created a test M3U file and playing it just fine

I just made the time 000 and it works fine.

Now for the code changes
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Please post the code you made that works.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
When you want to create a playlist for someone using their session id just create a file that has the songe and the location you can then send this list to your player.

I want to warn you that playing music over the internet has a lot of restrictions, unless you are willing to send a minimum of $340 to ASCAP and get a license you will get a lot of DMCA takedown notices and possibly a copyright infringement case
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
That is 4 songs played per day because the site is interactive
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
David, we already have him creating the m3u file with the session id.  See line 5 http:#a40026214

Can't this be done just by sending to the browser?  My suggestion was to use a player and javascript or just html5 audio tag.

If you use this type of file that has to be written to disk, it means you also need a way to clean up.

Good point on licensing.  

@trgrassijr55, once you do have all of this working, your next step should be to not store your music inside of your domain.  You would use FileSystemObject to call up what you need or better yet, stream it.  Otherwise you will just open up your self for easy downloading of your music.

What you are doing will be fine for very small usage.  If your plan is to have a lot of people stream or download music, you should have all of your files on a CDN and off your server.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
What you are doing will be fine for very small usage.  If your plan is to have a lot of people stream or download music, you should have all of your files on a CDN and off your server. Only as long as you are licensed. all he needs is a session cookie that the song # is stored and have a lookup of the song # to the filename a database or even an xml file will be good here.
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott

I got a M3U file working

http://www.tomsmp3.com/Playlist%5Ctest.m3u

#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
M:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
M:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
M:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3

My current code

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window


Only one "#EXTM3U" needed in the M3U file

Was thinking to add this
fname.WriteLine "#EXTM3U"
after pathToPlayList line

But now how do I get the other lines coded?

See if the link I posted works for you
http://www.tomsmp3.com/Playlist%5Ctest.m3u


This article has one line for #EXTINF testing that out now
http://howto.wired.com/wiki/Stream_Your_Music_Online



Update

the test.m3u works only on my machine because I have the drive mapped as M:

I think we need to get the url path to work here

Will continue to test and update soon
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
if you replace

fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>"  
   
with

fname.WriteLine "<a href=""" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"  

does that create the playlist properly? when i clicked the link to the m3u file and tried to play it, it didnt work, but gave an error saying the files couldnt be found
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
actually, after reading that article briefly, it looks like you need to fully qualify the domain name, so something like this may do the trick:

fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Big Monty

Yes I tried it on another machine and it does not play

I just tried this one

#EXTM3U
#EXTING:000, Black Sabbath - Behind The Wall Of Sleep
<a href="%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C01%2DCollection+of+Hits%2DBehind+The+Wall+Of+Sleep%2Emp3">M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\01-Collection of Hits-Behind The Wall Of Sleep.mp3</a>
#EXTING:000,Black Sabbath - Dazed And Confused  Paranoid
<a href="+%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C05%2DCollection+of+Hits%2DDazed+And+Confused++Paranoid%2Emp3"> M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\05-Collection of Hits-Dazed And Confused  Paranoid.mp3</a>
#EXTING:000, Black Sabbath - Ironman
<a href="+%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C09%2DCollection+of+Hits%2DIronman%2Emp3"> M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\09-Collection of Hits-Ironman.mp3</a>


http://www.tomsmp3.com/Playlist%5Ctest3.m3u


I think we need the EXT format on the code like above
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
did you try fully qualifying the url like I suggested?

try manually creating a m3u file with fully qualified paths (http://www.tomsmp3.com/....) and see if you can open that from another computer
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Big Monty

Hope you got some well deserved rest

I changed the code

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   
   fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window



Getting this error from MP see attached file

Also attached the output from the asp code that created to playlist-11111.m3u

Got my site and check it out
MP-Error.bmp
myplaylist-899504330.txt
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Your slash is going in the wrong direction.

<a href="http://www.tomsmp3.com/mp3\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\01-Led Zeppelin IV-Black Dog.mp3"

Open in new window

should be
<a href="http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/01-Led Zeppelin IV-Black Dog.mp3"

Open in new window


Try

   fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(replace(song,"M:\Music","/mp3"),"\","/") & """>" & song & "</a>"   

Open in new window

0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
fix the slash issue and see if that resolves it
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
and thanks, sleep was much needed :)
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Made the change same error

Here is the M3U file output

<a href="http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/01-Led Zeppelin IV-Black Dog.mp3">M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\01-Led Zeppelin IV-Black Dog.mp3</a>
<a href="http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/02-Led Zeppelin IV-Rock and Roll.mp3"> M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\02-Led Zeppelin IV-Rock and Roll.mp3</a>
<a href="http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/03-Led Zeppelin IV-The Battle of Evermore.mp3"> M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\03-Led Zeppelin IV-The Battle of Evermore.mp3</a>
<a href="http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/04-Led Zeppelin IV-Stairway to Heaven.mp3"> M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\04-Led Zeppelin IV-Stairway to Heaven.mp3</a>
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
>Here is the M3U file output
The slashes look nice.  But how does this look like what worked for you.  The code below works only on your machine but we need to make it work by using urls and not mapping to your drive.

#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
M:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
M:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
M:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3

Open in new window


<!-- 
*********** You said this works **********
#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
M:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
M:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
M:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3

*********** should be **********
#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Houses of the Holy/01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/How the West Was Won/How the West Was Won Disc 2/03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Bob Dylan/Desire/05-Desire-Oh Sister.mp3
-->

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
fname.WriteLine "#EXTM3U" '** M3U'
for each song in arraySongs

   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   fname.WriteLine "#EXTING:000, "&song
   fname.WriteLine	"http://www.tomsmp3.com"&replace(replace(song,"M:\Music","/mp3"),"\","/")
   'fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window

0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott

Thanks we are so close.

The first song now plays

I thought it might have been this line of code
fname.WriteLine "#EXTING:000, "&song

so I changed it to

fname.WriteLine "#EXTINF:000, "&song


Check out the site and see what you get.

The M3U file look good.
#EXTM3U
#EXTINF:000, M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\02-Led Zeppelin IV-Rock and Roll.mp3
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/02-Led Zeppelin IV-Rock and Roll.mp3
#EXTINF:000,  M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\03-Led Zeppelin IV-The Battle of Evermore.mp3
http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/03-Led Zeppelin IV-The Battle of Evermore.mp3
#EXTINF:000,  M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\04-Led Zeppelin IV-Stairway to Heaven.mp3
http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/04-Led Zeppelin IV-Stairway to Heaven.mp3
#EXTINF:000,  M:\Music\MP3MusicAlbums\Led Zeppelin\Led Zeppelin IV\08-Led Zeppelin IV-When the Levee Breaks.mp3
http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/Led Zeppelin IV/08-Led Zeppelin IV-When the Levee Breaks.mp3
#EXTINF:000,  M:\Music\MP3MusicAlbums\Led Zeppelin\BBC Sessions\BBC Sessions Disc 1\09-BBC Sessions Disc 1-Whole Lotta Love.mp3
http://www.tomsmp3.com /mp3/MP3MusicAlbums/Led Zeppelin/BBC Sessions/BBC Sessions Disc 1/09-BBC Sessions Disc 1-Whole Lotta Love.mp3
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
try this
#<!-- 


*********** Current file missing %20 for space **********
***********             Clean up song name            **********
#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Houses of the Holy/01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/How the West Was Won/How the West Was Won Disc 2/03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Bob Dylan/Desire/05-Desire-Oh Sister.mp3
-->

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
fname.WriteLine "#EXTM3U" '** M3U'
for each song in arraySongs

   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   fname.WriteLine "#EXTING:000, "& makeSongName(song)
   fname.WriteLine	"http://www.tomsmp3.com"&replace(replace(replace(song,"M:\Music","/mp3"),"\","/")," ","%20")
   'fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"   
   
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing

function makeSongName(song)
	 p = InStrRev(song,"\",-1)
     makeSongName = mid(song,p,len(song)-p)
end function


%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window

0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott we are so close

Do you really man this #EXTING ? all doc I found is #EXTINF

I changed it to #EXTINF

here is the output

#EXTM3U
#EXTINF:000, \01-Billboard Top 100 - 1971-56 Beginnings.mp
http://www.tomsmp3.com/mp3/MP3MusicAlbums/Chicago/Billboard%20Top%20100%20-%201971/01-Billboard%20Top%20100%20-%201971-56%20Beginnings.mp3
#EXTINF:000, \02-Billboard Top 100 - 1971-57 Color My World.mp
http://www.tomsmp3.com%20/mp3/MP3MusicAlbums/Chicago/Billboard%20Top%20100%20-%201971/02-Billboard%20Top%20100%20-%201971-57%20Color%20My%20World.mp3
#EXTINF:000, \01-Billboard Top 100 - 1972-77 Saturday In The Park.mp
http://www.tomsmp3.com%20/mp3/MP3MusicAlbums/Chicago/Billboard%20Top%20100%20-%201972/01-Billboard%20Top%20100%20-%201972-77%20Saturday%20In%20The%20Park.mp3
#EXTINF:000, \01-Billboard Top 100 - 1973-54 Feelin' Stronger Every Day.mp
http://www.tomsmp3.com%20/mp3/MP3MusicAlbums/Chicago/Billboard%20Top%20100%20-%201973/01-Billboard%20Top%20100%20-%201973-54%20Feelin'%20Stronger%20Every%20Day.mp3


Still playing only the first song
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Try changing line 31
   fname.WriteLine	"http://www.tomsmp3.com"&replace(replace(replace(song,"M:\Music","/mp3"),"\","/")," ","%20")

Open in new window

to below.  try and keep just one space between writeline and "htt..
fname.WriteLine "http://www.tomsmp3.com"&trim(replace(replace(replace(trim(song,"M:\Music","/mp3")),"\","/")," ","%20"))

Open in new window



Also replace the function to fix the name.

function makeSongName(song)
	 p = InStrRev(song,"\",-1)
     makeSongName = mid(song,p,len(song)-p)
end function

Open in new window

to below. That will take out the front slash from the name and add back the 3 at the end.
function makeSongName(song)
	 p = InStrRev(song,"\",-1)
     makeSongName = mid(song,p+1,len(song)-p)
end function

Open in new window


If it were me, I would probably have mass updated all my file names and get rid of any spaces by possibly closing the gap or replace with hyphens.  I would also remove any single or double quotes that may be in the file names. I saw single quotes in some.

Actually, I would probably store each song as a number that perhaps matches an id number in the database.  Then leave the title etc in the db.

See if this update works.
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott,

Thanks
I test this tonight.

Yes quotes spaces make database files hard to work with.

Are you talking about just the file name or the folders also?

Folder

Led Zeppelin
   Houses of The Holy
      01-Houses of The Holy-Song One.mp3
      02-Houses of The Holy-Song Two.mp3
      03-Houses of The Holy-Song Three is' test.mp3


Led Zeppelin
   Houses_of_The_Holy
      01-Houses_of_The_Holy-Song_One.mp3
      02-Houses_of_The_Holy-Song_Two.mp3
      03-Houses_of_The Holy-Song_Three is test.mp3


I would use underscores in place of the spaces
I like the dashes for between the track number and song
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
No spaces in folder or file names.  I don't like underscores for things you need to see in a browser because it is too hard to tell if it is there or not.
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott will look into changing the folder names and file names

Updated my code with your recent changes above

got this error:

Microsoft VBScript runtime  error '800a01c2'

Wrong number of arguments or invalid property assignment: 'trim'

/music3.asp, line 16

My current code:

<%
if request.form<>"" then
dim fs,fname, pathToPlayList
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)

pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"

strSongs=request.form("selectItem")
arraySongs=split(strSongs,",")
response.write "<ul>"
fname.WriteLine "#EXTM3U" '** M3U'
for each song in arraySongs
   response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" 
   fname.WriteLine "#EXTINF:000, "& makeSongName(song)
   fname.WriteLine "http://www.tomsmp3.com"&trim(replace(replace(replace(trim(song,"M:\Music","/mp3")),"\","/")," ","%20"))
   next
response.write "</ul>" 
fname.Close
else
response.write "You did not post any data yet<br>"
end if
set fname=nothing
set fs=nothing

function makeSongName(song)
	 p = InStrRev(song,"\",-1)
     makeSongName = mid(song,p+1,len(song)-p)
end function
%>
<input type="button" value="BACK!"onClick="history.back();">
<button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>

Open in new window

0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Try this

   fname.WriteLine "http://www.tomsmp3.com"&trim(replace(replace(trim(song,"M:\Music","/mp3"),"\","/")," ","%20"))

Open in new window

0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Scott

Thanks

changed the code to the above

Microsoft VBScript runtime  error '800a01c2'

Wrong number of arguments or invalid property assignment: 'trim'

/music3.asp, line 16
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
oh, the trim needs to go around song.  

   fname.WriteLine "http://www.tomsmp3.com"&replace(replace(replace(trim(song),"M:\Music","/mp3"),"\","/")," ","%20")

Open in new window

0
 
LVL 23

Author Closing Comment

by:Thomas Grassi
Comment Utility
Scott,

Your the best.

Now working.

Going to work on the file and folder renames soon. Found a free program that will do massive folders at once.

Thanks again
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
'Sounds' good!  The next step is cleaning up the front end.  At least you have it working.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now