PrePAN

Sign in to PrePAN

Video-File-TVShow-Import Video file migration module to handle TV Shows.

Good

Synopsis

#!/bin/perl

  use strict;
  use warnings;

  use Video::File::TVShow::Import;

  our $excpetionList = "S.W.A.T.2017:S.W.A.T 2017";

  my $obj = Video::File::TVShow::Import->new();

  $obj->newShowFolder("/tmp/");
  $obj->showsFolder("/absolute/path/to/TV Shows");

  if((!defined $obj->newShowFolder()) || (!defined $obj->showFolder())) {
    print "Verify your paths. Something in wrong\n";
    exit;
  }

  # Create a hash for matching file name to Folders
  $obj->createShowHash();

  # 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);

  # Batch process a folder containing TV Show files
  $obj->processNewShows();

  # Report any file names which could not be handled automatically.
  $obj->wereThereErrors();

  #end of program

Description

I wrote this module in order for me automate my personal Video library rip and import work flow.

The idea being that dvds would be ripped into a staging folder. The files would be named according to Season and Episode format. The resulting file would then be moved into the correct show/season folder automatically. This is done as a cron job.

The module's role is to allow someone to create their own programs to to carry out these actions. Taking care of details such as matching show name to destination folder, create the required season folder if it does not exist and calling rsync to migrate the video file to its new home.

Comments

This looks pretty neat. To make things a bit more OO, I might suggest removing the `$::exceptionList` global variable and instead passing that in to the `new()` method. I'd also remove the `Exporter` / `@EXPORT` stuff, as object classes shouldn't also export subs (and you're not doing any exporting).

You do a lot of reading from directories. It might be less code / easier to use the Path::Tiny module for that.

I also have a bunch of scripts that help me organize my media library. You may find something useful there: https://github.com/preaction/Curator
Thanks. I will take a look at those ideas. I wasn't sure how I wanted to handle the exception list. But you have a good point about moving away from the global. It was a quick fix that as usual becomes a fixture.
I am also looking for some feedback on if the current module name makes sense or if TVShow::Import should be replaced with something better. I feel comfortable with the prefix Video::File

Please sign up to post a review.