@@ -4449,24 +4449,25 @@ sub get_metadata {
4449
4449
# programme versions
4450
4450
my %found ;
4451
4451
for my $ver ( @{$doc -> {versions }} ) {
4452
- for my $ver_type ( @{$ver -> {types }} ) {
4453
- my $type ;
4454
- # check for audiodescribed and signed first
4455
- if ( $ver_type =~ / (described|description)/i ) {
4456
- $type = " audiodescribed" ;
4457
- } elsif ( $ver_type =~ / sign/i ) {
4458
- $type = " signed" ;
4459
- } elsif ( $ver_type =~ / open subtitles/i ) {
4460
- $type = " opensubtitles" ;
4461
- } else {
4462
- ($type = lc ($ver_type )) =~ s /\s +.*$// ;
4463
- }
4464
- if ( $type ) {
4465
- my $version = $type ;
4466
- $version .= $found {$type } if ++$found {$type } > 1;
4467
- $prog -> {verpids }-> {$version } = $ver -> {pid };
4468
- $prog -> {durations }-> {$version } = $ver -> {duration };
4469
- }
4452
+ my @ver_types = @{$ver -> {types }};
4453
+ next unless @ver_types ;
4454
+ my $type ;
4455
+ if ( grep /(described|description)/i, @ver_types ) {
4456
+ $type = " audiodescribed" ;
4457
+ } elsif ( grep /sign/i, @ver_types ) {
4458
+ $type = " signed" ;
4459
+ } elsif ( grep /open subtitles/i, @ver_types ) {
4460
+ $type = " opensubtitles" ;
4461
+ } else {
4462
+ my @other_types = grep !/(described|description|sign|open subtitles)/i, @ver_types ;
4463
+ next unless @other_types ;
4464
+ ($type = lc ($other_types [0])) =~ s /\s +.*$// ;
4465
+ }
4466
+ if ( $type ) {
4467
+ my $version = $type ;
4468
+ $version .= $found {$type } if ++$found {$type } > 1;
4469
+ $prog -> {verpids }-> {$version } = $ver -> {pid };
4470
+ $prog -> {durations }-> {$version } = $ver -> {duration };
4470
4471
}
4471
4472
}
4472
4473
$got_metadata = 1 if $pid ;
0 commit comments