Skip to content

Instantly share code, notes, and snippets.

@anakaiti
Last active June 9, 2020 03:31
Show Gist options
  • Save anakaiti/dd2677faf8a805726157eb4b93fc6552 to your computer and use it in GitHub Desktop.
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
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