App-Pimpd
view release on metacpan or search on metacpan
lib/App/Pimpd/Transfer.pm view on Meta::CPAN
}
my @tracks = grep {
$artist eq $_->artist
} $mpd->collection->songs_from_album($album);;
@tracks = map { $config{music_directory} . '/' . $_->file } @tracks;
if(remote_host()) {
for(@tracks) {
#$_ = escape($_);
_scp($_, $destination);
}
}
else {
for(@tracks) {
#$_ = escape($_);
if(copy($_, $destination)) {
printf("%40.40s => %s\n", basename($_), $destination);
}
else {
warn("cp_album: $!");
}
}
}
return;
}
lib/App/Pimpd/Transfer.pm view on Meta::CPAN
}
else {
confess("cp: $!");
}
}
return;
}
sub _scp {
my($source, $dest) = @_;
$source = escape($source);
system('scp', '-r',
"-P $config{ssh_port}",
qq($config{ssh_host}:$source), $dest
) == 0;# or confess("scp: $!");
return;
}
lib/App/Pimpd/Validate.pm view on Meta::CPAN
BEGIN {
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
invalid_regex
to_terminal
empty_playlist
invalid_playlist_pos
remote_host
escape
get_valid_lists
isa_valid_playlist
);
}
use Carp 'croak';
use App::Pimpd;
use Term::ExtendedColor qw(fg);
lib/App/Pimpd/Validate.pm view on Meta::CPAN
return(@lists);
}
sub isa_valid_playlist {
my @playlists = @_;
my @lists = $mpd->collection->all_playlists;
map { s/^\s+//m } @lists;
return ($_[0] ~~ @lists) ? 1 : 0;
}
sub escape {
my $str = shift;
$str =~ s/([;<>*|`&\$!#()[\]{}:'" ])/\\$1/g;
return $str;
}
sub remote_host {
not exists($config{mpd_host}) and $config{mpd_host} = 'localhost';
if(($config{mpd_host} eq 'localhost') or ($config{mpd_host} eq '127.0.0.1')) {
return 0;
lib/App/Pimpd/Validate.pm view on Meta::CPAN
=head1 SYNOPSIS
use App::Pimpd;
use App::Pimpd::Validate;
if(to_terminal()) {
print "Yes, you can see me!\n";
}
$str = escape($str);
if(invalid_playlist_pos(42)) {
print STDERR "No song on playlist position 42!\n";
}
=head1 DESCRIPTION
App::Pimpd::Validate provides functions for verifying certain conditions that's
crucial for other functions.
lib/App/Pimpd/Validate.pm view on Meta::CPAN
=item to_terminal()
Returns true if output is going to a TTY.
=item invalid_playlist_pos()
Parameters: $integer
Returns true if supplied argument is an invalid playlist position.
=item escape()
Parameters: $string
Returns: $string
Takes the supplied string and escapes it from evil chars the shell might
otherwise munch.
=item get_valid_lists()
Parameters: @playlists
Returns: @valid_playlists
Takes a list and traverses it, checking if every playlist exists.
If a playlist is found to be non-existant, tries to match the string against
( run in 0.400 second using v1.01-cache-2.11-cpan-c21f80fb71c )