CDDB_get
view release on metacpan or search on metacpan
CDDB_get.pm view on Meta::CPAN
$input = 0 if $multi;
print STDERR Dumper($config) if $debug;
$CDDB_HOST = $config->{CDDB_HOST} if (defined($config->{CDDB_HOST}));
$CDDB_PORT = $config->{CDDB_PORT} if (defined($config->{CDDB_PORT}));
$CDDB_MODE = $config->{CDDB_MODE} if (defined($config->{CDDB_MODE}));
$CD_DEVICE = $config->{CD_DEVICE} if (defined($config->{CD_DEVICE}));
$HELLO_ID = $config->{HELLO_ID} if (defined($config->{HELLO_ID}));
$PROTO_VERSION = $config->{PROTO_VERSION} if (defined($config->{PROTO_VERSION}));
my $HTTP_PROXY = $config->{HTTP_PROXY} if (defined($config->{HTTP_PROXY}));
my $FW=1 if (defined($config->{FW}));
if(defined($diskid)) {
$id=$diskid->[0];
$total=$diskid->[1];
$toc=$diskid->[2];
} else {
my $diskid=get_discids($CD_DEVICE);
$id=$diskid->[0];
$total=$diskid->[1];
CDDB_get.pm view on Meta::CPAN
my $id=$HELLO_ID;
$id =~ s/ /+/g;
my $url = "/~cddb/cddb.cgi?cmd=$query2&hello=$id&proto=$PROTO_VERSION";
my $host=$CDDB_HOST;
my $port=80;
my ($user,$pass);
if($HTTP_PROXY) {
if($HTTP_PROXY =~ /^(http:\/\/|)(.+?):(.+)\@(.+?):(.+)/) {
$user=$2;
$pass=$3;
$host=$4;
$port=$5;
} elsif($HTTP_PROXY =~ /^(http:\/\/|)(.+?):(\d+)/) {
$host=$2;
$port=$3;
}
$url="http://$CDDB_HOST".$url." HTTP/1.0";
}
print STDERR "cddb: connecting to $host:$port\n" if $debug;
$socket=IO::Socket::INET->new(PeerAddr=>$host, PeerPort=>$port,
Proto=>"tcp",Type=>SOCK_STREAM) or die "cannot connect to cddb db: $host:$port [$!]";
CDDB_get.pm view on Meta::CPAN
print $socket "GET $url\n";
if($user) {
my $cred = encode_base64("$user:$pass");
print $socket "Proxy-Authorization: Basic $cred\n";
}
print $socket "\n";
print $socket "\n" if $FW;
if($HTTP_PROXY) {
while(<$socket> =~ /^\S+/){};
}
$return=<$socket>;
chomp $return;
print STDERR "cddb: http result: $return\n" if $debug;
} else {
die "unkown mode: $CDDB_MODE for querying cddb";
}
CDDB_get.pm view on Meta::CPAN
my $id=$HELLO_ID;
$id =~ s/ /+/g;
my $url = "/~cddb/cddb.cgi?cmd=$query2&hello=$id&proto=$PROTO_VERSION";
my $host=$CDDB_HOST;
my $port=80;
my ($user,$pass);
if($HTTP_PROXY) {
if($HTTP_PROXY =~ /^(http:\/\/|)(.+?):(.+)\@(.+?):(.+)/) {
$user=$2;
$pass=$3;
$host=$4;
$port=$5;
} elsif($HTTP_PROXY =~ /^(http:\/\/|)(.+?):(\d+)/) {
$host=$2;
$port=$3;
}
$url="http://$CDDB_HOST".$url." HTTP/1.0";
}
print STDERR "cddb: connecting to $host:$port\n" if $debug;
$socket=IO::Socket::INET->new(PeerAddr=>$host, PeerPort=>$port,
Proto=>"tcp",Type=>SOCK_STREAM) or die "cannot connect to cddb db: $host:$port [$!]";
CDDB_get.pm view on Meta::CPAN
print $socket "GET $url\n";
if($user) {
my $cred = encode_base64("$user:$pass");
print $socket "Proxy-Authorization: Basic $cred\n";
}
print $socket "\n";
print $socket "\n" if $FW;
if($HTTP_PROXY) {
while(<$socket> =~ /^\S+/){};
}
while(<$socket>) {
last if(/^\./);
push @lines,$_;
}
close $socket;
} else {
die "unkown mode: $CDDB_MODE for querying cddb";
# $config{CDDB_PORT}=8880; # set cddb port
# $config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http, this is switched with -f
# $config{CD_DEVICE}="/dev/cdrom"; # set cd device
# $config{HELLO_ID} ="root nowhere.com fastrip 0.77"; # hello string: username hostname clientname version
# $config{PROTO_VERSION} = 5; # cddb protokol version
# get proxy settings for cddb mode
$config{HTTP_PROXY}=$ENV{http_proxy} if $ENV{http_proxy}; # maybe wanna use a proxy ?
$config{CDDB_MODE}="http" if($option{f});
if($option{F}) {
$config{CDDB_MODE}="http";
$config{FW}=1;
}
$config{CD_DEVICE}=$option{c} if $option{c};
# user interaction welcome?
( run in 1.193 second using v1.01-cache-2.11-cpan-71847e10f99 )