| 1 | package File::TVShow::Organize; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use File::Path qw(make_path); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use IPC::Cmd qw(can_run); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use File::TVShow::Info; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | our $VERSION = '0.360.1'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | my ($class, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | #default data and states. Other data is created and stored during | ||||||||||||||||||||||||||||||||||||||||||
| 25 | #program execution | ||||||||||||||||||||||||||||||||||||||||||
| 26 | countries => "(UK|US)", | ||||||||||||||||||||||||||||||||||||||||||
| 27 | delete => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | recursion => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | seasonFolder => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | exceptionListSource => $args->{Exceptions} || undef, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'Exceptions'} || undef
MC/DC100%1/1
$args->{'Exceptions'} || undef
$args->{'Exceptions'}
Truth table100%2/2
A
A= $args->{'Exceptions'}
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | ## Additional constructor code goes here. | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | ▶ | if (!defined $self->{exceptionListSource}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | ## Do nothing | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # create an array of pairs seperated by | character | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | my @list1 = split /\|/, $self->{exceptionListSource}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | # now split each item in the array with by the : character use the first | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # value as the key and the second as value | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | foreach my $item(@list1) { | |||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | my ($key, $value) = split(/:/, $item); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | $self->{_exceptionList}{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | sub countries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
countries: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # Set and get countries in case you want to change or add to the defaults | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # use | as your separator | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | my ($self, $countries) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | $self->{countries} = $countries if defined $countries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | return $self->{countries}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 58 | ▶ | sub show_folder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_folder: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | # Set and get path for where new shows are to be stored in the file system | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 58 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 58 | ▶ | if (defined $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 6 | ▶ | if ((-e $path) and (-d $path)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-e $path and -d $path
MC/DC50%1/2
-e $path and -d $path
-e $path
-d $path
Truth table66%2/3
A and B
A= -e $pathB= -d $path
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | $self->{showFolder} = $path; | |||||||||||||||||||||||||||||||||||||||||
| 68 | # Append / if missing from path | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | if ($self->{showFolder} !~ m/.*\/$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | $self->{showFolder} = $self->{showFolder} . '/'; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | $self->{showFolder} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 58 | return $self->{showFolder}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 46 | ▶ | sub new_show_folder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_show_folder: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | # Set and get path to find new files to be moved from live | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 46 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 46 | ▶ | if (defined $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 8 | ▶ | if ((-e $path) and (-d $path)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-e $path and -d $path
MC/DC50%1/2
-e $path and -d $path
-e $path
-d $path
Truth table66%2/3
A and B
A= -e $pathB= -d $path
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 6 | $self->{newShowFolder} = $path; | |||||||||||||||||||||||||||||||||||||||||
| 85 | # Append / if missing from path | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | ▶ | if ($self->{newShowFolder} !~ m/.*\/$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $self->{newShowFolder} = $self->{newShowFolder} . '/'; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | $self->{newShowFolder} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 46 | return $self->{newShowFolder}; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | sub create_show_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_show_hash: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # exit loudly if the path has not been defined by the time this is called | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | ▶ | croak unless defined($self->{showFolder}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # Get the root path of the TV Show folder | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | my $directory = $self->show_folder(); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | my $showNameHolder; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | ▶ | opendir(DIR, $directory) or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | while (my $file = readdir(DIR)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2380 | ▶ | next if ($file =~ m/^\./); # skip hidden files and folders | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1184 | chomp($file); # trim and end of line character | |||||||||||||||||||||||||||||||||||||||||
| 111 | # create the inital hash strings are converted to lower case so | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # "Doctor Who (2005)" becomes | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # "doctor who (2005)" key="doctor who (2005), path="Doctor Who (2005) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 1184 | $self->{shows}{lc($file)}{path} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 115 | # hanle if there is US or UK in the show name | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 1184 | ▶ | if ($file =~ m/\s\(?$self->{countries}\)?$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 40 | $showNameHolder = $file; | |||||||||||||||||||||||||||||||||||||||||
| 118 | # name minus country in $1 country in $2 | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 40 | $showNameHolder =~ s/(.*) \(?($self->{countries})\)?/$1/gi; | |||||||||||||||||||||||||||||||||||||||||
| 120 | #catinate them together again with () around country | ||||||||||||||||||||||||||||||||||||||||||
| 121 | #This is now another key to the same path | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 40 | $self->{shows}{lc($showNameHolder . " ($2)")}{path} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 123 | # create a key to the same path again with out country unless one has | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # been already defined by another show | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # this handles something like "Prey" which has a "Prey US" version | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # and "Prey UK" | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 40 | ▶ | $self->{shows}{lc($showNameHolder)}{path} = $file unless (exists $self->{shows}{lc($showNameHolder)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # Handle shows with Year extensions in the same manner has UK|USA | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 1184 | ▶ | if ($file =~ m/\s\(?\d{4}\)?$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 80 | $showNameHolder = $file; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 80 | $showNameHolder =~ s/(.*) \(?(\d\d\d\d)\)?/$1/gi; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 80 | $self->{shows}{lc($showNameHolder . " ($2)")}{path} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 80 | $self->{shows}{lc($showNameHolder . " $2")}{path} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 135 | $self->{shows}{lc($showNameHolder)}{path} = $file unless | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 80 | ▶ | (exists $self->{shows}{lc($showNameHolder)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | closedir(DIR); | |||||||||||||||||||||||||||||||||||||||||
| 140 | # Does this need to return anything or can it just return $self | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | return $self->{shows}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | sub clear_show_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_show_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | $self->{shows} = (); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 121 | ▶ | sub show_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # Access the shows hash and return the correct directory path for the show | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # name as passed to the funtion | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 121 | my ($self, $show) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 121 | return $self->{shows}{lc($show)}{path}; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | ▶ | sub process_new_shows { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_new_shows: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | my ($self, $curr_dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | ▶ | $curr_dir = $self->new_show_folder() unless defined($curr_dir); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | my $destination; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | ▶ | opendir(DIR, $curr_dir) or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | ▶ | while (my $file = readdir(DIR)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 128 | $destination = undef; | |||||||||||||||||||||||||||||||||||||||||
| 170 | ## Skip hiddenfiles | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 128 | ▶ | next if ($file =~ m/^\./); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | ## Trim the file name incase of end of line marker | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 57 | chomp($file); | |||||||||||||||||||||||||||||||||||||||||
| 174 | ## Skip files that have been processed before. They have had .done appended | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # to to them. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 57 | ▶ | next if ($file =~ m/\.done$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 57 | ▶ | if (!$self->recursion) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 32 | ▶ | next if -d $self->new_show_folder() . $file; ## Skip non-Files | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 25 | ▶ | $self->process_new_shows($curr_dir . $file . "/") if -d $curr_dir . $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # next if ($file !~ m/s\d\de\d\d/i); # skip if SXXEXX is not present in file name | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 55 | my $showData; | |||||||||||||||||||||||||||||||||||||||||
| 184 | # Extract show name, Season and Episode | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 55 | $showData = File::TVShow::Info->new($file); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 55 | ▶ | next if !$showData->is_tv_show(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | # Apply special handling if the show is in the _exceptionList | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 49 | ▶ | if (exists $self->{_exceptionList}{$showData->{organize_name}}) { ##Handle special cases like "S.W.A.T" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | # Replace the original name value with the one found in _exceptionList | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | $showData->{organize_name} = $self->{_exceptionList}{$showData->{organize_name}}; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | # Handle normally using '.' as the space marker name "Somthing.this" becomes "Something this" | ||||||||||||||||||||||||||||||||||||||||||
| 193 | # Strip periods from name. | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 47 | $showData->{organize_name} =~ s/\./ /g; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # If we don't have a show_path skip. Probably an unhandled show name | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # store it in the UnhandledFileNames hash for reporting later. | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 49 | ▶ | if (!defined $self->show_path($showData->{organize_name})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | $self->{UnhandledFileNames}{$file} = $showData->{organize_name}; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # Create the path string for storing the file in the right place | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 47 | $destination = $self->show_folder() . $self->show_path($showData->{organize_name}); | |||||||||||||||||||||||||||||||||||||||||
| 205 | # if this is true. Update the $destination and create the season subfolder if required. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | # if this is false. Do not append the season folder. files should just be stored in the root of the show folder. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 47 | ▶ | if($self->season_folder()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 45 | $destination = $self->create_season_folder($destination, int($showData->{season})); | |||||||||||||||||||||||||||||||||||||||||
| 209 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | # Import the file. This will use rsync to copy the file into place and either rename or delete. | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # see move_show() for implementation details | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 47 | $self->move_show($destination, $curr_dir, $file); | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 7 | close(DIR); | |||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 216 | #return $self; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | sub were_there_errors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
were_there_errors: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | # Check if there has been any files that File::TVShow::Info could not handle | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # Check that the hash UnHandledFileNames has actually been created before | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # checking that is is not empty or you will get an error. | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | if ((defined $self->{UnhandledFileNames}) && (keys %{$self->{UnhandledFileNames}})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"UnhandledFileNames"} and keys %{$$self{"UnhandledFileNames"};}
MC/DC0%0/2
defined $self->{"UnhandledFileNames"} and keys %{$$self{"UnhandledFileNames"};}
defined $self->{"UnhandledFileNames"}
keys %{$$self{"UnhandledFileNames"};}
Truth table33%1/3
A and B
A= defined $self->{"UnhandledFileNames"}B= keys %{$$self{"UnhandledFileNames"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | print "\nThere were unhandled files in the directory\n"; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | print "consider adding them to the exceptionList\n###\n"; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | foreach my $key (keys %{$self->{UnhandledFileNames}}) { | |||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | print "### " . $key . " ==> " . $self->{UnhandledFileNames}{$key} . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | print "###\n"; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | my ($self, $delete) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | ▶ | return $self->{delete} if(@_ == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 5 | ▶ | if (($delete =~ m/[[:alpha:]]/) || ($delete != 0) && ($delete != 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$delete =~ /[[:alpha:]]/ or $delete != 0 and $delete != 1
$delete != 0 and $delete != 1
MC/DC33%1/3
$delete =~ /[[:alpha:]]/ or $delete != 0 and $delete != 1
$delete =~ /[[:alpha:]]/
$delete != 0
$delete != 1
Truth table75%3/4
A or B and C
A= $delete =~ /[[:alpha:]]/B= $delete != 0C= $delete != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | print STDERR "Invalid arguments passed. Value not updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | ▶ | if ($delete == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 3 | $self->{delete} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } elsif ($delete == 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | $self->{delete} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # This return seems like its on a branch of code that is of litle use. | ||||||||||||||||||||||||||||||||||||||||||
| 255 | # Unless the return is checked on being set. | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | return $self->{delete}; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 63 | ▶ | sub recursion { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recursion: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 63 | my ($self, $recursion) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 63 | ▶ | return $self->{recursion} if(@_ == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | if (($recursion =~ m/[[:alpha:]]/) || ($recursion != 0) && ($recursion != 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$recursion =~ /[[:alpha:]]/ or $recursion != 0 and $recursion != 1
$recursion != 0 and $recursion != 1
MC/DC33%1/3
$recursion =~ /[[:alpha:]]/ or $recursion != 0 and $recursion != 1
$recursion =~ /[[:alpha:]]/
$recursion != 0
$recursion != 1
Truth table75%3/4
A or B and C
A= $recursion =~ /[[:alpha:]]/B= $recursion != 0C= $recursion != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | print STDERR "Invalid arguments passed. Value not updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | ▶ | if ($recursion == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | $self->{recursion} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } elsif ($recursion == 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $self->{recursion} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # This return seems like its on a branch of code that is of litle use. | ||||||||||||||||||||||||||||||||||||||||||
| 278 | # Unless the return is checked on being set. | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | return $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 97 | ▶ | sub verbose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 97 | my ($self, $verbose) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 97 | ▶ | return $self->{verbose} if(@_ == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | ▶ | if (($verbose =~ m/[[:alpha:]]/) || ($verbose != 0) && ($verbose != 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$verbose =~ /[[:alpha:]]/ or $verbose != 0 and $verbose != 1
$verbose != 0 and $verbose != 1
MC/DC33%1/3
$verbose =~ /[[:alpha:]]/ or $verbose != 0 and $verbose != 1
$verbose =~ /[[:alpha:]]/
$verbose != 0
$verbose != 1
Truth table75%3/4
A or B and C
A= $verbose =~ /[[:alpha:]]/B= $verbose != 0C= $verbose != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | print STDERR "\n### Invalid arguments passed. Value not updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | ▶ | if ($verbose == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | $self->{verbose} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } elsif ($verbose == 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | $self->{verbose} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | # This return seems like its on a branch of code that is of litle use. | ||||||||||||||||||||||||||||||||||||||||||
| 298 | # Unless the return is checked on being set. | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | return $self->{verbose}; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 53 | ▶ | sub season_folder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
season_folder: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 53 | my ($self, $seasonFolder) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 53 | ▶ | return $self->{seasonFolder} if(@_ == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 4 | ▶ | if (($seasonFolder =~ m/[[:alpha:]]/) || ($seasonFolder != 0) && ($seasonFolder != 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$seasonFolder =~ /[[:alpha:]]/ or $seasonFolder != 0 and $seasonFolder != 1
$seasonFolder != 0 and $seasonFolder != 1
MC/DC33%1/3
$seasonFolder =~ /[[:alpha:]]/ or $seasonFolder != 0 and $seasonFolder != 1
$seasonFolder =~ /[[:alpha:]]/
$seasonFolder != 0
$seasonFolder != 1
Truth table75%3/4
A or B and C
A= $seasonFolder =~ /[[:alpha:]]/B= $seasonFolder != 0C= $seasonFolder != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | print STDERR "\n### Invalid arguments passed. Value not updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | ▶ | if ($seasonFolder == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | $self->{seasonFolder} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } elsif ($seasonFolder == 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | $self->{seasonFolder} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # This return seems like its on a branch of code that is of litle use. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # Unless the return is checked on being set. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | return $self->{seasonFolder}; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 45 | ▶ | sub create_season_folder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_season_folder: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 45 | my ($self, $_path, $season) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 45 | my $path = $_path . '/'; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 45 | ▶ | if ($season == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | $path = $path . 'Specials' | |||||||||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 39 | $path = $path . 'Season' . $season; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | # Show Season folder being created if verbose mode is true. | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 45 | ▶ | if($self->verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | make_path($path, { verbose => 1 }) unless -e $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # Verbose mode is false so work silently. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 45 | ▶ | make_path($path) unless -e $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 45 | return $path; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 47 | ▶ | sub move_show { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move_show: called CC=7 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 47 | my ($self, $destination, $source, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | # If the destination folder or source filder are not defined or no file is | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # passed exit with errors | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 47 | ▶ | carp "Destination not passed." unless defined($destination); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 47 | ▶ | carp "Source not passed." unless defined($source); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 47 | ▶ | carp "File not passed." unless defined($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | # rewrite paths so they are rsync friendly. This means escape spaces and | ||||||||||||||||||||||||||||||||||||||||||
| 357 | # other special characters. | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 47 | ($destination, $source) = _rsync_prep ($destination,$source); | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | # create the command string to be used in system() call | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # Set --progress if verbose is true | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # Get path to rsync using IPC::Cmd | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 47 | my $command = can_run('rsync'); | |||||||||||||||||||||||||||||||||||||||||
| 365 | 47 | $command .= " -ta "; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 47 | ▶ | $command = $command . "--progress " if ($self->verbose); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 47 | $command = $command . $source . $file . " " . $destination; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 47 | system($command); | |||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 47 | ▶ | if($? == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | # If delete is true unlink file. | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if($self->delete) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | unlink($source . $file); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | # delete is false so merely rename the file by appending .done | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | move($source . $file, $source . $file . ".done") | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 380 | #report failed processing? Error on rsync command return code | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 47 | print "## Something went very wrong. Rsync failed for some reason.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 47 | print "## rsync err $?\n"; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 47 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | # This interal sub-routine prepares paths for use with external rsynch command | ||||||||||||||||||||||||||||||||||||||||||
| 389 | # Need to escape special characters | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 47 | ▶ | sub _rsync_prep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rsync_prep: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 47 | my ($dest, $source) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | # escape spaces and () characters to work with the rsync command. | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 47 | $dest =~ s/\(/\\(/g; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 47 | $dest =~ s/\)/\\)/g; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 47 | $dest =~ s/ /\\ /g; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 47 | $dest = $dest . "/"; | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 47 | $source =~ s/ /\\ /g; | |||||||||||||||||||||||||||||||||||||||||
| 401 | #$source = $source . "/"; | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 47 | return $dest, $source; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | __END__ | ||||||||||||||||||||||||||||||||||||||||||