elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Python] MP3 Downloader 0.1
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Python] MP3 Downloader 0.1  (Leído 2,595 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Python] MP3 Downloader 0.1
« en: 28 Noviembre 2012, 16:09 pm »

Traduccion a Python de este simple script para buscar y bajar musica.

El codigo

Código
  1. #!usr/bin/python
  2. #MP3 Downloader 0.1
  3. #Coded By Doddy H
  4.  
  5. import sys,urllib,urllib2,re,os,urlparse
  6.  
  7. def toma(web) :
  8. nave = urllib2.Request(web)
  9. 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');
  10. op = urllib2.build_opener()
  11. return op.open(nave).read()
  12.  
  13. def clean():
  14. if sys.platform=="win32":
  15.  os.system("cls")
  16. else:
  17.  os.system("clear")
  18.  
  19. def head():
  20. print """
  21.  
  22. @     @  @@@@@   @@@     @@@@     @@@@  @         @ @    @
  23. @     @  @    @ @   @    @   @   @    @ @         @ @@   @
  24. @@   @@  @    @     @    @    @  @    @  @   @   @  @@   @
  25. @@   @@  @    @     @    @    @  @    @  @   @   @  @ @  @
  26. @ @ @ @  @@@@@    @@     @    @  @    @  @   @   @  @ @  @
  27. @ @ @ @  @          @    @    @  @    @   @ @ @ @   @  @ @
  28. @  @  @  @          @    @    @  @    @   @ @ @ @   @   @@
  29. @  @  @  @      @   @    @   @   @    @    @   @    @   @@
  30. @     @  @       @@@     @@@@     @@@@     @   @    @    @
  31.  
  32.  
  33.  
  34.  
  35.                              Coded By Doddy H
  36.  
  37.  
  38. """
  39.  
  40. def copyright():
  41. print "\n\n(C) Doddy Hackman 2012\n"
  42. raw_input()
  43. sys.exit(1)
  44.  
  45. def proxar(a,b,c):
  46. sys.stdout.write("\r[+] Status : %s / %s" % (a * b,c))
  47.  
  48. def down(file,filesave):
  49. print "\n[+] File to download : "+filesave+"\n"
  50. try:
  51.  urllib.urlretrieve(file,filesave,reporthook=proxar)
  52. except:
  53.  print "\n[-] Error\n"
  54.  copyright()
  55. print "\n\n[+] File Download in "+os.curdir+"/"+filesave
  56.  
  57. def buscar(titulo) :
  58.  
  59. songs = []
  60. datas =[]
  61. links = []
  62. datas_back = []
  63. links_back = []
  64.  
  65. titulo = re.sub(" ","_",titulo)
  66.  
  67. print "\n\n[+] Searching ...\n"
  68.  
  69. code = toma("http://mp3skull.com/mp3/"+titulo+".html")
  70.  
  71. if not (re.findall("Sorry, no results found for",code)):
  72.  
  73.  songs = re.findall("<div style=\"font-size:15px;\"><b>(.*)<\/b><\/div>",code)
  74.  datas_back = re.findall("<!-- info mp3 here -->\s+(.*?)<\/div>",code)
  75.  links_back = re.findall("<a href=\"(.*)\.mp3\"",code)
  76.  
  77.  for datac in datas_back :
  78.   datac = re.sub("<br />"," ",datac)
  79.   datas.append(datac)
  80.  
  81.  for li in links_back :
  82.   lic = li+".mp3"
  83.   links.append(lic)
  84.  
  85.  try:
  86.   for counter in range(0,len(songs)):
  87.    print "\n[Song "+str(counter)+"] : "+songs[counter]
  88.    print "[Data] : "+datas[counter]
  89.    print "[Link] : "+links[counter]
  90.  
  91.  except:
  92.   pass
  93.  
  94.  while 1:
  95.  
  96.   print "\n[+] Options\n"
  97.   print "[+] 1 - Download"
  98.   print "[+] 2 - Search"
  99.   print "[+] 3 - Exit\n"
  100.  
  101.   op = raw_input("[+] Option : ")
  102.  
  103.   if op  == "3":
  104.    print "\n\n[+] Finished\n"
  105.    copyright()  
  106.  
  107.   if op == "2":
  108.    party()
  109.  
  110.   if op == "1":
  111.    num = input("\n[?] Number :")
  112.    down(links[num],os.path.basename(links[num]))
  113.  
  114. else:
  115.  print "\n[-] Not Found\n";
  116.  raw_input()
  117.  party()
  118.  
  119. def party():
  120.  
  121. clean()
  122. head()
  123.  
  124. bs = raw_input("\n\n[?] Song : ")
  125.  
  126. buscar(bs)
  127.  
  128. ##
  129.  
  130. if not os.path.isdir("mp3_downloads"):
  131. os.makedirs("mp3_downloads")
  132.  
  133. os.chdir("mp3_downloads")
  134.  
  135. party()
  136.  
  137. ##
  138.  
  139. #The End ?
  140.  


« Última modificación: 28 Noviembre 2012, 18:49 pm por Doddy » En línea

peib0l
Wiki

Desconectado Desconectado

Mensajes: 3.493


freedom


Ver Perfil WWW
Re: [Python] MP3 Downloader 0.1
« Respuesta #1 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


« Última modificación: 2 Diciembre 2012, 00:33 am por peib0l » En línea

flacc


Desconectado Desconectado

Mensajes: 854



Ver Perfil WWW
Re: [Python] MP3 Downloader 0.1
« Respuesta #2 en: 8 Diciembre 2012, 18:34 pm »

interesante a ver si mas rato le hecho un ojo...saludos
En línea

BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
Re: [Python] MP3 Downloader 0.1
« Respuesta #3 en: 16 Diciembre 2012, 17:56 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
En línea

flacc


Desconectado Desconectado

Mensajes: 854



Ver Perfil WWW
Re: [Python] MP3 Downloader 0.1
« Respuesta #4 en: 20 Diciembre 2012, 20:03 pm »

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 :(
« Última modificación: 20 Diciembre 2012, 20:09 pm por Mini_Nauta » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
CREANDO UN DOWNLOADER EN PYTHON
Scripting
43H4FH44H45H4CH49H56H45H 2 2,676 Último mensaje 5 Julio 2008, 06:37 am
por dooque
(Python)Existen ventanas de entrada y salida de datos en python « 1 2 »
Scripting
tonilogar 11 15,565 Último mensaje 29 Noviembre 2009, 00:49 am
por tonilogar
[python]VideoTraining Aprende A Programar En Python desde 0 « 1 2 3 »
Scripting
juh 22 17,396 Último mensaje 16 Octubre 2010, 13:12 pm
por Pere Navarro
[Python] WS Downloader: ¡Descarga vídeos de YouTube!
Scripting
.:WindHack:. 5 4,137 Último mensaje 19 Noviembre 2010, 02:54 am
por .:WindHack:.
[Aporte][Python]Linux Magazine Downloader v1.0
Scripting
electrodev 0 2,126 Último mensaje 9 Agosto 2013, 00:08 am
por electrodev
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines