Skip to content

Commit 4efb728

Browse files
committed
avoid duplicate versions for AD and SL programmes
1 parent 210289d commit 4efb728

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

get_iplayer

+19-18
Original file line numberDiff line numberDiff line change
@@ -4449,24 +4449,25 @@ sub get_metadata {
44494449
# programme versions
44504450
my %found;
44514451
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};
44704471
}
44714472
}
44724473
$got_metadata = 1 if $pid;

0 commit comments

Comments
 (0)