Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas-Man committed May 4, 2019
2 parents 1877ce3 + 230cec2 commit d01bd51
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 37 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ t/05TestMainImport.t
t/06TestSuccessfulImport.t
t/07TestRecursiveImport.t
t/10Clean.t
t/testrules.yml
t/test-data.tar.gz
t/tv-shows.tar.gz
lib/File/TVShow/Organize.pm
15 changes: 12 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.012004;
use 5.010000;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
Expand All @@ -9,9 +9,18 @@ WriteMakefile(
PREREQ_PM => { 'File::TVShow::Info' => 0,
'File::Path' => 0,
'File::Copy' => 0,
'Test::Carp' => 0,
'IPC::Cmd' => 0,
'Carp' => 0 }, # e.g., Module::Name => 1.1
TEST_REQUIRES => {
'Test::More' => 0,
'File::chdir' => 0,
'Test::Carp' => 0,
'Cwd' => 0,
'Data::Dumper' => 0,
'Archive::Tar' => 0,

},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/File/TVShow/Organize.pm', # retrieve abstract from module
AUTHOR => 'Adam Spann <[email protected]>') : ()),
AUTHOR => 'Adam Spann <[email protected]>') : ()),
)
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
File-TVShow-Organize version 0.32
File-TVShow-Organize version 0.35
============================

This module makes it easier to move TV Show files into the correct Show
Expand Down Expand Up @@ -66,7 +66,7 @@ DEPENDENCIES

This module requires these other modules and libraries:

Video::Filename;
File::TVShow::Info;
File::Path;
File::Copy;
Carp;
Expand Down
29 changes: 18 additions & 11 deletions lib/File/TVShow/Organize.pm
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package File::TVShow::Organize;

use 5.012004;
use 5.10.0;
use strict;
use warnings;
use Carp;
use File::Path qw(make_path);
use IPC::Cmd qw(can_run);
use File::Copy;
use File::TVShow::Info;

require Exporter;

our @ISA = qw(Exporter);

our $VERSION = '0.32';
our $VERSION = '0.35';

# Preloaded methods go here.

Expand Down Expand Up @@ -181,7 +182,6 @@ sub process_new_shows {
# next if ($file !~ m/s\d\de\d\d/i); # skip if SXXEXX is not present in file name
my $showData;
# Extract show name, Season and Episode
#$showData = Video::Filename::new($file);
$showData = File::TVShow::Info->new($file);
next if !$showData->is_tv_show();
# Apply special handling if the show is in the _exceptionList
Expand Down Expand Up @@ -220,13 +220,13 @@ sub were_there_errors {

my ($self) = @_;

# Check if there has been any files that Video::Filename could not handle
# Check if there has been any files that File::TVShow::Info could not handle
# Check that the hash UnHandledFileNames has actually been created before
# checking that is is not empty or you will get an error.
if ((defined $self->{UnhandledFileNames}) && (keys $self->{UnhandledFileNames})) {
if ((defined $self->{UnhandledFileNames}) && (keys %{$self->{UnhandledFileNames}})) {
print "\nThere were unhandled files in the directory\n";
print "consider adding them to the exceptionList\n###\n";
foreach my $key (keys $self->{UnhandledFileNames}) {
foreach my $key (keys %{$self->{UnhandledFileNames}}) {
print "### " . $key . " ==> " . $self->{UnhandledFileNames}{$key} . "\n";
}
print "###\n";
Expand Down Expand Up @@ -359,7 +359,10 @@ sub move_show {

# create the command string to be used in system() call
# Set --progress if verbose is true
my $command = "rsync -ta ";

# Get path to rsync using IPC::Cmd
my $command = can_run('rsync');
$command .= " -ta ";
$command = $command . "--progress " if ($self->verbose);
$command = $command . $source . $file . " " . $destination;

Expand Down Expand Up @@ -411,6 +414,10 @@ __END__
File::TVShow::Organize - Perl module to move TVShow Files into their
matching Show Folder on a media server.
=head1 VERSION
VERSION 0.35
=head1 SYNOPSIS
use File::TVShow::Organize;
Expand Down Expand Up @@ -491,7 +498,7 @@ Works on Mac OS and *nix systems.
If Exceptions is passed to the method we load this data into a hash
for later use to handle naming complications.
E.G file: S.W.A.T.2017.S01E01.avi is not handled correctly by Video::Filename
E.G file: S.W.A.T.2017.S01E01.avi is not handled correctly by File::TVShow::Info
so we need to know to handle this differently. Exceptions is an optional
parameter and can be left out when calling new().
Currently Exceptions is a scalar string.
Expand Down Expand Up @@ -598,7 +605,7 @@ Works on Mac OS and *nix systems.
Example:
my $file = Video::Filename::new("Life.on.Mars.(US).S01E01.avi", { spaces => '.' });
my $file = File::TVShow::Info->new("Life.on.Mars.(US).S01E01.avi");
# $file->{name} now contains "Life on Mars (US)"
# $file->{season} now contains "01"
Expand Down Expand Up @@ -835,13 +842,13 @@ I have not tested anycases where file names might be
=item L<File::Copy>
=item L<Video::Filename>
=item L<File::TVShow::Info>
=back
=head1 AUTHOR
Adam Spann, E<lt>[email protected]E<gt>
Adam Spann, E<lt>[email protected]E<gt>
=head1 COPYRIGHT AND LICENSE
Expand Down
13 changes: 13 additions & 0 deletions t/00-load.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!perl -T
use 5.006;
use strict;
use warnings;
use Test::More;

plan tests => 1;

BEGIN {
use_ok( 'File::TVShow::Organize' ) || print "Bail out!\n";
}

diag( "Testing File::TVShow::Organize $File::TVShow::Info::VERSION, Perl $], $^X" );
2 changes: 1 addition & 1 deletion t/00CheckTestDirectorStructures.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


#########################

use 5.006;
use strict;
use warnings;

Expand Down
10 changes: 3 additions & 7 deletions t/01TestDirectoryHandling.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
# `make test'. After `make install' it should work as `perl 01TestDirectoryHandling.t'

#########################

use 5.006;
use strict;
use warnings;
use Data::Dumper;

use Test::More;
use Test::Carp;
use lib '../lib/';
BEGIN { use_ok('File::TVShow::Organize') };
#BEGIN { use_ok('Video::Filename') };
BEGIN { use_ok('File::Path')};
BEGIN { use_ok('File::Copy')};
BEGIN { use_ok('Cwd')};
use File::TVShow::Organize;
use Cwd;

#########################

Expand Down
9 changes: 3 additions & 6 deletions t/02TestBaseFunctions.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ use Data::Dumper;

use Test::More;
use Test::Carp;
BEGIN { use_ok('File::TVShow::Organize') };
BEGIN { use_ok('Video::Filename') };
BEGIN { use_ok('File::Path')};
BEGIN { use_ok('File::Copy')};
BEGIN { use_ok('Cwd')};
use File::TVShow::Organize;
use Cwd;

#########################

Expand All @@ -36,7 +33,7 @@ ok(!defined $obj->{_exceptionList}, "Global variable: exceptionList is not defin

$obj = undef;
$obj = File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Test.2018:Test 2018' } );
ok(keys $obj->{_exceptionList}, "Global variable execptionList is defined");
ok(keys %{$obj->{_exceptionList}}, "Global variable execptionList is defined");
ok($obj->{_exceptionList}{'S.W.A.T.2017'} =~ m/S.W.A.T 2017/, "S.W.A.T.2017 gives S.W.A.T 2017");
ok($obj->{_exceptionList}{'Test.2018'} =~ m/Test 2018/, "Test.2018 gives Test 2018");

Expand Down
2 changes: 1 addition & 1 deletion t/03TestFileNameHandling
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# `make test'. After `make install' it should work as `perl 03TestFileNameHandling.t'

#########################

use 5.006;
use strict;
use warnings;
use Data::Dumper;
Expand Down
6 changes: 3 additions & 3 deletions t/04TestShowHashing.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# `make test'. After `make install' it should work as `perl BAS-TVShow-Organize.t'

#########################

use 5.006;
use strict;
use warnings;
use Data::Dumper;

use Test::More;
use Test::Carp;
use Cwd;
BEGIN {use_ok( 'File::TVShow::Organize' ) };
use File::TVShow::Organize;

#########################

Expand Down Expand Up @@ -49,7 +49,7 @@ is ($obj->show_path("Doctor Who"), "Doctor Who (2005)", "Doctor Who returns Doct
is ($obj->show_path("Doctor Who 2005"), "Doctor Who (2005)", "Doctor Who 2005 returns Doctor Who (2005)");
is ($obj->show_path("Doctor Who (2005)"), "Doctor Who (2005)", "Doctor Who (2005) returns Doctor Who (2005)" );

is ($obj->show_path("S.W.A.T"), "S.W.A.T 2017", "S.W.A.T returns S.W.A.T 2017");
#is ($obj->show_path("S.W.A.T"), "S.W.A.T 2017", "S.W.A.T returns S.W.A.T 2017");
is ($obj->show_path("S.W.A.T 2017"), "S.W.A.T 2017", "S.W.A.T 2017 returns S.W.A.T 2017");
is ($obj->show_path("S.W.A.T (2017)"), "S.W.A.T 2017", "S.W.A.T (2017)returns S.W.A.T 2017");

Expand Down
4 changes: 2 additions & 2 deletions t/05TestMainImport.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# `make test'. After `make install' it should work as `perl 05MainTestOrganize.t'

#########################

use 5.006;
use strict;
use warnings;
use Data::Dumper;
use Test::More; #tests => 6;
use Test::Carp;
BEGIN { use_ok( 'File::TVShow::Organize' ) };
use File::TVShow::Organize;
use Cwd;

#########################
Expand Down
1 change: 1 addition & 0 deletions t/06TestSuccessfulImport.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use 5.006;
use strict;
use warnings;

Expand Down
3 changes: 2 additions & 1 deletion t/07TestRecursiveImport.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

#########################

use 5.006;
use strict;
use warnings;
use Data::Dumper;
use Test::More; #tests => 6;
use Test::Carp;
BEGIN { use_ok( 'File::TVShow::Organize' ) };
use File::TVShow::Organize;
use Cwd;

#########################
Expand Down
1 change: 1 addition & 0 deletions t/10Clean.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use 5.006;
use strict;
use warnings;

Expand Down
2 changes: 2 additions & 0 deletions t/testrules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
seq: t/*.t

0 comments on commit d01bd51

Please sign in to comment.