mirror of
http://gitea.phreedom.club/localhost_frssoft/peertube-cli
synced 2025-02-02 01:36:38 +00:00
preparing for userspace installation
This commit is contained in:
parent
236cbb3023
commit
8fa20fd650
|
@ -1,13 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
instance=$(jj -i config.json instance)
|
||||
pref_video_quality=$(jj -i config.json prefer_quality_video)
|
||||
torrent_enabled=$(jj -i config.json torrent_enabled)
|
||||
workdir="$HOME/.local/share/peertube-cli"
|
||||
instance=$(jj -i $workdir/config.json instance)
|
||||
pref_video_quality=$(jj -i $workdir/config.json prefer_quality_video)
|
||||
torrent_enabled=$(jj -i $workdir/config.json torrent_enabled)
|
||||
rpcport=9095
|
||||
instance_hist='instance.hist'
|
||||
instance_hist="$workdir/instance.hist"
|
||||
ordering='title'
|
||||
default_player_command='mpv --hwdec --network-timeout=30 --profile=low-latency'
|
||||
|
||||
mkdir -p $workdir
|
||||
if [ ! -f "$workdir/config.json" ]; then
|
||||
cp -r config.json transmission-daemon $workdir
|
||||
echo 'config created'
|
||||
fi
|
||||
instance_point="https://$instance/api/v1"
|
||||
default_curl_opt()
|
||||
{
|
||||
|
@ -17,7 +23,8 @@ default_curl_opt()
|
|||
torrent_init()
|
||||
{
|
||||
if [ "$torrent_enabled" = 'true' ]; then
|
||||
transmission-daemon -T -g transmission-daemon -w temp --password '' -p $rpcport
|
||||
tmp_dir=$(mktemp -d)
|
||||
transmission-daemon -T -g $workdir/transmission-daemon -w $tmp_dir --password '' -p $rpcport
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -42,21 +49,21 @@ peertube_api_version_server()
|
|||
|
||||
peertube_api_get_all_videos()
|
||||
{
|
||||
default_curl_opt "$instance_point/videos?count=100&start=$1" | jj -p | tee preload >> /dev/null
|
||||
default_curl_opt "$instance_point/videos?count=100&start=$1" | jj -p | tee $workdir/preload >> /dev/null
|
||||
}
|
||||
|
||||
peertube_api_get_local_videos()
|
||||
{
|
||||
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 $workdir/preload >> /dev/null
|
||||
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 $workdir/preload >> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
peertube_api_get_live_streams()
|
||||
{
|
||||
default_curl_opt "$instance_point/videos?count=100&start=$1&isLive=true&sort=-publishedAt" | jj -p | tee preload >> /dev/null
|
||||
default_curl_opt "$instance_point/videos?count=100&start=$1&isLive=true&sort=-publishedAt" | jj -p | tee $workdir/preload >> /dev/null
|
||||
}
|
||||
|
||||
peertube_api_get_livechat()
|
||||
|
@ -89,11 +96,11 @@ peertube_api_get_fulldescription()
|
|||
|
||||
peertube_menu_videos()
|
||||
{
|
||||
echo "Avalaible $(jj -i preload total) videos"
|
||||
echo "Avalaible $(jj -i $workdir/preload total) videos"
|
||||
sub_menu=1
|
||||
page=0
|
||||
while [ $sub_menu -eq 1 ]; do
|
||||
names=$(jj -i preload -l 'data.#.name' | nl -s: -v0 -w1)
|
||||
names=$(jj -i $workdir/preload -l 'data.#.name' | nl -s: -v0 -w1)
|
||||
menu_videos_choice=$(echo "Main menu\n$names\nNext page" | fzy)
|
||||
case $menu_videos_choice in
|
||||
"Main menu") sub_menu=0 ;;
|
||||
|
@ -107,7 +114,7 @@ peertube_menu_videos()
|
|||
fi ;;
|
||||
*)
|
||||
index=$(echo "$menu_videos_choice" | cut -f 1 -d:)
|
||||
video_uuid=$(jj -i preload data."$index".uuid)
|
||||
video_uuid=$(jj -i $workdir/preload data."$index".uuid)
|
||||
if [ "$1" = 'lives' ]; then
|
||||
peertube_menu_stream "$video_uuid"
|
||||
else
|
||||
|
@ -250,18 +257,18 @@ menu_settings()
|
|||
|
||||
"$default_res")
|
||||
resolution=$(echo '144\n240\n288\n480\n720\n1080' | fzy)
|
||||
jj -i config.json prefer_quality_video -v "$resolution" -o config.json
|
||||
jj -i $workdir/config.json prefer_quality_video -v "$resolution" -o $workdir/config.json
|
||||
export pref_video_quality="$resolution" ;;
|
||||
|
||||
"$torrent_set")
|
||||
case $torrent_enabled in
|
||||
'true')
|
||||
jj -i config.json torrent_enabled -v 'false' -o config.json
|
||||
jj -i $workdir/config.json torrent_enabled -v 'false' -o $workdir/config.json
|
||||
export torrent_enabled='false'
|
||||
transmission-remote $rpcport --exit ;;
|
||||
|
||||
'false')
|
||||
jj -i config.json torrent_enabled -v 'true' -o config.json
|
||||
jj -i $workdir/config.json torrent_enabled -v 'true' -o $workdir/config.json
|
||||
export torrent_enabled='true'
|
||||
torrent_init ;;
|
||||
esac
|
||||
|
@ -326,7 +333,7 @@ while true; do
|
|||
empty=1
|
||||
fi ;;
|
||||
|
||||
"Choice from list") instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy) ;;
|
||||
"Choice from list") instance=$(jj -l -i $workdir/config.json public_list_instances | sed 's/"//g' | fzy) ;;
|
||||
|
||||
"Manual input") echo "Type instance (ex. $instance):" && read instance ;;
|
||||
esac
|
||||
|
@ -344,7 +351,7 @@ while true; do
|
|||
export version=$(peertube_api_version_server)
|
||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||
if [ "$conf_instance_state" = 'Permanent' ]; then
|
||||
jj -i config.json instance -v "$instance" -o config.json
|
||||
jj -i $workdir/config.json instance -v "$instance" -o $workdir/config.json
|
||||
else
|
||||
echo ''
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue