Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 28th, 2005, 5:38 PM   #1
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Wink Arranging Music.. :)

Ok another sad useless pointless program! You can tell i get bored...
Bassically it will search the given directories for mp3's and wma's, and then just write them to a html file, with a link so they can be played at the click of a buton, ideal when your music files are all over the shot, like mine are, that's the reason i made it.
So go ahead and take the piss but it has a purpose for me, and it might for someone else!! And if it don't, oh well...
Also, i aint great at html, so it's REALLY basic!! but still works!!

import os
path = "#path to store html doc\music_dir.html"
html = open(path, 'w')
html.write("""
<HTML>
<HEAD>
<TITLE>Entire Music Collection</TITLE>
</HEAD>
<BODY align="center">
<HR>
<H1 align="center">Music Libary</H1>
<HR>
<P align="center">All Songs Are Accesable By Clicking On Them</P>
""")
paths = []
while(1):
	paths.append(raw_input("Path Name: "))
	b = raw_input("Enter Another Path? (Y/N) ")
	if b.lower() == "y":
		b = "y"
	else:
		break
for a in range(len(paths)):
	path = paths[a]
for root, dirs, files in os.walk(path, topdown=False):
	for name in files:
		if os.path.join(root, name).endswith(".wma") or os.path.join(root, name).endswith(".mp3"):
			item1 = os.path.join(root, name)
			item2 = os.path.join(name)
			item = '<P align="center"><A href="',item1,'">',item2,"</A></P>"
			item = "".join(item)
			item = str(item)
			html.write(item)
html.write("""
<P>Thanks For Using Saturn Music Collector</P>
</BODY>
</HTML>
""")
html.close()

Ok, at the moment you have to manually type path name, i've edited this version, the one i used i had the paths stored, I know of a gui directory selector, BUT i don't know how to use it.. i know you need tkinter, which i d/l and installed, but don't have a clue how to use it...
__________________
while me is alive:
	make(life,simple)
SaturN is offline   Reply With Quote
Old Jun 28th, 2005, 6:55 PM   #2
SaturN
Programmer
 
Join Date: Apr 2005
Location: Uk
Posts: 68
Rep Power: 4 SaturN is on a distinguished road
Just so's that no one can so, But what if i have the same song in other directories, it's gonna show up twice...

import os
path = "C:\Documents and Settings\Sam\Desktop\music_dir.html"
html = open(path, 'w')
html.write("""
<HTML>
<HEAD>
<TITLE>Entire Music Collection</TITLE>
</HEAD>
<BODY background="C:\Documents and Settings\Sam\Desktop\Programs\HTML Music File\roses.jpg" align="center">
<HR>
<H1 align="center">Music Libary</H1>
<HR>
<P align="center">All Songs Are Accesable By Clicking On Them</P>
""")
paths = []
items = []
while(1):
    paths.append(raw_input("Path Name: "))
    b = raw_input("Enter Another Path? (Y/N) ")
    if b.lower() == "y":
        b = "y"
    else:
        break
lists = []
for a in range(len(paths)):
    path = paths[a]
    for root, dirs, files in os.walk(path, topdown=False):
        for name in files:
            if os.path.join(root, name).endswith(".wma") or os.path.join(root, name).endswith(".mp3"):
                item1 = os.path.join(root, name)
                item2 = os.path.join(name)
                item = '<P align="center"><A href="',item1,'">',item2,"</A></P>"
                item = "".join(item)
                item = str(item)
                if os.path.join(name) in lists:
                    print "Already Located"
                if os.path.join(name) not in lists:
                    lists.append(os.path.join(name))
                    items.append(item)
for a in range(len(items)):
    html.write(items[a])
html.write("""
<P>Music Collections From SaturN</P>
</BODY>
</HTML>
""")
html.close()

There we go, works fine or me
__________________
while me is alive:
	make(life,simple)
SaturN is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC