Skip to content

Commit d5e1ceb

Browse files
committed
- When there are multiple audio tracks, select the default one.
One such video is: https://youtube.com/watch?v=YIEVL_072hA
1 parent ccbb6f4 commit d5e1ceb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/WWW/YoutubeViewer.pm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,16 @@ sub _extract_from_ytdl {
828828
foreach my $format (@{$ref->{formats}}) {
829829
if (exists($format->{format_id}) and exists($format->{url})) {
830830

831+
my $id = $format->{format_id};
832+
833+
# Keep only the default audio track
834+
if ($id =~ /(^[0-9]+)-[0-9]/) {
835+
$id = $1;
836+
$format->{format_note} =~ /\(default\)/ or next;
837+
}
838+
831839
my $entry = {
832-
itag => $format->{format_id},
840+
itag => $id,
833841
url => $format->{url},
834842
type => ((($format->{format} // '') =~ /audio only/i) ? 'audio/' : 'video/') . $format->{ext},
835843
};

0 commit comments

Comments
 (0)