59 lines
1.1 KiB
Bash
59 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
: "${1?How to use: $0 PT_VIDEO_LINK}"
|
|
|
|
link="$1"
|
|
|
|
### Get HTML
|
|
|
|
wget "$link" -O /tmp/videohtml
|
|
|
|
### Variables
|
|
|
|
videolink=$(grep "og:video:url" /tmp/videohtml | sed 's/.*href="//;s#" />##' )
|
|
chatver=$(grep "peertube-plugin-livechat" /tmp/videohtml \
|
|
| sed 's#.*npmName..:..peertube-plugin-livechat.....name..:..livechat.....version..:..##;s#.....description.....PeerTube plugin livechat: offers a way.*##' )
|
|
instance=$(echo "$videolink" | sed 's#https://##;s#/videos/watch/.*##')
|
|
videoid=$(echo "$videolink" | sed 's#.*videos/watch/##')
|
|
|
|
### Delete html
|
|
|
|
rm /tmp/videohtml
|
|
|
|
### Functions
|
|
|
|
function live()
|
|
{
|
|
xdg-open https://"$instance"/plugins/livechat/"$chatver"/router/webchat/room/"$videoid" &
|
|
mpv --no-terminal https://"$instance"/static/streaming-playlists/hls/"$videoid"/0.m3u8 &
|
|
exit 0
|
|
}
|
|
|
|
function nolive()
|
|
{
|
|
mpv --no-terminal --ytdl-format=best "$videolink" &
|
|
exit 0
|
|
}
|
|
|
|
### Choose
|
|
|
|
echo
|
|
echo "Is it live? (Y/n)"
|
|
read -r is_live
|
|
echo
|
|
|
|
case "$is_live" in
|
|
"" | "y")
|
|
live
|
|
;;
|
|
"n")
|
|
nolive
|
|
;;
|
|
* )
|
|
echo "Ты, блять, дурак что ли? Белым по чёрному написано y или n"
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
|