From ddc0b8872b38b739f2dd0b55bf280ca182df03c5 Mon Sep 17 00:00:00 2001 From: trizen Date: Sat, 11 Jul 2020 00:30:37 +0300 Subject: Minor code simplification. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- lib/WWW/FairViewer/Itags.pm | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'lib/WWW') diff --git a/lib/WWW/FairViewer/Itags.pm b/lib/WWW/FairViewer/Itags.pm index 15ef710..52ad82b 100644 --- a/lib/WWW/FairViewer/Itags.pm +++ b/lib/WWW/FairViewer/Itags.pm @@ -172,6 +172,8 @@ sub _find_streaming_url { foreach my $itag (@{$args{itags}->{$resolution}}) { + next if not exists $stream->{$itag->{value}}; + if ($itag->{hfr}) { $args{hfr} || next; # skip high frame rate (HFR) videos } @@ -179,8 +181,6 @@ sub _find_streaming_url { if ($itag->{dash}) { $args{dash} || next; - next if not exists $stream->{$itag->{value}}; - my $video_info = $stream->{$itag->{value}}; my $audio_info = $self->_find_streaming_url(%args, resolution => 'audio', dash => 0); @@ -192,23 +192,20 @@ sub _find_streaming_url { next; } - if (exists $stream->{$itag->{value}}) { - - if ($resolution eq 'audio' and not $args{dash_mp4_audio}) { - if ($itag->{format} eq 'mp4') { - next; # skip mp4 audio URLs - } + if ($resolution eq 'audio' and not $args{dash_mp4_audio}) { + if ($itag->{format} eq 'mp4') { + next; # skip mp4 audio URLs } + } - my $entry = $stream->{$itag->{value}}; - - # Ignore segmented DASH URLs (they load pretty slow in mpv) - if (not $args{dash_segmented}) { - next if ($entry->{url} =~ m{^https://manifest\.googlevideo\.com/api/manifest/dash/}); - } + my $entry = $stream->{$itag->{value}}; - return $entry; + # Ignore segmented DASH URLs (they load pretty slow in mpv) + if (not $args{dash_segmented}) { + next if ($entry->{url} =~ m{^https://manifest\.googlevideo\.com/api/manifest/dash/}); } + + return $entry; } return; -- cgit v1.2.3