mirror of
http://gitea.phreedom.club/localhost_frssoft/peertube-cli
synced 2024-11-25 11:41:26 +00:00
Compare commits
6 commits
236cbb3023
...
028b3c8387
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 028b3c8387 | ||
localhost_frssoft | a705f79547 | ||
localhost_frssoft | 1d8f8c7279 | ||
localhost_frssoft | b477832e1a | ||
localhost_frssoft | 4a734a3438 | ||
localhost_frssoft | 8fa20fd650 |
10
install.sh
Executable file
10
install.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
installdir="$HOME/.local/bin"
|
||||
datadir="$HOME/.local/share/peertube-cli"
|
||||
mkdir -p $installdir
|
||||
mkdir -p $datadir
|
||||
|
||||
cp -r transmission-daemon config.json $datadir
|
||||
cp peertube-cli.sh $installdir/peertube-cli
|
||||
|
||||
echo "done, make sure $installdir in your PATH"
|
|
@ -1,13 +1,20 @@
|
|||
#!/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'
|
||||
tempvideostor=$(mktemp -d)
|
||||
default_player_command="mpv --hwdec --network-timeout=30 --profile=low-latency --cache=yes --cache-on-disk=yes --cache-dir=$tempvideostor --cache-unlink-files=immediate"
|
||||
|
||||
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,13 +24,14 @@ 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
|
||||
}
|
||||
|
||||
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'
|
||||
else
|
||||
echo
|
||||
|
@ -42,21 +50,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 +97,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 +115,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
|
||||
|
@ -136,8 +144,8 @@ peertube_menu_video()
|
|||
else
|
||||
hls='streamingPlaylists.0.'
|
||||
fi
|
||||
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)
|
||||
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)
|
||||
echo "Channel: $channel"
|
||||
fulldescr=
|
||||
if [ -n "$desc" ]; then
|
||||
|
@ -153,9 +161,9 @@ peertube_menu_video()
|
|||
if [ -z "$video_url" ]; then
|
||||
echo "Resolution $pref_video_quality"'p not avalaible'
|
||||
echo 'Please choice:'
|
||||
resolution=$(echo "$get_video" | jj -l "$hls"files.#.resolution.label | fzy)
|
||||
video_url=$(echo "$get_video" | jj "$hls"files.#[resolution.label="$resolution"].fileUrl)
|
||||
torrent_url=$(echo "$get_video" | jj "$hls"files.#[resolution.label="$resolution"].torrentUrl)
|
||||
resolution=$(echo "$get_video" | jj -l "$hls"files.\#.resolution.label | fzy)
|
||||
video_url=$(echo "$get_video" | jj "$hls"files.\#[resolution.label="$resolution"].fileUrl)
|
||||
torrent_url=$(echo "$get_video" | jj "$hls"files.\#[resolution.label="$resolution"].torrentUrl)
|
||||
fi
|
||||
|
||||
if [ "$torrent_enabled" = 'true' ]; then
|
||||
|
@ -172,8 +180,8 @@ peertube_menu_video()
|
|||
"Share")
|
||||
echo "Link: https://$instance/w/$1"
|
||||
echo "Direct links:"
|
||||
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.\#.resolution.label)"
|
||||
echo "$(echo "$get_video" | jj -l "$hls"files.\#.fileUrl)" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
@ -250,18 +258,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 +334,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 +352,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