my $filename = lc($title);
$filename =~ s/[\s_-]+/_/;
-use Data::Dumper;
-
my @titles;
for my $title_bit ($result =~ /\n(\+ title \d+:.+?)(?=\n\+ title\s+|$)/gs) {
my %title;
$title{num} = $1;
my ($duration) = $title_bit =~ /^\s+\+\s+duration:\s+([\d:]+)$/m;
# HH:MM:SS, so (HH*60 + MM) * 60 + SS
- $duration = reduce {$a * 60 + $b } split /:/, $duration;
+ $duration = reduce {defined $a and defined $b ? $a * 60 + $b : undef } split /:/, $duration;
$title{duration} = $duration;
# figure out audio tracks
$title_bit =~ /(?<leadspace>\s+)\+\s+audio\s+tracks:\n # audio track header