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
2023-05-08 22:23:01 +00:00
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/##' )
2023-02-14 18:22:28 +00:00
### 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-03-16 12:46:53 +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
2023-03-16 12:46:53 +00:00