From dcaa19122dc9c7ed7e313e2044d827cc741a2374 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 25 Feb 2019 23:24:28 +0900 Subject: [PATCH 01/11] Removed ==== and <<< as well as added missing " at end of line. --- TODO | 2 -- lib/Video/File/TVShow/Import.pm | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/TODO b/TODO index 2543601..02f36e9 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ These items should be completed before the next major push to GitHub or local origin. -<<<<<<< HEAD Update Testing to make it more organised again. Its gotten a bit out of control. Look at using Path::Tiny for path and file handling. ->>>>>>> origin/development diff --git a/lib/Video/File/TVShow/Import.pm b/lib/Video/File/TVShow/Import.pm index ce9da53..f325c33 100644 --- a/lib/Video/File/TVShow/Import.pm +++ b/lib/Video/File/TVShow/Import.pm @@ -575,7 +575,7 @@ Works on Mac OS and *nix systems. key: life on mars us => folder: Life on Mars (US) key: life on mars => folder: Life on Mars (US) - However if there already exists a folder: "Life on Mars" and a folder "Life on Mars (US) + However if there already exists a folder: "Life on Mars" and a folder "Life on Mars (US)" the following hash key:folder pairs will be created. Note that the folderis differ key: life on mars => folder: Life on Mars key: life on mars (us) => folder: Life on Mars (US) From 3372d1a80cf589ccdabc660dd1d13061458345d2 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 4 Mar 2019 23:01:28 +0900 Subject: [PATCH 02/11] Migration from CamelCase to snake_case Based on feed back I have moved from camelCase to snake_case which is standard perl coding style. --- Examples/basic.pl | 14 +-- Examples/myPersonalCode.pl | 16 +-- lib/Video/File/TVShow/Import.pm | 168 ++++++++++++++++---------------- t/01TestDirectoryHandling.t | 30 +++--- t/02TestBaseFunctions.t | 16 +-- t/04TestShowHashing.t | 71 +++++++------- t/05TestMainImport.t | 26 ++--- t/07TestRecursiveImport.t | 12 +-- 8 files changed, 174 insertions(+), 179 deletions(-) diff --git a/Examples/basic.pl b/Examples/basic.pl index ae9dfa1..bf3b08a 100644 --- a/Examples/basic.pl +++ b/Examples/basic.pl @@ -9,28 +9,28 @@ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); - $obj->newShowFolder("/tmp/"); - $obj->showFolder("/absolute/path/to/TV Shows"); + $obj->new_show_folder("/tmp/"); + $obj->show_folder("/absolute/path/to/TV Shows"); - if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) { + if((!defined $obj->new_show_folder()) || (!defined $obj->show_folder())) { print "Verify your paths. Something is wrong\n"; exit; } # Create a hash for matching file name to Folders - $obj->createShowHash(); + $obj->create_show_hash(); # Delete files after processing. The default is to rename the files by appending ".done" $obj->delete(1); # Do not create sub folders under the the show's parent folder. All files should be dumped # into the parent folder. The default is to create season folders. - $obj->seasonFolder(0); + $obj->season_folder(0); # Batch process a folder containing TV Show files - $obj->processNewShows(); + $obj->process_new_shows(); # Report any file names which could not be handled automatically. - $obj->wereThereErrors(); + $obj->were_there_errors(); #end of program diff --git a/Examples/myPersonalCode.pl b/Examples/myPersonalCode.pl index fd55750..6bce45b 100644 --- a/Examples/myPersonalCode.pl +++ b/Examples/myPersonalCode.pl @@ -4,8 +4,8 @@ # before I do a make install for the module. #use lib "/Users/aspann/dev/BAS-TVShow-Import/lib/"; -# Note I do not personally do any case testing as I have been using this code for some time and am very -# familiar with its operation. +# Note I do not personally do any case testing as I have been using this code +# for some time and am very familiar with its operation. use strict; use warnings; @@ -16,15 +16,15 @@ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); -$obj->newShowFolder("/Volumes/Drobo/completed"); -$obj->showFolder("/Volumes/Drobo/TV Shows"); +$obj->new_show_folder("/Volumes/Drobo/completed"); +$obj->show_folder("/Volumes/Drobo/TV Shows"); -$obj->createShowHash(); +$obj->create_show_hash(); -$obj->processNewShows(); +$obj->process_new_shows(); -# if you wish to use the plex command here you will need to check what number matches your TV Library to trigger -# a reload of the correct items. +# if you wish to use the plex command here you will need to check what number +# matches your TV Library to trigger a reload of the correct items. # See https://support.plex.tv/articles/201242707-plex-media-scanner-via-command-line/ for details. my $plexCommand = "/Applications/Plex\\ Media\\ Server.app/Contents\\/MacOS\\/Plex\\ Media\\ Scanner -s -c 1 > /dev/null 2>&1"; diff --git a/lib/Video/File/TVShow/Import.pm b/lib/Video/File/TVShow/Import.pm index f325c33..3eaa7ef 100644 --- a/lib/Video/File/TVShow/Import.pm +++ b/lib/Video/File/TVShow/Import.pm @@ -62,7 +62,7 @@ sub countries { # it's your call, but in Perl-land the usual convention is to use # snakecase instead of camel case for functions and methods. # E.g., here I'd expect to have 'show_folder' -sub showFolder { +sub show_folder { # Set and get path for where new shows are to be stored in the file system my ($self, $path) = @_; if (defined $path) { @@ -79,7 +79,7 @@ sub showFolder { return $self->{showFolder}; } -sub newShowFolder { +sub new_show_folder { # Set and get path to find new files to be imported from live my ($self, $path) = @_; if (defined $path) { @@ -96,7 +96,7 @@ sub newShowFolder { return $self->{newShowFolder}; } -sub createShowHash { +sub create_show_hash { my ($self) = @_; @@ -104,7 +104,7 @@ sub createShowHash { croak unless defined($self->{showFolder}); # Get the root path of the TV Show folder - my $directory = $self->showFolder(); + my $directory = $self->show_folder(); my $showNameHolder; opendir(DIR, $directory) or die $!; @@ -145,14 +145,14 @@ sub createShowHash { } -sub clearShowHash { +sub clear_show_hash { my ($self) = @_; $self->{shows} = (); return $self; } -sub showPath { +sub show_path { # Access the shows hash and return the correct directory path for the show # name as passed to the funtion @@ -160,10 +160,10 @@ sub showPath { return $self->{shows}{lc($show)}{path}; } -sub processNewShows { +sub process_new_shows { my ($self, $curr_dir) = @_; - $curr_dir = $self->newShowFolder() unless defined($curr_dir); + $curr_dir = $self->new_show_folder() unless defined($curr_dir); my $destination; @@ -178,9 +178,9 @@ sub processNewShows { # to to them. next if ($file =~ m/\.done$/); if (!$self->recursion) { - next if -d $self->newShowFolder() . $file; ## Skip non-Files + next if -d $self->new_show_folder() . $file; ## Skip non-Files } else { - $self->processNewShows($curr_dir . $file . "/") if -d $curr_dir . $file; + $self->process_new_shows($curr_dir . $file . "/") if -d $curr_dir . $file; }; next if ($file !~ m/s\d\de\d\d/i); # skip if SXXEXX is not present in file name my $showData; @@ -195,29 +195,29 @@ sub processNewShows { $showData = Video::Filename::new($file, { spaces => '.'}); } - # If we don't have a showPath skip. Probably an unhandled show name + # If we don't have a show_path skip. Probably an unhandled show name # store it in the UnhandledFileNames hash for reporting later. - if (!defined $self->showPath($showData->{name})) { + if (!defined $self->show_path($showData->{name})) { $self->{UnhandledFileNames}{$file} = $showData->{name}; next; } # Create the path string for storing the file in the right place - $destination = $self->showFolder() . $self->showPath($showData->{name}); + $destination = $self->show_folder() . $self->show_path($showData->{name}); # if this is true. Update the $destination and create the season subfolder if required. # if this is false. Do not append the season folder. files should just be stored in the root of the show folder. - if($self->seasonFolder()) { - $destination = $self->createSeasonFolder($destination, $showData->{season}); + if($self->season_folder()) { + $destination = $self->create_season_folder($destination, $showData->{season}); }; # Import the file. This will use rsync to copy the file into place and either rename or delete. - # see importShow() for implementation details - $self->importShow($destination, $curr_dir, $file); + # see import_show() for implementation details + $self->import_show($destination, $curr_dir, $file); } close(DIR); return; #return $self; } -sub wereThereErrors { +sub were_there_errors { my ($self) = @_; @@ -302,7 +302,7 @@ sub verbose { } } -sub seasonFolder { +sub season_folder { my ($self, $seasonFolder) = @_; return $self->{seasonFolder} if(@_ == 1); @@ -322,7 +322,7 @@ sub seasonFolder { } } -sub createSeasonFolder { +sub create_season_folder { my ($self, $_path, $season) = @_; @@ -344,7 +344,7 @@ sub createSeasonFolder { } -sub importShow { +sub import_show { my ($self, $destination, $source, $file) = @_; @@ -356,7 +356,7 @@ sub importShow { # rewrite paths so they are rsync friendly. This means escape spaces and # other special characters. - ($destination, $source) = _rsyncPrep($destination,$source); + ($destination, $source) = _rsync_prep ($destination,$source); # create the command string to be used in system() call # Set --progress if verbose is true @@ -385,7 +385,7 @@ sub importShow { # This interal sub-routine prepares paths for use with external rsynch command # Need to escape special characters -sub _rsyncPrep { +sub _rsync_prep { my ($dest, $source) = @_; @@ -420,29 +420,29 @@ matching Show Folder on a media server. my $obj = Video::File::TVShow::Import->new(); - $obj->newShowFolder("/tmp/"); - $obj->showFolder("/absolute/path/to/TV Shows"); + $obj->new_show_folder("/tmp/"); + $obj->show_folder("/absolute/path/to/TV Shows"); - if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) { + if((!defined $obj->new_show_folder()) || (!defined $obj->show_folder())) { print "Verify your paths. Something in wrong\n"; exit; } # Create a hash for matching file name to Folders - $obj->createShowHash(); + $obj->create_show_hash(); # Delete files are processing. $obj->delete(1); # Don't create sub Season folders under the root show name folder. # Instead just dump them all into the root folder - $obj->seasonFolder(0); + $obj->season_folder(0); # Batch process a folder containing TVShow files - $obj->processNewShows(); + $obj->process_new_shows(); # Report any file names which could not be handled automatically. - $obj->wereThereErrors(); + $obj->were_there_errors(); #end of program @@ -457,7 +457,7 @@ show name and season. Season2 -> Castle.S02E01.avi Specials -> Castle.S00E01.avi -This season folder behaviour can be disabled by calling seasonFolder(0). In this case +This season folder behaviour can be disabled by calling season_folder(0). In this case all files are simply placed under Castle without sorting into season folders. Source files are renamed or deleted upon successful relocation. @@ -476,10 +476,6 @@ have already been successfully processed in previous executions of code using th Works on Mac OS and *nix systems. -=head2 EXPORT - - None by default. - =head1 Methods =head2 new @@ -520,15 +516,15 @@ Works on Mac OS and *nix systems. This allows the system to match against programs names such as Agent X US / Agent X (US) / Agent X and reference the same single folder -=head2 showFolder +=head2 show_folder Arguments: None or String Set the path return undef is the path is invalid - $obj->showFolder("/path/to/folder"); + $obj->show_folder("/path/to/folder"); Return the path to the folder - $obj->showFolder(); + $obj->show_folder(); Always confirm this does not return undef before using. undef will be returned if the path is invalid. @@ -541,15 +537,15 @@ Works on Mac OS and *nix systems. If the path is invalid this would leave the internal value as being undef. -=head2 newShowFolder +=head2 new_show_folder Arguments: None or String Set the path return undef is the path is invalid - $obj->newShowFolder("/path/to/folder"); + $obj->new_show_folder("/path/to/folder"); Return the path to the folder - $obj->newShowFolder(); + $obj->new_show_folder(); Always confirm this does not return undef before using. undef will be returned if the path is invalid. @@ -560,11 +556,11 @@ Works on Mac OS and *nix systems. This is where new files to be add to the TV Show store reside on the file system. -=head2 createShowHash +=head2 create_show_hash Arguments: None - $obj->createShowHash; + $obj->create_show_hash; This function creates a hash of show names with the correct path to store data based on the directories that are found in showFolder. @@ -584,22 +580,22 @@ Works on Mac OS and *nix systems. As such file naming relating to country of origin is important if you are importing versions of the same show based on country. -=head2 clearShowHash +=head2 clear_show_hash Arguments: None - This function clears the ShowHash data so that createShowHash can be run - again before or after a folder change which might occur if showFolder() were + This function clears the ShowHash data so that create_show_hash can be run + again before or after a folder change which might occur if show_folder() were to be set to a new folder. -=head2 showPath +=head2 show_path Arguments: String - $obj->showPath("Life on Mars US") returns the name of the folder "Life on Mars (US)" + $obj->show_path("Life on Mars US") returns the name of the folder "Life on Mars (US)" or undef if "Life on Mars US" does not exist as a key. - No key will be found if there was no folder found when $obj->createShowHash was called. + No key will be found if there was no folder found when $obj->create_show_hash was called. Example: @@ -608,21 +604,21 @@ Works on Mac OS and *nix systems. # $file->{name} now contains "Life on Mars (US)" # $file->{season} now contains "01" - my $dest = "/path/to/basefolder/" . $obj->showPath($file->{name}); + my $dest = "/path/to/basefolder/" . $obj->show_path($file->{name}); result => $dest now cotains "/path/to/basefolder/Life on Mars (US)/" - $dest = $obj->createSeasonFolder($dest,$file->{season}); + $dest = $obj->create_season_folder($dest,$file->{season}); result => $dest now contains "/path/to/basefolder/Life on Mars (US)/Season1/" -=head2 processNewShows +=head2 process_new_shows Arguments: None - $obj->processNewShows(); + $obj->process_new_shows(); - This function requires that $obj->showFolder("/absolute/path") and - $obj->newShowFolder("/absoute/path") have already been called as their paths + This function requires that $obj->show_folder("/absolute/path") and + $obj->new_show_folder("/absoute/path") have already been called as their paths will be used in this function call. This is the main process for batch processing of a folder of show files. @@ -634,7 +630,7 @@ Works on Mac OS and *nix systems. If recursion is enabled it will process any sub folders that it finds from the initial folder. -=head2 importShow +=head2 import_show Arguments: String, String, String The first arguement is the folder where the file is to be moved into @@ -642,12 +638,12 @@ Works on Mac OS and *nix systems. exists. The third argument is the file which is to be moved. - $obj->importShow("/absolute/path/to/destintaion/folder/", + $obj->import_show("/absolute/path/to/destintaion/folder/", "absolute/path/to/source/folder/", "file"); This function does the heavy lifting of actually moving the show file into the determined folder. - This function is called by processNewShows which does the work to + This function is called by process_new_shows which does the work to determine the paths to folder and file. This function could be called on its own after you have verified "folder" @@ -658,7 +654,7 @@ Works on Mac OS and *nix systems. This function then checks the state of $obj->delete to determine if the processed file should be renamed "file.done" or should be removed using - unlink(). Note delete(1) should be called before processNewShows() if you + unlink(). Note delete(1) should be called before process_new_shows() if you wish to delete the processed file. By default the file is only renamed. =head2 delete @@ -688,28 +684,28 @@ Works on Mac OS and *nix systems. $obj->recursion(0) set recursion to false $obj->recursion(1) set recursion to true - This controls the behaviour of processNewShows(); + This controls the behaviour of process_new_shows(); -=head2 seasonFolder +=head2 season_folder Arguments: None,0,1 - $obj->seasonFolder return the current true or false state (1 or 0) - $obj->seasonFolder(0) or seasonFolder(1) sets and returns the new value. - $obj->seasonFolder() returns undef if the input is invalid and the internal + $obj->season_folder return the current true or false state (1 or 0) + $obj->season_folder(0) or season_folder(1) sets and returns the new value. + $obj->season_folder() returns undef if the input is invalid and the internal state is unchanged. - if(!defined $obj->seasonFolder("x")) { + if(!defined $obj->season_folder("x")) { print "You passed and invalid value\n"; } The default is true. -=head2 wereThereErrors +=head2 were_there_errors Arguments: None - $obj->wereThereErrors; + $obj->were_there_errors; This should be called at the end of the program to report if any file names @@ -721,14 +717,14 @@ Works on Mac OS and *nix systems. EG S.W.A.T.2017.SXX should get an entry such as: exceptionList = "S.W.A.T.2017:S.W.A.T 2017"; -=head2 createSeasonFolder +=head2 create_season_folder Arguments: String, Number The first argument is the current folder that the file should be moved to The second argument is the season number. - $obj->createSeasonFolder("/absolute/path/to/show/folder/",$seasonNumber) + $obj->create_season_folder("/absolute/path/to/show/folder/",$seasonNumber) This creates a folder within "/absolute/path/to/show/folder/" by calling make_path() returns the newly created path @@ -754,7 +750,7 @@ Works on Mac OS and *nix systems. of verbose is not changed. Return 0 if verbose mode is off. Return 1 if verbose mode is on. - This state is checked by createSeasonFolder(), importShow() + This state is checked by create_season_folder(), import_show() This allows to system to give some user feedback on what is being done if you want to watch the module working. @@ -771,26 +767,26 @@ Works on Mac OS and *nix systems. my $obj = Video::File::TVShow::Import->new(); - $obj->newShowFolder("/tmp/"); - $obj->showFolder("/absolute/path/to/TV Shows"); + $obj->new_show_folder("/tmp/"); + $obj->show_folder("/absolute/path/to/TV Shows"); - if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) { + if((!defined $obj->new_show_folder()) || (!defined $obj->show_folder())) { print "Verify your paths. Something in wrong\n"; exit; } # Create a hash for matching file name to Folders - $obj->createShowHash(); + $obj->create_show_hash(); # Don't create sub Season folders under the root show name folder. # Instead just dump them all into the root folder - $obj->seasonFolder(0); + $obj->season_folder(0); # Batch process a folder containing TVShow files - $obj->processNewShows(); + $obj->process_new_shows(); # Report any file names which could not be handled automatically. - $obj->wereThereErrors(); + $obj->were_there_errors(); =head2 Process two different source folders. @@ -802,27 +798,27 @@ Works on Mac OS and *nix systems. use Video::File::TVShow::Import; my $obj = Video::File::TVShow::Import->new(); - $obj->newShowFolder("/tmp/"); - $obj->showFolder("/absolute/path/to/TV Shows"); + $obj->new_show_folder("/tmp/"); + $obj->show_folder("/absolute/path/to/TV Shows"); - if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) { + if((!defined $obj->new_show_folder()) || (!defined $obj->show_folder())) { print "Verify your paths. Something in wrong\n"; exit; } # Create a hash for matching file name to Folders - $obj->createShowHash(); + $obj->create_show_hash(); # Batch process first folder containing TVShow files - $obj->newShowFolder("/tmp/"); - $obj->processNewShows(); + $obj->new_show_folder("/tmp/"); + $obj->process_new_shows(); # Batch process second folder containing TVShow files. - $obj->newShowFolder("/tmp2/"); - $obj->processNewShows(); + $obj->new_show_folder("/tmp2/"); + $obj->process_new_shows(); # Report any file names which could not be handled automatically. - $obj->wereThereErrors(); + $obj->were_there_errors(); =head1 INCOMPATIBILITIES diff --git a/t/01TestDirectoryHandling.t b/t/01TestDirectoryHandling.t index 5e09b87..a3753a6 100644 --- a/t/01TestDirectoryHandling.t +++ b/t/01TestDirectoryHandling.t @@ -25,39 +25,39 @@ my $obj = Video::File::TVShow::Import->new(); isa_ok($obj, 'Video::File::TVShow::Import'); subtest "Test Destintaiton Directory handling" => sub { -can_ok ($obj, 'showFolder'); +can_ok ($obj, 'show_folder'); -subtest "Call showFolder with it never being set" => sub { -is ($obj->showFolder, undef, "showFolder was never set and returns undef as required"); +subtest "Call show_folder with it never being set" => sub { +is ($obj->show_folder, undef, "show_folder was never set and returns undef as required"); }; subtest "Pass an invalid path" => sub { -is($obj->showFolder(getcwd . '/TV Shows'), undef, "Passed an invalid path"); +is($obj->show_folder(getcwd . '/TV Shows'), undef, "Passed an invalid path"); }; subtest "Pass a valid path" => sub { -ok($obj->showFolder(getcwd . '/t/TV Shows') =~ m/.*\/TV Shows\/$/, "Passed a valid Path without ending \/ character \/ was appended by funtion"); +ok($obj->show_folder(getcwd . '/t/TV Shows') =~ m/.*\/TV Shows\/$/, "Passed a valid Path without ending \/ character \/ was appended by funtion"); }; -subtest "Pass an invalid path again to showfolder()" => sub { -is($obj->showFolder(getcwd . 't/TV Shows'), undef, "t/TV Shows is not a valid path missing leading /"); +subtest "Pass an invalid path again to show_folder()" => sub { +is($obj->show_folder(getcwd . 't/TV Shows'), undef, "t/TV Shows is not a valid path missing leading /"); }; }; -subtest "Test newShowFolder method" => sub { -can_ok ($obj, 'newShowFolder'); -is ($obj->newShowFolder, undef, "New TV Show download folder is undefined as expected"); +subtest "Test new_show_folder method" => sub { +can_ok ($obj, 'new_show_folder'); +is ($obj->new_show_folder, undef, "New TV Show download folder is undefined as expected"); -subtest "Pass invalid path to newShowFolder()" => sub { -is($obj->newShowFolder(getcwd . 'test-data'), undef, "Passed an invalid path"); +subtest "Pass invalid path to new_show_folder()" => sub { +is($obj->new_show_folder(getcwd . 'test-data'), undef, "Passed an invalid path"); }; -ok($obj->newShowFolder(getcwd . '/t/test-data') =~ m/.*\/$/, "newShowFolder was passed a valid path not ending with \/. but returned path ending in \/"); +ok($obj->new_show_folder(getcwd . '/t/test-data') =~ m/.*\/$/, "new_show_folder was passed a valid path not ending with \/. but returned path ending in \/"); -subtest "Pass an invalid path again to newShowFolder" => sub { -is($obj->newShowFolder(getcwd . 't/test-data'), undef, "t/test-data is not a valid path missing leading /"); +subtest "Pass an invalid path again to new_show_folder" => sub { +is($obj->new_show_folder(getcwd . 't/test-data'), undef, "t/test-data is not a valid path missing leading /"); }; }; diff --git a/t/02TestBaseFunctions.t b/t/02TestBaseFunctions.t index ee67270..63675d0 100644 --- a/t/02TestBaseFunctions.t +++ b/t/02TestBaseFunctions.t @@ -73,14 +73,14 @@ is($obj->recursion("A"), undef, "I was passed an invalid imput returning undef") }; -subtest "Testing seasonFolder function." => sub { -can_ok($obj, 'seasonFolder'); - -is($obj->seasonFolder(),1, "The default is true. (1) We will create season folders under the parent folder."); -is($obj->seasonFolder(0),0 ,"SeasonFolder has been set to False. (0) Show files will not be put into seasons sub folders."); -is($obj->seasonFolder(), 0, "SeasonFolder is still set to False (0)"); -is($obj->seasonFolder(1),1, "SeasonFolder has been set to true (1)"); -is($obj->seasonFolder("A"), undef, "I was passed an invalid arugment. Returning undef") +subtest "Testing season_folder function." => sub { +can_ok($obj, 'season_folder'); + +is($obj->season_folder(),1, "The default is true. (1) We will create season folders under the parent folder."); +is($obj->season_folder(0),0 ,"season_folder has been set to False. (0) Show files will not be put into seasons sub folders."); +is($obj->season_folder(), 0, "season_folder is still set to False (0)"); +is($obj->season_folder(1),1, "season_folder has been set to true (1)"); +is($obj->season_folder("A"), undef, "I was passed an invalid arugment. Returning undef") }; diff --git a/t/04TestShowHashing.t b/t/04TestShowHashing.t index 5bafb65..b4886a1 100644 --- a/t/04TestShowHashing.t +++ b/t/04TestShowHashing.t @@ -21,70 +21,69 @@ my $obj = Video::File::TVShow::Import->new(); my $ShowDirectory = getcwd . '/t/TV Shows'; -subtest "Set showFolder path" => sub { -$obj->showFolder($ShowDirectory); +subtest "Set show_folder path" => sub { +$obj->show_folder($ShowDirectory); -can_ok($obj, 'createShowHash'); +can_ok($obj, 'create_show_hash'); }; -$obj->createShowHash(); +$obj->create_show_hash(); subtest "Long test to check that we can get the correct folder to store Shows in based on the filename" => sub { -can_ok($obj, 'showPath'); +can_ok($obj, 'show_path'); -is ($obj->showPath("Agent X"), "Agent X US", "Agent X returns Agent X US"); -is ($obj->showPath("Agent X US"), "Agent X US", "Agent X US returns Agent X US"); -is ($obj->showPath("Agent X (US)"), "Agent X US", "Agent X (US) returns Agent X US"); +is ($obj->show_path("Agent X"), "Agent X US", "Agent X returns Agent X US"); +is ($obj->show_path("Agent X US"), "Agent X US", "Agent X US returns Agent X US"); +is ($obj->show_path("Agent X (US)"), "Agent X US", "Agent X (US) returns Agent X US"); -is ($obj->showPath("Travelers"), "Travelers (2016)", "Travelers returns Travelers (2016)"); -is ($obj->showPath("Travelers 2016"), "Travelers (2016)", "Travelers 2016 returns Travelers (2016)"); -is ($obj->showPath("Travelers (2016)"), "Travelers (2016)", "Travelers (2016) returns Travelers (2016)"); +is ($obj->show_path("Travelers"), "Travelers (2016)", "Travelers returns Travelers (2016)"); +is ($obj->show_path("Travelers 2016"), "Travelers (2016)", "Travelers 2016 returns Travelers (2016)"); +is ($obj->show_path("Travelers (2016)"), "Travelers (2016)", "Travelers (2016) returns Travelers (2016)"); -is ($obj->showPath("Bull"), "Bull (2016)", "Bull returns Bull (2016)"); -is ($obj->showPath("Bull 2016"), "Bull (2016)", "Bull 2016 returns Bull (2016)"); -is ($obj->showPath("Bull (2016)"), "Bull (2016)", "Bull (2016) returns Bull (2016)"); +is ($obj->show_path("Bull"), "Bull (2016)", "Bull returns Bull (2016)"); +is ($obj->show_path("Bull 2016"), "Bull (2016)", "Bull 2016 returns Bull (2016)"); +is ($obj->show_path("Bull (2016)"), "Bull (2016)", "Bull (2016) returns Bull (2016)"); -is ($obj->showPath("Doctor Who"), "Doctor Who (2005)", "Doctor Who returns Doctor Who (2005)"); -is ($obj->showPath("Doctor Who 2005"), "Doctor Who (2005)", "Doctor Who 2005 returns Doctor Who (2005)"); -is ($obj->showPath("Doctor Who (2005)"), "Doctor Who (2005)", "Doctor Who (2005) returns Doctor Who (2005)" ); +is ($obj->show_path("Doctor Who"), "Doctor Who (2005)", "Doctor Who 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("Doctor Who (2005)"), "Doctor Who (2005)", "Doctor Who (2005) returns Doctor Who (2005)" ); -is ($obj->showPath("S.W.A.T"), "S.W.A.T 2017", "S.W.A.T returns S.W.A.T 2017"); -is ($obj->showPath("S.W.A.T 2017"), "S.W.A.T 2017", "S.W.A.T 2017 returns S.W.A.T 2017"); -is ($obj->showPath("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"), "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"); -is ($obj->showPath("S.W.A.T 2018"), "S.W.A.T 2018", "S.W.A.T 2018 returns S.W.A.T 2018"); +is ($obj->show_path("S.W.A.T 2018"), "S.W.A.T 2018", "S.W.A.T 2018 returns S.W.A.T 2018"); -is ($obj->showPath("The Librarian"), "The Librarian", "The Librarian returns The Librarian"); +is ($obj->show_path("The Librarian"), "The Librarian", "The Librarian returns The Librarian"); -is ($obj->showPath("The Librarians"), "The Librarians US", "The Librarian returns The Librarian US"); -is ($obj->showPath("The Librarians US"), "The Librarians US", "The Librarians US returns The Librarian US"); -is ($obj->showPath("The Librarians (US)"), "The Librarians US", "The Librarians (US) returns The Librarian US"); +is ($obj->show_path("The Librarians"), "The Librarians US", "The Librarian returns The Librarian US"); +is ($obj->show_path("The Librarians US"), "The Librarians US", "The Librarians US returns The Librarian US"); +is ($obj->show_path("The Librarians (US)"), "The Librarians US", "The Librarians (US) returns The Librarian US"); -is ($obj->showPath("The Tomorrow People (1992) - The New Generation"), "The Tomorrow People (1992) - The New Generation", "The Tomorrow People (1992) - The New Generation"); +is ($obj->show_path("The Tomorrow People (1992) - The New Generation"), "The Tomorrow People (1992) - The New Generation", "The Tomorrow People (1992) - The New Generation"); -is ($obj->showPath("The Tomorrow People"), "The Tomorrow People", "The Tomorrow Pople returns The Tomorrow People"); +is ($obj->show_path("The Tomorrow People"), "The Tomorrow People", "The Tomorrow Pople returns The Tomorrow People"); -is ($obj->showPath("The Tomorrow People US"), "The Tomorrow People US", "The Tomorrow People US"); -is ($obj->showPath("The Tomorrow People (US)"), "The Tomorrow People US", "The Tomorrow People (US)"); -isnt ($obj->showPath("The Tomorrow People"), "The Tomorrow People US", "The Tomorrow Poeple doesnt return The Tomorrow People US"); +is ($obj->show_path("The Tomorrow People US"), "The Tomorrow People US", "The Tomorrow People US"); +is ($obj->show_path("The Tomorrow People (US)"), "The Tomorrow People US", "The Tomorrow People (US)"); +isnt ($obj->show_path("The Tomorrow People"), "The Tomorrow People US", "The Tomorrow Poeple doesnt return The Tomorrow People US"); -is ($obj->showPath("bogus"), undef, "If a show Folder does not exist return undef"); +is ($obj->show_path("bogus"), undef, "If a show Folder does not exist return undef"); }; subtest "Test that we can empty the showHash" => sub { - -can_ok($obj, 'clearShowHash'); -$obj->clearShowHash(); + +can_ok($obj, 'clear_show_hash'); +$obj->clear_show_hash(); is($obj->{shows},undef, "Show Hash is empty."); }; subtest "We can reload the showHash" => sub { -$obj->createShowHash(); +$obj->create_show_hash(); ok(keys %{$obj->{shows}} > 0, "showHash contains objects"); }; done_testing(); - diff --git a/t/05TestMainImport.t b/t/05TestMainImport.t index 9a47fe7..4c139d8 100644 --- a/t/05TestMainImport.t +++ b/t/05TestMainImport.t @@ -23,34 +23,34 @@ my $sourceDir = getcwd . '/t/test-data/done_list/'; my $ShowDirectory = getcwd . '/t/TV Shows'; #load paths into obj -$obj->showFolder($ShowDirectory); -$obj->newShowFolder($sourceDir); +$obj->show_folder($ShowDirectory); +$obj->new_show_folder($sourceDir); -$obj->createShowHash(); +$obj->create_show_hash(); subtest "About to process done_list Folder." => sub { -can_ok($obj, 'wereThereErrors'); +can_ok($obj, 'were_there_errors'); is($obj->{UnhandledFileNames}, undef, "No UnhandedFiles have been found"); -can_ok($obj, 'processNewShows'); -$obj->processNewShows(); -can_ok($obj, 'importShow'); +can_ok($obj, 'process_new_shows'); +$obj->process_new_shows(); +can_ok($obj, 'import_show'); }; # Now test Delete folder processing run $obj->delete(1); -$obj->newShowFolder(getcwd . '/t/test-data/delete_list/'); -$obj->processNewShows(); +$obj->new_show_folder(getcwd . '/t/test-data/delete_list/'); +$obj->process_new_shows(); -$obj->seasonFolder(0); -$obj->newShowFolder(getcwd . '/t/test-data/noseason_list/'); -$obj->processNewShows(); +$obj->season_folder(0); +$obj->new_show_folder(getcwd . '/t/test-data/noseason_list/'); +$obj->process_new_shows(); subtest "Check if there were errors" => sub { -$obj->wereThereErrors(); +$obj->were_there_errors(); ok($obj->{UnhandledFileNames} =~ /HASH/, "Unhandled files were found"); }; diff --git a/t/07TestRecursiveImport.t b/t/07TestRecursiveImport.t index 8013266..5f178d6 100644 --- a/t/07TestRecursiveImport.t +++ b/t/07TestRecursiveImport.t @@ -27,14 +27,14 @@ my $sourceDir = getcwd . '/t/test-data/done_list/'; my $ShowDirectory = getcwd . '/t/TV Shows'; #load paths into obj -$obj->showFolder($ShowDirectory); -$obj->newShowFolder($sourceDir); +$obj->show_folder($ShowDirectory); +$obj->new_show_folder($sourceDir); $obj->recursion(1); -$obj->createShowHash(); +$obj->create_show_hash(); -$obj->processNewShows(); +$obj->process_new_shows(); subtest "Testing recursive processing with delete set as false" => sub { $file = getcwd . "/t/test-data/done_list/test/"; @@ -46,8 +46,8 @@ ok(-e $ShowDirectory . "/True Blood/Season1/true.blood.S01E01.avi", "true.blood. # Now test Delete folder processing run $obj->delete(1); -$obj->newShowFolder(getcwd . '/t/test-data/delete_list/'); -$obj->processNewShows(); +$obj->new_show_folder(getcwd . '/t/test-data/delete_list/'); +$obj->process_new_shows(); subtest "Testing recursive processing with delete set as true" => sub { $file = getcwd . "/test-data/delete_list/test/"; From 68f4541237cafce0e679d5b0e8b6430f52c41bc8 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 4 Mar 2019 23:05:34 +0900 Subject: [PATCH 03/11] Removed comment to move to snake_case --- lib/Video/File/TVShow/Import.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Video/File/TVShow/Import.pm b/lib/Video/File/TVShow/Import.pm index 3eaa7ef..7d97e0e 100644 --- a/lib/Video/File/TVShow/Import.pm +++ b/lib/Video/File/TVShow/Import.pm @@ -59,9 +59,6 @@ sub countries { return $self->{countries}; } -# it's your call, but in Perl-land the usual convention is to use -# snakecase instead of camel case for functions and methods. -# E.g., here I'd expect to have 'show_folder' sub show_folder { # Set and get path for where new shows are to be stored in the file system my ($self, $path) = @_; From f1f71ed26430512e403ea234e17abc8572ebb5e4 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 4 Mar 2019 23:15:49 +0900 Subject: [PATCH 04/11] update to Changes and README Added changes log for snake_case migration and also updated the readme sample code to show snake_case function calls. --- Changes | 3 ++- README | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index 309481f..6c7018d 100644 --- a/Changes +++ b/Changes @@ -30,4 +30,5 @@ Revision history for Perl extension Video::File::TVShow::Import. - Added the Carp Module to the list of required modules. Its been in use for a while. - Removed exceptionList as a global variable. We now pass a named variable - to new() + to new() + - Migrated to snake_case in order to fit normal perl coding style. diff --git a/README b/README index c36a6df..012f251 100644 --- a/README +++ b/README @@ -31,16 +31,16 @@ Example Usage: Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Other:other' } ); - $obj->newShowFolder("/tmp/"); - $obj->showFolder("/absolute/path/to/TV Shows"); + $obj->new_show_folder("/tmp/"); + $obj->show_folder("/absolute/path/to/TV Shows"); - if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) { + if((!defined $obj->new_show_folder()) || (!defined $obj->show_folder())) { print "Verify your paths. Something in wrong\n"; exit; } # Create a hash for matching file name to Folders - $obj->createShowHash(); + $obj->create_show_hash(); # Delete files after processing. The default is to rename the files by appending ".done" @@ -49,13 +49,13 @@ Example Usage: # Do not create sub folders under the the show's parent folder. All files should be dumped # into the parent folder. The default is to create season folders. - $obj->seasonFolder(0); + $obj->season_folder(0); # Batch process a folder containing TV Show files - $obj->processNewShows(); + $obj->process_new_shows(); # Report any file names which could not be handled automatically. - $obj->wereThereErrors(); + $obj->were_there_errors(); #end of program From ef47b137c4c9b6559d47d2155cdda44037182049 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 4 Mar 2019 23:31:31 +0900 Subject: [PATCH 05/11] Simple typo fix in Changes file --- Changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changes b/Changes index 6c7018d..2f0ffee 100644 --- a/Changes +++ b/Changes @@ -11,7 +11,7 @@ Revision history for Perl extension Video::File::TVShow::Import. seasonFolder() 0.25 Friday May 11th 2018 - - Documentaion update. No Changes to the code base implemented + - Documentation update. No Changes to the code base implemented - Also need to remember to update this file when changes are actually made to the version releases :) From a2f6e6b46e4323c761999bf8947a3ce36dadd53d Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 11 Mar 2019 23:06:33 +0900 Subject: [PATCH 06/11] Renamed Module Import and import_* methods Import changed to Organize import_* changed to move_* --- lib/Video/File/TVShow/Import.pm | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/Video/File/TVShow/Import.pm b/lib/Video/File/TVShow/Import.pm index 7d97e0e..c0fcc8f 100644 --- a/lib/Video/File/TVShow/Import.pm +++ b/lib/Video/File/TVShow/Import.pm @@ -1,4 +1,4 @@ -package Video::File::TVShow::Import; +package Video::File::TVShow::Organize; use 5.012004; use strict; @@ -77,7 +77,7 @@ sub show_folder { } sub new_show_folder { - # Set and get path to find new files to be imported from live + # Set and get path to find new files to be moved from live my ($self, $path) = @_; if (defined $path) { if ((-e $path) and (-d $path)) { @@ -206,8 +206,8 @@ sub process_new_shows { $destination = $self->create_season_folder($destination, $showData->{season}); }; # Import the file. This will use rsync to copy the file into place and either rename or delete. - # see import_show() for implementation details - $self->import_show($destination, $curr_dir, $file); + # see move_show() for implementation details + $self->move_show($destination, $curr_dir, $file); } close(DIR); return; @@ -341,7 +341,7 @@ sub create_season_folder { } -sub import_show { +sub move_show { my ($self, $destination, $source, $file) = @_; @@ -406,16 +406,16 @@ __END__ =head1 NAME -Video::File::TVShow::Import - Perl module to move TVShow Files into their +Video::File::TVShow::Organize - Perl module to move TVShow Files into their matching Show Folder on a media server. =head1 SYNOPSIS - use Video::File::TVShow::Import; + use Video::File::TVShow::Organize; our $exceptionList = "S.W.A.T.2017:S.W.A.T 2017|Other:other"; - my $obj = Video::File::TVShow::Import->new(); + my $obj = Video::File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); @@ -479,12 +479,12 @@ Works on Mac OS and *nix systems. Arguments: None or { Exeptions => 'MatchCase:DesiredValue'} - $obj = Video::File::TVShow::Import->new(); + $obj = Video::File::TVShow::Organize->new(); - $obj = Video::File::TVShow::Import->new({ Exceptions => + $obj = Video::File::TVShow::Organize->new({ Exceptions => 'MatchCase:DesiredValue' }) - This subroutine creates a new object of type Video::File::TVShow::Import + This subroutine creates a new object of type Video::File::TVShow::Organize If Exceptions is passed to the method we load this data into a hash for later use to handle naming complications. @@ -575,7 +575,7 @@ Works on Mac OS and *nix systems. key: life on mars us => folder: Life on Mars (US) As such file naming relating to country of origin is important if you are - importing versions of the same show based on country. + moving versions of the same show based on country. =head2 clear_show_hash @@ -627,7 +627,7 @@ Works on Mac OS and *nix systems. If recursion is enabled it will process any sub folders that it finds from the initial folder. -=head2 import_show +=head2 move_show Arguments: String, String, String The first arguement is the folder where the file is to be moved into @@ -635,7 +635,7 @@ Works on Mac OS and *nix systems. exists. The third argument is the file which is to be moved. - $obj->import_show("/absolute/path/to/destintaion/folder/", + $obj->move_show("/absolute/path/to/destintaion/folder/", "absolute/path/to/source/folder/", "file"); This function does the heavy lifting of actually moving the show file into @@ -664,7 +664,7 @@ Works on Mac OS and *nix systems. Input should be 0 or 1. 0 being do not delete. 1 being delete. - Set if we should delete source file after successfully importing it to the tv + Set if we should delete source file after successfully moving it to the tv store or if we should rename it to $file.done @@ -747,7 +747,7 @@ Works on Mac OS and *nix systems. of verbose is not changed. Return 0 if verbose mode is off. Return 1 if verbose mode is on. - This state is checked by create_season_folder(), import_show() + This state is checked by create_season_folder(), move_show() This allows to system to give some user feedback on what is being done if you want to watch the module working. @@ -760,9 +760,9 @@ Works on Mac OS and *nix systems. use strict; use warnings; - use Video::File::TVShow::Import; + use Video::File::TVShow::Organize; - my $obj = Video::File::TVShow::Import->new(); + my $obj = Video::File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); @@ -792,8 +792,8 @@ Works on Mac OS and *nix systems. use strict; use warnings; - use Video::File::TVShow::Import; - my $obj = Video::File::TVShow::Import->new(); + use Video::File::TVShow::Organize; + my $obj = Video::File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); From 3185edee3ca123f6d382ad2415fdc6a61e7ff050 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 11 Mar 2019 23:08:04 +0900 Subject: [PATCH 07/11] Updated README with changes to Organize --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 012f251..663f054 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ -Video-File-TVShow-Import version 0.31 +Video-File-TVShow-Organize version 0.31 ============================ -This module makes it easier to import TV Show files into the correct Show +This module makes it easier to move TV Show files into the correct Show folder and also place them in to the correct season or specials folder. This may be of use if you have a large media server which you are trying to keep organised. @@ -25,9 +25,9 @@ Example Usage: use strict; use warnings; - use Video::File::TVShow::Import; + use Video::File::TVShow::Organize; - my $obj = Video::File::TVShow::Import->new( { + my $obj = Video::File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Other:other' } ); From 9398b0eaf86e537d04b15d7388b7c1e665510a27 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 11 Mar 2019 23:11:34 +0900 Subject: [PATCH 08/11] Changes to move from Import to Organize --- Changes | 2 ++ Examples/basic.pl | 4 ++-- Examples/myPersonalCode.pl | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 2f0ffee..1735f18 100644 --- a/Changes +++ b/Changes @@ -32,3 +32,5 @@ Revision history for Perl extension Video::File::TVShow::Import. - Removed exceptionList as a global variable. We now pass a named variable to new() - Migrated to snake_case in order to fit normal perl coding style. + - Changed Import to Organize + - Changed import_* to move_* for methods. diff --git a/Examples/basic.pl b/Examples/basic.pl index bf3b08a..d28d23f 100644 --- a/Examples/basic.pl +++ b/Examples/basic.pl @@ -3,9 +3,9 @@ use strict; use warnings; - use Video::File::TVShow::Import; + use Video::File::TVShow::Organize; - my $obj = Video::File::TVShow::Import->new({ + my $obj = Video::File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); diff --git a/Examples/myPersonalCode.pl b/Examples/myPersonalCode.pl index 6bce45b..bd26f06 100644 --- a/Examples/myPersonalCode.pl +++ b/Examples/myPersonalCode.pl @@ -2,7 +2,7 @@ # This is used during development to confirm code works in my local environment. # before I do a make install for the module. -#use lib "/Users/aspann/dev/BAS-TVShow-Import/lib/"; +#use lib "/Users/aspann/dev/BAS-TVShow-Organize/lib/"; # Note I do not personally do any case testing as I have been using this code # for some time and am very familiar with its operation. @@ -10,9 +10,9 @@ use strict; use warnings; -use Video::File::TVShow::Import; +use Video::File::TVShow::Organize; -my $obj = Video::File::TVShow::Import->new({ +my $obj = Video::File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); From 5ee9293313383f73096d2b88a82dff048685639a Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 11 Mar 2019 23:18:50 +0900 Subject: [PATCH 09/11] Additional changes to move from Import to Organize Test files, README and other documenation --- MANIFEST | 2 +- Makefile.PL | 8 ++++---- lib/Video/File/TVShow/{Import.pm => Organize.pm} | 0 t/01TestDirectoryHandling.t | 6 +++--- t/02TestBaseFunctions.t | 10 +++++----- t/03TestFileNameHandling | 7 +++---- t/04TestShowHashing.t | 6 +++--- t/05TestMainImport.t | 8 ++++---- t/07TestRecursiveImport.t | 6 +++--- 9 files changed, 26 insertions(+), 27 deletions(-) rename lib/Video/File/TVShow/{Import.pm => Organize.pm} (100%) diff --git a/MANIFEST b/MANIFEST index ca73368..a95f35c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -13,4 +13,4 @@ t/07TestRecursiveImport.t t/10Clean.t t/test-data.tar.gz t/tv-shows.tar.gz -lib/Video/File/TVShow/Import.pm +lib/Video/File/TVShow/Organize.pm diff --git a/Makefile.PL b/Makefile.PL index fa01dde..667fbdf 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,14 +3,14 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( - NAME => 'Video::File::TVShow::Import', - VERSION_FROM => 'lib/Video/File/TVShow/Import.pm', # finds $VERSION + NAME => 'Video::File::TVShow::Organize', + VERSION_FROM => 'lib/Video/File/TVShow/Organize.pm', # finds $VERSION PREREQ_PM => { 'Video::Filename' => 0, - 'File::Path' => 0, + 'File::Path' => 0, 'File::Copy' => 0, 'Test::Carp' => 0, 'Carp' => 0 }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 - (ABSTRACT_FROM => 'lib/Video/File/TVShow/Import.pm', # retrieve abstract from module + (ABSTRACT_FROM => 'lib/Video/File/TVShow/Organize.pm', # retrieve abstract from module AUTHOR => 'Adam Spann ') : ()), ) diff --git a/lib/Video/File/TVShow/Import.pm b/lib/Video/File/TVShow/Organize.pm similarity index 100% rename from lib/Video/File/TVShow/Import.pm rename to lib/Video/File/TVShow/Organize.pm diff --git a/t/01TestDirectoryHandling.t b/t/01TestDirectoryHandling.t index a3753a6..e60f33c 100644 --- a/t/01TestDirectoryHandling.t +++ b/t/01TestDirectoryHandling.t @@ -10,7 +10,7 @@ use Data::Dumper; use Test::More; use Test::Carp; use lib '../lib/'; -BEGIN { use_ok('Video::File::TVShow::Import') }; +BEGIN { use_ok('Video::File::TVShow::Organize') }; BEGIN { use_ok('Video::Filename') }; BEGIN { use_ok('File::Path')}; BEGIN { use_ok('File::Copy')}; @@ -21,8 +21,8 @@ BEGIN { use_ok('Cwd')}; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Import->new(); -isa_ok($obj, 'Video::File::TVShow::Import'); +my $obj = Video::File::TVShow::Organize->new(); +isa_ok($obj, 'Video::File::TVShow::Organize'); subtest "Test Destintaiton Directory handling" => sub { can_ok ($obj, 'show_folder'); diff --git a/t/02TestBaseFunctions.t b/t/02TestBaseFunctions.t index 63675d0..7e6fac2 100644 --- a/t/02TestBaseFunctions.t +++ b/t/02TestBaseFunctions.t @@ -9,7 +9,7 @@ use Data::Dumper; use Test::More; use Test::Carp; -BEGIN { use_ok('Video::File::TVShow::Import') }; +BEGIN { use_ok('Video::File::TVShow::Organize') }; BEGIN { use_ok('Video::Filename') }; BEGIN { use_ok('File::Path')}; BEGIN { use_ok('File::Copy')}; @@ -20,8 +20,8 @@ BEGIN { use_ok('Cwd')}; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Import->new(); -isa_ok($obj, 'Video::File::TVShow::Import'); +my $obj = Video::File::TVShow::Organize->new(); +isa_ok($obj, 'Video::File::TVShow::Organize'); subtest 'Test Default Countries value' => sub { @@ -35,7 +35,7 @@ subtest "Test Exception List case" => sub { ok(!defined $obj->{_exceptionList}, "Global variable: exceptionList is not defined"); $obj = undef; -$obj = Video::File::TVShow::Import->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Test.2018:Test 2018' } ); +$obj = Video::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($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"); @@ -43,7 +43,7 @@ ok($obj->{_exceptionList}{'Test.2018'} =~ m/Test 2018/, "Test.2018 gives Test 20 }; $obj = undef; -$obj = Video::File::TVShow::Import->new(); +$obj = Video::File::TVShow::Organize->new(); subtest 'Testing if we should delete or rename processed files' => sub { can_ok ($obj, 'delete'); diff --git a/t/03TestFileNameHandling b/t/03TestFileNameHandling index d4cad99..092d28a 100644 --- a/t/03TestFileNameHandling +++ b/t/03TestFileNameHandling @@ -10,7 +10,7 @@ use Data::Dumper; use Test::More tests => 0; use Test::Carp; use lib '../lib/'; -use Video::File::TVShow::Import; +use Video::File::TVShow::Organize; use Cwd; ######################### @@ -20,10 +20,9 @@ use Cwd; our $exceptionList = "S.W.A.T.2017:S.W.A.T 2017"; -my $obj = Video::File::TVShow::Import->new(); +my $obj = Video::File::TVShow::Organize->new(); -#ok($obj->_handleExceptionsDatedFileNames("S.W.A.T.2017") =~ m/S.W.A.T 2017/, "Returned S.W.A.T 2017"); +#ok($obj->_handleExceptionsDatedFileNames("S.W.A.T.2017") =~ m/S.W.A.T 2017/, "Returned S.W.A.T 2017"); #testing done_testing(); - diff --git a/t/04TestShowHashing.t b/t/04TestShowHashing.t index b4886a1..4fbb371 100644 --- a/t/04TestShowHashing.t +++ b/t/04TestShowHashing.t @@ -1,5 +1,5 @@ # Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl BAS-TVShow-Import.t' +# `make test'. After `make install' it should work as `perl BAS-TVShow-Organize.t' ######################### @@ -10,14 +10,14 @@ use Data::Dumper; use Test::More; use Test::Carp; use Cwd; -BEGIN {use_ok( 'Video::File::TVShow::Import' ) }; +BEGIN {use_ok( 'Video::File::TVShow::Organize' ) }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Import->new(); +my $obj = Video::File::TVShow::Organize->new(); my $ShowDirectory = getcwd . '/t/TV Shows'; diff --git a/t/05TestMainImport.t b/t/05TestMainImport.t index 4c139d8..55c60ef 100644 --- a/t/05TestMainImport.t +++ b/t/05TestMainImport.t @@ -1,5 +1,5 @@ # Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl 05MainTestImport.t' +# `make test'. After `make install' it should work as `perl 05MainTestOrganize.t' ######################### @@ -8,7 +8,7 @@ use warnings; use Data::Dumper; use Test::More; #tests => 6; use Test::Carp; -BEGIN { use_ok( 'Video::File::TVShow::Import' ) }; +BEGIN { use_ok( 'Video::File::TVShow::Organize' ) }; use Cwd; ######################### @@ -16,7 +16,7 @@ use Cwd; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Import->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' } ); +my $obj = Video::File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' } ); # Setup folder paths. my $sourceDir = getcwd . '/t/test-data/done_list/'; @@ -34,7 +34,7 @@ is($obj->{UnhandledFileNames}, undef, "No UnhandedFiles have been found"); can_ok($obj, 'process_new_shows'); $obj->process_new_shows(); -can_ok($obj, 'import_show'); +can_ok($obj, 'move_show'); }; diff --git a/t/07TestRecursiveImport.t b/t/07TestRecursiveImport.t index 5f178d6..5d4c058 100644 --- a/t/07TestRecursiveImport.t +++ b/t/07TestRecursiveImport.t @@ -1,5 +1,5 @@ # Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl 05MainTestImport.t' +# `make test'. After `make install' it should work as `perl 05MainTestOrganize.t' ######################### @@ -8,7 +8,7 @@ use warnings; use Data::Dumper; use Test::More; #tests => 6; use Test::Carp; -BEGIN { use_ok( 'Video::File::TVShow::Import' ) }; +BEGIN { use_ok( 'Video::File::TVShow::Organize' ) }; use Cwd; ######################### @@ -20,7 +20,7 @@ my $file; my $outputPath; my $inputPath = "t/test-data/"; -my $obj = Video::File::TVShow::Import->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); +my $obj = Video::File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); # Setup folder paths. my $sourceDir = getcwd . '/t/test-data/done_list/'; From 6a7dd4d6ed23842dad785ecc7e8a2e23feed563b Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Mon, 11 Mar 2019 23:40:10 +0900 Subject: [PATCH 10/11] Move from Video::File to just File:: --- Examples/basic.pl | 4 ++-- Examples/myPersonalCode.pl | 4 ++-- MANIFEST | 2 +- Makefile.PL | 6 +++--- README | 6 +++--- lib/{Video => }/File/TVShow/Organize.pm | 22 +++++++++++----------- t/01TestDirectoryHandling.t | 6 +++--- t/02TestBaseFunctions.t | 10 +++++----- t/03TestFileNameHandling | 4 ++-- t/04TestShowHashing.t | 4 ++-- t/05TestMainImport.t | 4 ++-- t/07TestRecursiveImport.t | 4 ++-- 12 files changed, 38 insertions(+), 38 deletions(-) rename lib/{Video => }/File/TVShow/Organize.pm (97%) diff --git a/Examples/basic.pl b/Examples/basic.pl index d28d23f..6b05119 100644 --- a/Examples/basic.pl +++ b/Examples/basic.pl @@ -3,9 +3,9 @@ use strict; use warnings; - use Video::File::TVShow::Organize; + use File::TVShow::Organize; - my $obj = Video::File::TVShow::Organize->new({ + my $obj = File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); diff --git a/Examples/myPersonalCode.pl b/Examples/myPersonalCode.pl index bd26f06..c8b8e44 100644 --- a/Examples/myPersonalCode.pl +++ b/Examples/myPersonalCode.pl @@ -10,9 +10,9 @@ use strict; use warnings; -use Video::File::TVShow::Organize; +use File::TVShow::Organize; -my $obj = Video::File::TVShow::Organize->new({ +my $obj = File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); diff --git a/MANIFEST b/MANIFEST index a95f35c..2ccf0cd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -13,4 +13,4 @@ t/07TestRecursiveImport.t t/10Clean.t t/test-data.tar.gz t/tv-shows.tar.gz -lib/Video/File/TVShow/Organize.pm +lib/File/TVShow/Organize.pm diff --git a/Makefile.PL b/Makefile.PL index 667fbdf..e25d93b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,14 +3,14 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( - NAME => 'Video::File::TVShow::Organize', - VERSION_FROM => 'lib/Video/File/TVShow/Organize.pm', # finds $VERSION + NAME => 'File::TVShow::Organize', + VERSION_FROM => 'lib/File/TVShow/Organize.pm', # finds $VERSION PREREQ_PM => { 'Video::Filename' => 0, 'File::Path' => 0, 'File::Copy' => 0, 'Test::Carp' => 0, 'Carp' => 0 }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 - (ABSTRACT_FROM => 'lib/Video/File/TVShow/Organize.pm', # retrieve abstract from module + (ABSTRACT_FROM => 'lib/File/TVShow/Organize.pm', # retrieve abstract from module AUTHOR => 'Adam Spann ') : ()), ) diff --git a/README b/README index 663f054..3fabf88 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Video-File-TVShow-Organize version 0.31 +File-TVShow-Organize version 0.31 ============================ This module makes it easier to move TV Show files into the correct Show @@ -25,9 +25,9 @@ Example Usage: use strict; use warnings; - use Video::File::TVShow::Organize; + use File::TVShow::Organize; - my $obj = Video::File::TVShow::Organize->new( { + my $obj = File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Other:other' } ); diff --git a/lib/Video/File/TVShow/Organize.pm b/lib/File/TVShow/Organize.pm similarity index 97% rename from lib/Video/File/TVShow/Organize.pm rename to lib/File/TVShow/Organize.pm index c0fcc8f..4ca4034 100644 --- a/lib/Video/File/TVShow/Organize.pm +++ b/lib/File/TVShow/Organize.pm @@ -1,4 +1,4 @@ -package Video::File::TVShow::Organize; +package File::TVShow::Organize; use 5.012004; use strict; @@ -406,16 +406,16 @@ __END__ =head1 NAME -Video::File::TVShow::Organize - Perl module to move TVShow Files into their +File::TVShow::Organize - Perl module to move TVShow Files into their matching Show Folder on a media server. =head1 SYNOPSIS - use Video::File::TVShow::Organize; + use File::TVShow::Organize; our $exceptionList = "S.W.A.T.2017:S.W.A.T 2017|Other:other"; - my $obj = Video::File::TVShow::Organize->new(); + my $obj = File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); @@ -479,12 +479,12 @@ Works on Mac OS and *nix systems. Arguments: None or { Exeptions => 'MatchCase:DesiredValue'} - $obj = Video::File::TVShow::Organize->new(); + $obj = File::TVShow::Organize->new(); - $obj = Video::File::TVShow::Organize->new({ Exceptions => + $obj = File::TVShow::Organize->new({ Exceptions => 'MatchCase:DesiredValue' }) - This subroutine creates a new object of type Video::File::TVShow::Organize + This subroutine creates a new object of type File::TVShow::Organize If Exceptions is passed to the method we load this data into a hash for later use to handle naming complications. @@ -760,9 +760,9 @@ Works on Mac OS and *nix systems. use strict; use warnings; - use Video::File::TVShow::Organize; + use File::TVShow::Organize; - my $obj = Video::File::TVShow::Organize->new(); + my $obj = File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); @@ -792,8 +792,8 @@ Works on Mac OS and *nix systems. use strict; use warnings; - use Video::File::TVShow::Organize; - my $obj = Video::File::TVShow::Organize->new(); + use File::TVShow::Organize; + my $obj = File::TVShow::Organize->new(); $obj->new_show_folder("/tmp/"); $obj->show_folder("/absolute/path/to/TV Shows"); diff --git a/t/01TestDirectoryHandling.t b/t/01TestDirectoryHandling.t index e60f33c..fb75bc1 100644 --- a/t/01TestDirectoryHandling.t +++ b/t/01TestDirectoryHandling.t @@ -10,7 +10,7 @@ use Data::Dumper; use Test::More; use Test::Carp; use lib '../lib/'; -BEGIN { use_ok('Video::File::TVShow::Organize') }; +BEGIN { use_ok('File::TVShow::Organize') }; BEGIN { use_ok('Video::Filename') }; BEGIN { use_ok('File::Path')}; BEGIN { use_ok('File::Copy')}; @@ -21,8 +21,8 @@ BEGIN { use_ok('Cwd')}; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Organize->new(); -isa_ok($obj, 'Video::File::TVShow::Organize'); +my $obj = File::TVShow::Organize->new(); +isa_ok($obj, 'File::TVShow::Organize'); subtest "Test Destintaiton Directory handling" => sub { can_ok ($obj, 'show_folder'); diff --git a/t/02TestBaseFunctions.t b/t/02TestBaseFunctions.t index 7e6fac2..5aad40d 100644 --- a/t/02TestBaseFunctions.t +++ b/t/02TestBaseFunctions.t @@ -9,7 +9,7 @@ use Data::Dumper; use Test::More; use Test::Carp; -BEGIN { use_ok('Video::File::TVShow::Organize') }; +BEGIN { use_ok('File::TVShow::Organize') }; BEGIN { use_ok('Video::Filename') }; BEGIN { use_ok('File::Path')}; BEGIN { use_ok('File::Copy')}; @@ -20,8 +20,8 @@ BEGIN { use_ok('Cwd')}; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Organize->new(); -isa_ok($obj, 'Video::File::TVShow::Organize'); +my $obj = File::TVShow::Organize->new(); +isa_ok($obj, 'File::TVShow::Organize'); subtest 'Test Default Countries value' => sub { @@ -35,7 +35,7 @@ subtest "Test Exception List case" => sub { ok(!defined $obj->{_exceptionList}, "Global variable: exceptionList is not defined"); $obj = undef; -$obj = Video::File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017|Test.2018:Test 2018' } ); +$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($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"); @@ -43,7 +43,7 @@ ok($obj->{_exceptionList}{'Test.2018'} =~ m/Test 2018/, "Test.2018 gives Test 20 }; $obj = undef; -$obj = Video::File::TVShow::Organize->new(); +$obj = File::TVShow::Organize->new(); subtest 'Testing if we should delete or rename processed files' => sub { can_ok ($obj, 'delete'); diff --git a/t/03TestFileNameHandling b/t/03TestFileNameHandling index 092d28a..d4c6b46 100644 --- a/t/03TestFileNameHandling +++ b/t/03TestFileNameHandling @@ -10,7 +10,7 @@ use Data::Dumper; use Test::More tests => 0; use Test::Carp; use lib '../lib/'; -use Video::File::TVShow::Organize; +use File:::Organize; use Cwd; ######################### @@ -20,7 +20,7 @@ use Cwd; our $exceptionList = "S.W.A.T.2017:S.W.A.T 2017"; -my $obj = Video::File::TVShow::Organize->new(); +my $obj = File::TVShow::Organize->new(); #ok($obj->_handleExceptionsDatedFileNames("S.W.A.T.2017") =~ m/S.W.A.T 2017/, "Returned S.W.A.T 2017"); diff --git a/t/04TestShowHashing.t b/t/04TestShowHashing.t index 4fbb371..8725f58 100644 --- a/t/04TestShowHashing.t +++ b/t/04TestShowHashing.t @@ -10,14 +10,14 @@ use Data::Dumper; use Test::More; use Test::Carp; use Cwd; -BEGIN {use_ok( 'Video::File::TVShow::Organize' ) }; +BEGIN {use_ok( 'File::TVShow::Organize' ) }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Organize->new(); +my $obj = File::TVShow::Organize->new(); my $ShowDirectory = getcwd . '/t/TV Shows'; diff --git a/t/05TestMainImport.t b/t/05TestMainImport.t index 55c60ef..3f3ef1a 100644 --- a/t/05TestMainImport.t +++ b/t/05TestMainImport.t @@ -8,7 +8,7 @@ use warnings; use Data::Dumper; use Test::More; #tests => 6; use Test::Carp; -BEGIN { use_ok( 'Video::File::TVShow::Organize' ) }; +BEGIN { use_ok( 'File::TVShow::Organize' ) }; use Cwd; ######################### @@ -16,7 +16,7 @@ use Cwd; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $obj = Video::File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' } ); +my $obj = File::TVShow::Organize->new( { Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' } ); # Setup folder paths. my $sourceDir = getcwd . '/t/test-data/done_list/'; diff --git a/t/07TestRecursiveImport.t b/t/07TestRecursiveImport.t index 5d4c058..587d9e7 100644 --- a/t/07TestRecursiveImport.t +++ b/t/07TestRecursiveImport.t @@ -8,7 +8,7 @@ use warnings; use Data::Dumper; use Test::More; #tests => 6; use Test::Carp; -BEGIN { use_ok( 'Video::File::TVShow::Organize' ) }; +BEGIN { use_ok( 'File::TVShow::Organize' ) }; use Cwd; ######################### @@ -20,7 +20,7 @@ my $file; my $outputPath; my $inputPath = "t/test-data/"; -my $obj = Video::File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); +my $obj = File::TVShow::Organize->new({ Exceptions => 'S.W.A.T.2017:S.W.A.T 2017' }); # Setup folder paths. my $sourceDir = getcwd . '/t/test-data/done_list/'; From 56566211e69200d873196d4411707aa9ad014076 Mon Sep 17 00:00:00 2001 From: Adam Spann Date: Tue, 12 Mar 2019 07:16:07 +0900 Subject: [PATCH 11/11] Updated Changes file. to reflect naming changes --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index 1735f18..3cfe63c 100644 --- a/Changes +++ b/Changes @@ -34,3 +34,4 @@ Revision history for Perl extension Video::File::TVShow::Import. - Migrated to snake_case in order to fit normal perl coding style. - Changed Import to Organize - Changed import_* to move_* for methods. + - Dropped Video:: from the module naming. It now more simply File::TVShow::*