Don't import files if they don't have the supportted format extension,
[catagits/App-IdiotBox.git] / lib / App / IdiotBox / Importer.pm
index 030de6e..a19451c 100644 (file)
@@ -2,12 +2,15 @@ package App::IdiotBox::Importer;
 
 use strict;
 use warnings FATAL => 'all';
+use App::IdiotBox::Common qw(@SupportedFormats);
 use Cwd;
 use IO::All;
 use ExtUtils::MakeMaker qw(prompt);
 use File::Spec::Functions qw(catfile catdir);
 use POSIX qw(strftime);
 
+my $supported_formats_re = join('|', @SupportedFormats);
+
 sub log_info (&) { print $_[0]->(), "\n"; }
 
 sub run {
@@ -101,7 +104,7 @@ sub video_files_from_dir {
   my ($class, $dir) = @_;
   my %videos;
   foreach my $file (io($dir)->all_files) {
-    $file->filename =~ /^([^\.]+)\.([^\.]+)$/ or next;
+    $file->filename =~ /^([^\.]+)\.($supported_formats_re)$/ or next;
     push(@{$videos{$1}||=[]}, $2);
   }
   \%videos;