[Perl] MP3 Downloader 0.1

Iniciado por BigBear, 27 Noviembre 2012, 15:53 PM

0 Miembros y 1 Visitante están viendo este tema.

BigBear

Hice este simple script para buscar y bajar musica.

El codigo

Código (perl) [Seleccionar]

#!usr/bin/perl
#MP3 Downloader 0.1
#Coded By Doddy H

use LWP::UserAgent;
use URI::Split qw(uri_split);
use Time::HiRes "usleep";

my $nave = LWP::UserAgent->new;
$nave->agent(
"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
);
$nave->timeout(5);

my $se = "downloads_mp3";

unless ( -d $se ) {
    mkdir( $se, "777" );
}

chdir $se;

head();

print "[?] Song : ";
chomp( my $song = <stdin> );

$song =~ s/ /-/;

print "\n[+] Searching ...\n\n";

my $code = toma( "http://mp3skull.com/mp3/" . $song . ".html" );

chomp $code;

if ( $code =~ /Sorry, no results found for/ ) {
    print "\n[-] Not Found\n";
    copyright();
}

my @nombres;
my @datas;
my @links;

while ( $code =~ /<div style="font-size:15px;"><b>(.*)<\/b><\/div>/mig ) {
    my $nombre = $1;

    #print "name : $nombre\n";
    push( @nombres, $nombre );
}

while ( $code =~ /<!-- info mp3 here -->\s+(.*?)<\/div>/migs ) {
    my $data = $1;
    $data =~ s/<br \/>/ /;
    $data =~ s/<br \/>/ /;

    #print "data : $data\n";
    push( @datas, $data );
}

while ( $code =~ /<a href=\"(.*)\.mp3\"/mig ) {
    my $link = $1 . ".mp3";

    #print "link : $link\n";
    push( @links, $link );
}

my $encontrados = int(@nombres) - 1;

for my $aca ( 0 .. $encontrados ) {
    print "[Song $aca] : $nombres[$aca]\n";
    print "[Data] : $datas[$aca]\n";
    print "[Link] : $links[$aca]\n\n";
}

print "\n[?] Number : ";
chomp( my $number = <stdin> );

print "\n[+] Downloading ...\n";

now( $links[$number] );

print "\n[+] Finished\n";

copyright();

sub head {

    my @logo = (
        "#=============================================#", "\n",
        "#             MP3 Downloader 0.1              #", "\n",
        "#---------------------------------------------#", "\n",
        "# Written By Doddy H                          #", "\n",
        "# Email: lepuke[at]hotmail[com]               #", "\n",
        "# Website: doddyhackman.webcindario.com       #", "\n",
        "#---------------------------------------------#", "\n",
        "# The End ?                                   #", "\n",
        "#=============================================#", "\n"
    );

    print "\n";

    marquesina(@logo);

    print "\n\n";

}

sub copyright {

    my @fin = ("-- == (C) Doddy Hackman 2012 == --");

    print "\n\n";
    marquesina(@fin);
    print "\n\n";

    <stdin>;

    exit(1);

}

sub marquesina {

    #Effect based in the exploits by Jafer Al Zidjali

    my @logo = @_;

    my $car = "|";

    for my $uno (@logo) {
        for my $dos ( split //, $uno ) {

            $|++;

            if ( $car eq "|" ) {
                mostrar( "\b" . $dos . $car, "/" );
            }
            elsif ( $car eq "/" ) {
                mostrar( "\b" . $dos . $car, "-" );
            }
            elsif ( $car eq "-" ) {
                mostrar( "\b" . $dos . $car, "\\" );
            }
            else {
                mostrar( "\b" . $dos . $car, "|" );
            }
            usleep(40_000);
        }
        print "\b ";
    }

    sub mostrar {
        print $_[0];
        $car = $_[1];
    }

}

sub now {

    my ( $scheme, $auth, $path, $query, $frag ) = uri_split( $_[0] );

    if ( $path =~ /(.*)\/(.*)$/ ) {
        my $file = $2;
        if ( download( $_[0], $file ) ) {
        }
    }
}

sub download {
    if ( $nave->mirror( $_[0], $_[1] ) ) {
        if ( -f $_[1] ) {
            return true;
        }
    }
}

sub toma {
    return $nave->get( $_[0] )->content;
}

#The End ?


Un ejemplo de uso



#=============================================#
#             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) (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 == --


Eleкtro

jajaja, me robaste la idea sin saberlo!
Iba a hacerlo exactamente en el mismo buscador xD, mp3skull, que buen buscador gratis!

Gracias por el code!

Un saludo Doddy.








BigBear

na , el mejor es beemp3 pero usa captcha para darte el link.