Advertisement
Guest User

mp3

a guest
Jun 27th, 2010
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import os
  2. import random
  3. mp3_list = []
  4.  
  5. def crawleo(spath):
  6.     global mp3_list
  7.     if os.path.exists(spath):
  8.         buf = os.listdir(spath)
  9.         for f in buf:
  10.             if os.path.isfile(spath + "\\" + f):
  11.                 mp3_list.append(spath + "\\" + f)
  12.             else:
  13.                 #print "------------- ["+f+"] ------------------"
  14.                 crawleo(spath + "\\" + f)
  15.     else:
  16.         print "El path: " + spath + " no existe."
  17.  
  18. mp3_path = raw_input("Path de MP3: ")
  19. crawleo(mp3_path)
  20.  
  21. mp3_cant = raw_input("Cantidad de Temas (maximo "+str(len(mp3_list))+"): ")
  22.  
  23. random.shuffle(mp3_list)
  24.  
  25. fo = open("lista.m3u" ,"w")
  26.  
  27. for i in range(int(mp3_cant)):
  28.     fo.write(mp3_list[i]+"\n")
  29.  
  30. fo.close()
  31.  
  32. os.execlp("C:\Archivos de programa\Winamp\winamp.exe","-",
  33.           os.path.join(os.path.abspath(os.path.split(__file__)[0]),"lista.m3u"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement