Some patches

This commit is contained in:
localhost_frssoft 2022-04-18 17:12:22 +03:00
parent 77186eac68
commit 1efe93c629
1 changed files with 48 additions and 48 deletions

View File

@ -23,7 +23,7 @@ torrent_init()
check_connect() check_connect()
{ {
if [ -n "$(curl --head -s $instance_point/config | grep 'HTTP\/. 200')" ]; then if [ -n "$(curl --head -s "$instance_point"/config | grep 'HTTP\/. 200')" ]; then
echo 'OK' echo 'OK'
else else
echo echo
@ -47,7 +47,7 @@ peertube_api_get_all_videos()
peertube_api_get_local_videos() peertube_api_get_local_videos()
{ {
if [ $version -gt 3 ]; then if [ "$version" -gt 3 ]; then
default_curl_opt "$instance_point/videos?count=100&start=$1&isLocal=true" | jj -p | tee preload >> /dev/null default_curl_opt "$instance_point/videos?count=100&start=$1&isLocal=true" | jj -p | tee preload >> /dev/null
else else
default_curl_opt "$instance_point/videos?count=100&start=$1&filter=local" | jj -p | tee preload >> /dev/null default_curl_opt "$instance_point/videos?count=100&start=$1&filter=local" | jj -p | tee preload >> /dev/null
@ -82,18 +82,18 @@ peertube_menu_videos()
"Next page") "Next page")
if [ "$1" = 'all' ]; then if [ "$1" = 'all' ]; then
page=$(expr $page + 100) page=$(expr $page + 100)
peertube_api_get_all_videos $page peertube_api_get_all_videos "$page"
else else
page=$(expr $page + 100) page=$(expr "$page" + 100)
peertube_api_get_local_videos $page peertube_api_get_local_videos "$page"
fi ;; fi ;;
*) *)
index=$(echo $menu_videos_choice | cut -f 1 -d:) index=$(echo "$menu_videos_choice" | cut -f 1 -d:)
video_uuid=$(jj -i preload data.$index.uuid) video_uuid=$(jj -i preload data."$index".uuid)
if [ "$1" = 'lives' ]; then if [ "$1" = 'lives' ]; then
peertube_menu_stream $video_uuid peertube_menu_stream "$video_uuid"
else else
peertube_menu_video $video_uuid peertube_menu_video "$video_uuid"
fi ;; fi ;;
esac esac
done done
@ -103,23 +103,23 @@ peertube_menu_video()
{ {
clear clear
sub2_menu=1 sub2_menu=1
get_video=$(peertube_api_get_video $1) get_video=$(peertube_api_get_video "$1")
while [ $sub2_menu -eq 1 ]; do while [ $sub2_menu -eq 1 ]; do
name=$(echo $get_video | jj name) name=$(echo "$get_video" | jj name)
desc=$(echo $get_video | jj description) desc=$(echo "$get_video" | jj description)
channel=$(echo $get_video | jj channel.name) channel=$(echo "$get_video" | jj channel.name)
support_author=$(echo $get_video | jj support) support_author=$(echo "$get_video" | jj support)
if [ -n "$support_author" ]; then if [ -n "$support_author" ]; then
echo "Support/Donate: $support_author" echo "Support/Donate: $support_author"
fi fi
check_hls_empty=$(echo $get_video | jj streamingPlaylists.0) check_hls_empty=$(echo "$get_video" | jj streamingPlaylists.0)
if [ -z $check_hls_empty ]; then if [ -z "$check_hls_empty" ]; then
hls='' hls=''
else else
hls='streamingPlaylists.0.' hls='streamingPlaylists.0.'
fi fi
video_url=$(echo $get_video | jj "$hls"files.#[resolution.id=$pref_video_quality].fileUrl) video_url=$(echo "$get_video" | jj "$hls"files.#[resolution.id="$pref_video_quality"].fileUrl)
torrent_url=$(echo $get_video | jj "$hls"files.#[resolution.id=$pref_video_quality].torrentUrl) torrent_url=$(echo "$get_video" | jj "$hls"files.#[resolution.id="$pref_video_quality"].torrentUrl)
echo "Channel: $channel" echo "Channel: $channel"
fulldescr= fulldescr=
if [ -n "$desc" ]; then if [ -n "$desc" ]; then
@ -135,27 +135,27 @@ peertube_menu_video()
if [ -z "$video_url" ]; then if [ -z "$video_url" ]; then
echo "Resolution $pref_video_quality"'p not avalaible' echo "Resolution $pref_video_quality"'p not avalaible'
echo 'Please choice:' echo 'Please choice:'
resolution=$(echo $get_video | jj -l "$hls"files.#.resolution.label | fzy) resolution=$(echo "$get_video" | jj -l "$hls"files.#.resolution.label | fzy)
video_url=$(echo $get_video | jj "$hls"files.#[resolution.label=$resolution].fileUrl) video_url=$(echo "$get_video" | jj "$hls"files.#[resolution.label="$resolution"].fileUrl)
torrent_url=$(echo $get_video | jj "$hls"files.#[resolution.label=$resolution].torrentUrl) torrent_url=$(echo "$get_video" | jj "$hls"files.#[resolution.label="$resolution"].torrentUrl)
fi fi
if [ "$torrent_enabled" = 'true' ]; then if [ "$torrent_enabled" = 'true' ]; then
transmission-remote $rpcport -a $torrent_url transmission-remote $rpcport -a "$torrent_url"
curl -s --tcp-fastopen --output - $video_url | $default_player_command - curl -s --tcp-fastopen --output - "$video_url" | $default_player_command -
transmission-remote $rpcport -t 1 -rad transmission-remote $rpcport -t 1 -rad
else else
curl -s --tcp-fastopen --output - $video_url | $default_player_command - curl -s --tcp-fastopen --output - "$video_url" | $default_player_command -
fi ;; fi ;;
"Full description") "Full description")
fulldesc=$(peertube_api_get_fulldescription $1) fulldesc=$(peertube_api_get_fulldescription "$1")
echo "$fulldesc" | less -e ;; echo "$fulldesc" | less -e ;;
"Share") "Share")
echo "Link: https://$instance/w/$1" echo "Link: https://$instance/w/$1"
echo "Direct links:" echo "Direct links:"
echo "$(echo $get_video | jj -l "$hls"files.#.resolution.label)" echo "$(echo "$get_video" | jj -l "$hls"files.#.resolution.label)"
echo "$(echo $get_video | jj -l "$hls"files.#.fileUrl)" ;; echo "$(echo "$get_video" | jj -l "$hls"files.#.fileUrl)" ;;
esac esac
done done
} }
@ -164,17 +164,17 @@ peertube_menu_stream()
{ {
clear clear
sub2_menu=1 sub2_menu=1
get_video=$(peertube_api_get_video $1) get_video=$(peertube_api_get_video "$1")
while [ $sub2_menu -eq 1 ]; do while [ $sub2_menu -eq 1 ]; do
name=$(echo $get_video | jj name) name=$(echo "$get_video" | jj name)
desc=$(echo $get_video | jj description) desc=$(echo "$get_video" | jj description)
channel=$(echo $get_video | jj channel.name) channel=$(echo "$get_video" | jj channel.name)
support_author=$(echo $get_video | jj support) support_author=$(echo "$get_video" | jj support)
if [ -n "$support_author" ]; then if [ -n "$support_author" ]; then
echo "Support/Donate: $support_author" echo "Support/Donate: $support_author"
fi fi
playlist_stream=$(echo $get_video | jj streamingPlaylists.0.playlistUrl) playlist_stream=$(echo "$get_video" | jj streamingPlaylists.0.playlistUrl)
state=$(echo $get_video | jj state.label) state=$(echo "$get_video" | jj state.label)
echo "Status: $state" echo "Status: $state"
#torrent_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.id=$pref_video_quality].torrentUrl) #torrent_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.id=$pref_video_quality].torrentUrl)
echo "Channel: $channel" echo "Channel: $channel"
@ -188,15 +188,15 @@ peertube_menu_stream()
case $menu_video_choice in case $menu_video_choice in
"Main menu") sub2_menu=0 && sub_menu=0 ;; "Main menu") sub2_menu=0 && sub_menu=0 ;;
"Back") sub2_menu=0 ;; "Back") sub2_menu=0 ;;
"Play") $default_player_command $playlist_stream ;; "Play") $default_player_command "$playlist_stream" ;;
"Wait mode") "Wait mode")
playlist_stream=$(echo $get_video | jj streamingPlaylists.0.playlistUrl) playlist_stream=$(echo "$get_video" | jj streamingPlaylists.0.playlistUrl)
echo 'Wait mode enabled...' echo 'Wait mode enabled...'
echo 'Stream will be played when published state' echo 'Stream will be played when published state'
while [ -z $playlist_stream ]; do while [ -z "$playlist_stream" ]; do
get_video=$(peertube_api_get_video $1) get_video=$(peertube_api_get_video "$1")
playlist_stream=$(echo $get_video | jj streamingPlaylists.0.playlistUrl) playlist_stream=$(echo "$get_video" | jj streamingPlaylists.0.playlistUrl)
wait=15 wait=15
while [ $wait -gt 0 ]; do while [ $wait -gt 0 ]; do
date date
@ -206,10 +206,10 @@ peertube_menu_stream()
done done
clear clear
echo 'Stream PUBLISHED!' echo 'Stream PUBLISHED!'
$default_player_command $playlist_stream $default_player_command "$playlist_stream"
;; ;;
"Full description") "Full description")
fulldesc=$(peertube_api_get_fulldescription $1) fulldesc=$(peertube_api_get_fulldescription "$1")
echo "$fulldesc" | less -e ;; echo "$fulldesc" | less -e ;;
"Share") "Share")
@ -231,8 +231,8 @@ menu_settings()
"$default_res") "$default_res")
resolution=$(echo '144\n240\n288\n480\n720\n1080' | fzy) resolution=$(echo '144\n240\n288\n480\n720\n1080' | fzy)
jj -i config.json prefer_quality_video -v $resolution -o config.json jj -i config.json prefer_quality_video -v "$resolution" -o config.json
export pref_video_quality=$resolution ;; export pref_video_quality="$resolution" ;;
"$torrent_set") "$torrent_set")
case $torrent_enabled in case $torrent_enabled in
@ -289,10 +289,10 @@ while true; do
type_choice=$(echo "Video\nStream" | fzy) type_choice=$(echo "Video\nStream" | fzy)
echo 'Input link:' echo 'Input link:'
read url read url
url=$(echo $url | rev | cut -f1 -d/ | rev) url=$(echo "$url" | rev | cut -f1 -d/ | rev)
case $type_choice in case $type_choice in
"Video") peertube_menu_video $url ;; "Video") peertube_menu_video "$url" ;;
"Stream") peertube_menu_stream $url ;; "Stream") peertube_menu_stream "$url" ;;
esac esac
;; ;;
@ -312,7 +312,7 @@ while true; do
"Manual input") echo "Type instance (ex. $instance):" && read instance ;; "Manual input") echo "Type instance (ex. $instance):" && read instance ;;
esac esac
if [ $empty -eq 0 ]; then if [ $empty -eq 0 ]; then
echo $instance >> $instance_hist echo "$instance" >> $instance_hist
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
export instance export instance
export instance_point="https://$instance/api/v1" export instance_point="https://$instance/api/v1"
@ -325,7 +325,7 @@ while true; do
export version=$(peertube_api_version_server) export version=$(peertube_api_version_server)
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy) conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
if [ "$conf_instance_state" = 'Permanent' ]; then if [ "$conf_instance_state" = 'Permanent' ]; then
jj -i config.json instance -v $instance -o config.json jj -i config.json instance -v "$instance" -o config.json
else else
echo '' echo ''
fi fi