2023-02-14 18:22:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
: "${1?How to use: $0 PT_VIDEO_LINK}"
|
|
|
|
|
|
|
|
link="$1"
|
|
|
|
|
|
|
|
### Get HTML
|
|
|
|
|
|
|
|
wget "$link" -O /tmp/videohtml
|
|
|
|
|
|
|
|
### Variables
|
|
|
|
|
|
|
|
videolink=$( grep "meta property" /tmp/videohtml | grep "og:video:url" \
|
|
|
|
| sed 's/.*href="//' | sed 's#" />##')
|
|
|
|
chatver=$( grep 'peertube-plugin-livechat' /tmp/videohtml | grep 'version'\
|
|
|
|
| sed 's#.*npmName..:..peertube-plugin-livechat.....name..:..livechat.....version..:..##' \
|
|
|
|
| sed 's#.....description.....PeerTube plugin livechat: offers a way.*##' )
|
|
|
|
instance=$(echo "$videolink" | sed 's#https://##' | sed '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" &
|
2023-02-18 17:15:27 +00:00
|
|
|
mpv --no-terminal https://"$instance"/static/streaming-playlists/hls/"$videoid"/0.m3u8 &
|
2023-02-14 18:22:28 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
function nolive()
|
|
|
|
{
|
2023-02-18 17:15:27 +00:00
|
|
|
mpv --no-terminal --ytdl-format=best "$videolink"
|
2023-02-14 18:22:28 +00:00
|
|
|
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
|