• Publicidad

MP3 Downloader 0.1

¿Estás desarrollando un proyecto, o piensas hacerlo? Pon aquí tu propuesta, lo más seguro es que alguien esté interesado en ayudarte.

MP3 Downloader 0.1

Notapor BigBear » 2012-11-27 09:57 @456

Hice este simple script para buscar y bajar música.

El código:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!usr/bin/perl
  2. #MP3 Downloader 0.1
  3. #Coded By Doddy H
  4.  
  5. use LWP::UserAgent;
  6. use URI::Split qw(uri_split);
  7. use Time::HiRes "usleep";
  8.  
  9. my $nave = LWP::UserAgent->new;
  10. $nave->agent(
  11. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  12. );
  13. $nave->timeout(5);
  14.  
  15. my $se = "downloads_mp3";
  16.  
  17. unless ( -d $se ) {
  18.     mkdir( $se, "777" );
  19. }
  20.  
  21. chdir $se;
  22.  
  23. head();
  24.  
  25. print "[?] Song : ";
  26. chomp( my $song = <stdin> );
  27.  
  28. $song =~ s/ /-/;
  29.  
  30. print "\n[+] Searching ...\n\n";
  31.  
  32. my $code = toma( "http://mp3skull.com/mp3/" . $song . ".html" );
  33.  
  34. chomp $code;
  35.  
  36. if ( $code =~ /Sorry, no results found for/ ) {
  37.     print "\n[-] Not Found\n";
  38.     copyright();
  39. }
  40.  
  41. my @nombres;
  42. my @datas;
  43. my @links;
  44.  
  45. while ( $code =~ /<div style="font-size:15px;"><b>(.*)<\/b><\/div>/mig ) {
  46.     my $nombre = $1;
  47.  
  48.     #print "name : $nombre\n";
  49.     push( @nombres, $nombre );
  50. }
  51.  
  52. while ( $code =~ /<!-- info mp3 here -->\s+(.*?)<\/div>/migs ) {
  53.     my $data = $1;
  54.     $data =~ s/<br \/>/ /;
  55.     $data =~ s/<br \/>/ /;
  56.  
  57.     #print "data : $data\n";
  58.     push( @datas, $data );
  59. }
  60.  
  61. while ( $code =~ /<a href=\"(.*)\.mp3\"/mig ) {
  62.     my $link = $1 . ".mp3";
  63.  
  64.     #print "link : $link\n";
  65.     push( @links, $link );
  66. }
  67.  
  68. my $encontrados = int(@nombres) - 1;
  69.  
  70. for my $aca ( 0 .. $encontrados ) {
  71.     print "[Song $aca] : $nombres[$aca]\n";
  72.     print "[Data] : $datas[$aca]\n";
  73.     print "[Link] : $links[$aca]\n\n";
  74. }
  75.  
  76. print "\n[?] Number : ";
  77. chomp( my $number = <stdin> );
  78.  
  79. print "\n[+] Downloading ...\n";
  80.  
  81. now( $links[$number] );
  82.  
  83. print "\n[+] Finished\n";
  84.  
  85. copyright();
  86.  
  87. sub head {
  88.  
  89.     my @logo = (
  90.         "#=============================================#", "\n",
  91.         "#             MP3 Downloader 0.1              #", "\n",
  92.         "#---------------------------------------------#", "\n",
  93.         "# Written By Doddy H                          #", "\n",
  94.         "# Email: lepuke[at]hotmail[com]               #", "\n",
  95.         "# Website: doddyhackman.webcindario.com       #", "\n",
  96.         "#---------------------------------------------#", "\n",
  97.         "# The End ?                                   #", "\n",
  98.         "#=============================================#", "\n"
  99.     );
  100.  
  101.     print "\n";
  102.  
  103.     marquesina(@logo);
  104.  
  105.     print "\n\n";
  106.  
  107. }
  108.  
  109. sub copyright {
  110.  
  111.     my @fin = ("-- == (C) Doddy Hackman 2012 == --");
  112.  
  113.     print "\n\n";
  114.     marquesina(@fin);
  115.     print "\n\n";
  116.  
  117.     <stdin>;
  118.  
  119.     exit(1);
  120.  
  121. }
  122.  
  123. sub marquesina {
  124.  
  125.     #Effect based in the exploits by Jafer Al Zidjali
  126.  
  127.     my @logo = @_;
  128.  
  129.     my $car = "|";
  130.  
  131.     for my $uno (@logo) {
  132.         for my $dos ( split //, $uno ) {
  133.  
  134.             $|++;
  135.  
  136.             if ( $car eq "|" ) {
  137.                 mostrar( "\b" . $dos . $car, "/" );
  138.             }
  139.             elsif ( $car eq "/" ) {
  140.                 mostrar( "\b" . $dos . $car, "-" );
  141.             }
  142.             elsif ( $car eq "-" ) {
  143.                 mostrar( "\b" . $dos . $car, "\\" );
  144.             }
  145.             else {
  146.                 mostrar( "\b" . $dos . $car, "|" );
  147.             }
  148.             usleep(40_000);
  149.         }
  150.         print "\b ";
  151.     }
  152.  
  153.     sub mostrar {
  154.         print $_[0];
  155.         $car = $_[1];
  156.     }
  157.  
  158. }
  159.  
  160. sub now {
  161.  
  162.     my ( $scheme, $auth, $path, $query, $frag ) = uri_split( $_[0] );
  163.  
  164.     if ( $path =~ /(.*)\/(.*)$/ ) {
  165.         my $file = $2;
  166.         if ( download( $_[0], $file ) ) {
  167.         }
  168.     }
  169. }
  170.  
  171. sub download {
  172.     if ( $nave->mirror( $_[0], $_[1] ) ) {
  173.         if ( -f $_[1] ) {
  174.             return true;
  175.         }
  176.     }
  177. }
  178.  
  179. sub toma {
  180.     return $nave->get( $_[0] )->content;
  181. }
  182.  
  183. #The End ?
  184.  
Coloreado en 0.006 segundos, usando GeSHi 1.0.8.4


Un ejemplo de uso:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
#=============================================#
#             MP3 Downloader 0.1              #
#---------------------------------------------#
# Written By Doddy H                          #
# Email: lepuke[at]hotmail[com]               #
# Website: doddyhackman.webcindario.com       #
#---------------------------------------------#
# The End ?                                   #
#=============================================#


[?] Song : bones now

[+] Searching ...

[Song 0] : Discovery Now - bionic bones mp3
[Data] : 256 kbps 1:30 2.79 mb
[Link] : http://www.whro.org/home/html/podcasts/discoverynow/041408.mp3

[Song 1] : Sean Bones - 'Here Now' mp3
[Data] : 128 kbps 3:28 3.19 mb
[Link] : http://serve.castfire.com/audio/878039/sean-bones-here-now_2012-02-23-1
74939.128.mp3

[Song 2] : Discovery Now - bionic bones mp3
[Data] : 256 kbps  00:01:30 2.8 mb
[Link] : http://whro.org/home/html/podcasts/discoverynow/041408.mp3

[Song 3] : Sean Bones - Here Now mp3
[Data] : 5.02 mb
[Link] : http://www.hulkshare.com/dl/4t42l4kxi811/sean_bones_-_here_now.mp3

[Song 4] : Fuego Ft. Amara - Lo Que Quiero (Prod. By Bones, Now & Laterz) (http://Www.S
tiloCaro.Com) mp3
[Data] : 4.43 mb
[Link] : http://www.hulkshare.com/dl/w86wxq8bl0n4/fuego_ft._amara_-_lo_que_quier
o_%28prod._by_bones%2c_now_%26_laterz%29.mp3

[Song 5] : Sean Bones - Here Now mp3
[Data] : 160 kbps 3:27 3.95 mb
[Link] : http://myspoonful.com/wp-content/uploads/Sean-Bones-Here-Now.mp3

[Song 6] : Frankie Bones - Bonesbreaks Vol. 2 (B2) On The Beat Now-freestyle na
veia mp3
[Data] : 4:40 mins 6.41 mb
[Link] : http://dc203.4shared.com/img/564370108/97ff8470/dlink__2Fdownload_2FS4X
eLchH_3Ftsid_3D20121127-94941-8934f180/preview.mp3


[?] Number : 1

[+] Downloading ...

[+] Finished


-- == (C) Doddy Hackman 2012 == --

 
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: MP3 Downloader 0.1

Notapor explorer » 2012-11-27 10:28 @477

Algunas formas más breves...

Líneas 9 a 13:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $nave = LWP::UserAgent->new(
  2.     agent   => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12',
  3.     timeout => 5,
  4. );
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $code = toma( "http://mp3skull.com/mp3/$song.html" );
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Líneas 45 a 50:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my @nombres  =  $code =~ /<div style="font-size:15px;"><b>(.*)<\/b><\/div>/mig;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Líneas 54 a 55:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1.     $data =~ s/<br \/>/ /g;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Líneas 62 a 65:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1.     push @links, "$1.mp3";
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Líneas 68 a 70:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. for my $aca ( 0 .. $#nombres ) {
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España


Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 2 invitados

cron