Last active
June 9, 2020 03:31
-
-
Save anakaiti/dd2677faf8a805726157eb4b93fc6552 to your computer and use it in GitHub Desktop.
Watch youtube live stream using streamlink, mpv & open popout chat in fish shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function watchlive --description 'Watch youtube live stream' --argument url mode | |
set url (string match -r 'v=[^&]+' $url) | |
google-chrome --new-window "--app=https://www.youtube.com/live_chat?is_popout=1&$url" & | |
set prefix streamlink --retry-streams 5 | |
set suffix "https://www.youtube.com/watch?$url" | |
if [ "$mode" = 'audio' ] | |
# 144p & 240p: AAC-HEv2 2ch 48Khz 48Kbps | |
# 360p & 480p: AAC-LC 2ch 48Khz 128Kbps | |
# 720p & beyond: Max quality audio (up to 384k) | |
$prefix -p 'mpv --no-video' $suffix worst | |
else if set -q mode | |
$prefix $suffix $mode | |
else | |
$prefix $suffix | |
end | |
# ending | |
for window in (wmctrl -l | grep $url | cut -c -10) | |
wmctrl -i -c $window | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment