Traduccion a Python de este simple script para buscar y bajar musica.
El codigo
#!usr/bin/python
#MP3 Downloader 0.1
#Coded By Doddy H
import sys,urllib,urllib2,re,os,urlparse
def toma(web) :
nave = urllib2.Request(web)
nave.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5');
op = urllib2.build_opener()
return op.open(nave).read()
def clean():
if sys.platform=="win32":
os.system("cls")
else:
os.system("clear")
def head():
print """
@ @ @@@@@ @@@ @@@@ @@@@ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @@ @
@@ @@ @ @ @ @ @ @ @ @ @ @ @@ @
@@ @@ @ @ @ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @@@@@ @@ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @@
@ @ @ @ @ @ @ @ @ @ @ @ @ @@
@ @ @ @@@ @@@@ @@@@ @ @ @ @
Coded By Doddy H
"""
def copyright():
print "\n\n(C) Doddy Hackman 2012\n"
raw_input()
sys.exit(1)
def proxar(a,b,c):
sys.stdout.write("\r[+] Status : %s / %s" % (a * b,c))
def down(file,filesave):
print "\n[+] File to download : "+filesave+"\n"
try:
urllib.urlretrieve(file,filesave,reporthook=proxar)
except:
print "\n[-] Error\n"
copyright()
print "\n\n[+] File Download in "+os.curdir+"/"+filesave
def buscar(titulo) :
songs = []
datas =[]
links = []
datas_back = []
links_back = []
titulo = re.sub(" ","_",titulo)
print "\n\n[+] Searching ...\n"
code = toma("http://mp3skull.com/mp3/"+titulo+".html")
if not (re.findall("Sorry, no results found for",code)):
songs = re.findall("<div style=\"font-size:15px;\"><b>(.*)<\/b><\/div>",code)
datas_back = re.findall("<!-- info mp3 here -->\s+(.*?)<\/div>",code)
links_back = re.findall("<a href=\"(.*)\.mp3\"",code)
for datac in datas_back :
datac = re.sub("<br />"," ",datac)
datas.append(datac)
for li in links_back :
lic = li+".mp3"
links.append(lic)
try:
for counter in range(0,len(songs)):
print "\n[Song "+str(counter)+"] : "+songs[counter]
print "[Data] : "+datas[counter]
print "[Link] : "+links[counter]
except:
pass
while 1:
print "\n[+] Options\n"
print "[+] 1 - Download"
print "[+] 2 - Search"
print "[+] 3 - Exit\n"
op = raw_input("[+] Option : ")
if op == "3":
print "\n\n[+] Finished\n"
copyright()
if op == "2":
party()
if op == "1":
num = input("\n[?] Number :")
down(links[num],os.path.basename(links[num]))
else:
print "\n[-] Not Found\n";
raw_input()
party()
def party():
clean()
head()
bs = raw_input("\n\n[?] Song : ")
buscar(bs)
##
if not os.path.isdir("mp3_downloads"):
os.makedirs("mp3_downloads")
os.chdir("mp3_downloads")
party()
##
#The End ?
ey muy bueno, esta tarde lo pruebo, tiene muuchos fallos asi que me lo re-hago con tu idea XD
interesante a ver si mas rato le hecho un ojo...saludos
Cita de: peib0l en 30 Noviembre 2012, 13:24 PM
ey muy bueno, esta tarde lo pruebo, tiene muuchos fallos asi que me lo re-hago con tu idea XD
comenta los errores o sugerencias para ver si hago la version 0.2
hahaha funciona y todo... esta bueno, aun no veo los errores que mencionaron pero algún día le daré el ojo xD...saludos
edit: me parece que es por la consola de windows pero cuando salen muchos resultados no me los muestra todos cuando subo la scrollbar hacia arriba xD, cosa que ubuntu si deja :(