App-Plex-Archiver
view release on metacpan or search on metacpan
bin/plex-archiver view on Meta::CPAN
unless (-d "$source_dir") {
print("Error: '$source_dir' must be an existing directory.\n\n");
pod2usage(1);
}
unless (-d "$destination_dir") {
my $create_dest = ask_yes_or_no("Destination directory '$destination_dir' does not exist. Do you wish to create it? ");
if ($create_dest) {
printf("Creating desitnation directory '%s'...", $destination_dir);
if ($dry_run) {
say " SKIPPED [DRY RUN]";
} else {
eval {
make_path($destination_dir);
};
die("Failed to create path '$destination_dir': $@") if ($@);
say " DONE!";
}
}
}
#----------------------------
# Prepare for TMDB queries
#----------------------------
my ($error, $tmdb_api_key) = get_tmbd_api_key($api_key_filename, $debug);
if ($error) {
bin/plex-archiver view on Meta::CPAN
}
$new_name .= " {tmdb-$tmdb_id}";
}
my $new_dest_dir = File::Spec->catdir($destination_dir, $new_name);
my $new_filename = $new_name . '.' . $ext;
my $new_dest_filename = File::Spec->catfile($new_dest_dir, $new_filename);
# Make the new destination directory
if ($dry_run) {
say "DRY RUN: Make directory '$new_dest_dir'";
} else {
eval {
make_path($new_dest_dir);
};
die("Failed to create path '$new_dest_dir': $@") if ($@);
}
my $action = ($move ? "Moving" : "Copying");
printf("%s original file '%s' to '%s'...", $action, $entry, $new_dest_filename);
if ($dry_run) {
say " SKIPPED [DRY RUN]";
} else {
copy_file($entry, $new_dest_filename, $move);
say " DONE!";
}
}
exit(1);
__END__
# Script Documentation
#
( run in 0.675 second using v1.01-cache-2.11-cpan-96521ef73a4 )