Adding support for video file sizes
[catagits/App-IdiotBox.git] / lib / App / IdiotBox / Importer.pm
index b7ba153..b261174 100644 (file)
@@ -8,6 +8,8 @@ use ExtUtils::MakeMaker qw(prompt);
 use File::Spec::Functions qw(catfile catdir);
 use POSIX qw(strftime);
 
+use Utils::PresentingPerl;
+
 sub log_info (&) { print $_[0]->(), "\n"; }
 
 sub run {
@@ -74,9 +76,12 @@ sub run {
         $info->{author} = $choice;
       }
     }
+    my $size = get_file_size($video_file . '.' .  $video_files->{$video_file}[0]);
     $info->{name} = prompt('What is the name of this talk?', $info->{name});
     (my $slug = lc $info->{name}) =~ s/ /-/g;
     $info->{slug} = prompt('What is the slug for this talk?', $slug);
+    $info->{width} = prompt('What is the width of the video resolution?', $size->{width});
+    $info->{height} = prompt('What is the height of the video resolution?', $size->{height});
     $info->{bucket} = $bucket;
     $info->{announcement} = $ann;
     $videos{$video_file} = bless($info, 'App::IdiotBox::Video');
@@ -106,4 +111,17 @@ sub video_files_from_dir {
   \%videos;
 }
 
+sub get_video_size {
+    my ($filename) = @_;
+
+    my $size = {};
+    if($filename =~ /\.flv$/) {
+        eval { $size = Utils::PresentingPerl::get_flv_info($filename, [qw/width height/]);};
+        if($@) {
+            print "Looking for $filename size, failed, returning 0s\n";
+            return { width => 0, height => 0 };
+        }
+    }
+}
+
 1;