Skip to content

Commit 61064e6

Browse files
committed
- Pass the YouTube URL to mpv when there are no streaming URLs.
This also fixes the playing of livestreams.
1 parent ecdb7d4 commit 61064e6

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

bin/gtk-youtube-viewer

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,6 +2835,10 @@ sub get_player_command {
28352835
escape => 1,
28362836
);
28372837

2838+
if ($streaming->{streaming}{url} =~ m{^https://www\.youtube\.com/watch\?v=}) {
2839+
$cmd =~ s{ --no-ytdl\b}{ }g;
2840+
}
2841+
28382842
$has_video ? $cmd : join(' ', $cmd, quotemeta($streaming->{streaming}{url}));
28392843
}
28402844

bin/youtube-viewer

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,10 @@ sub get_player_command {
31443144
escape => 1,
31453145
);
31463146

3147+
if ($streaming->{streaming}{url} =~ m{^https://www\.youtube\.com/watch\?v=}) {
3148+
$cmd =~ s{ --no-ytdl\b}{ }g;
3149+
}
3150+
31473151
$has_video ? $cmd : join(' ', $cmd, quotemeta($streaming->{streaming}{url}));
31483152
}
31493153

lib/WWW/YoutubeViewer.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,17 @@ sub get_streaming_urls {
740740
# Filter out streams with `clen = 0`.
741741
@streaming_urls = grep { defined($_->{clen}) ? ($_->{clen} > 0) : 1 } @streaming_urls;
742742

743+
# Return the YouTube URL when there are no streaming URLs
744+
if (!@streaming_urls) {
745+
push @streaming_urls,
746+
{
747+
itag => 22,
748+
quality => "hd720",
749+
type => "video/mp4",
750+
url => "https://www.youtube.com/watch?v=$videoID",
751+
};
752+
}
753+
743754
return (\@streaming_urls, \@caption_urls, \%info);
744755
}
745756

0 commit comments

Comments
 (0)