Compare commits

..

No commits in common. "028b3c8387a625a5fd0673b8c18d716f166eb9ff" and "236cbb3023256ba457b22a091315683526d64d58" have entirely different histories.

2 changed files with 26 additions and 44 deletions

View file

@ -1,10 +0,0 @@
#!/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"

View file

@ -1,20 +1,13 @@
#!/bin/sh
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)
instance=$(jj -i config.json instance)
pref_video_quality=$(jj -i config.json prefer_quality_video)
torrent_enabled=$(jj -i config.json torrent_enabled)
rpcport=9095
instance_hist="$workdir/instance.hist"
instance_hist='instance.hist'
ordering='title'
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"
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()
{
@ -24,14 +17,13 @@ default_curl_opt()
torrent_init()
{
if [ "$torrent_enabled" = 'true' ]; then
tmp_dir=$(mktemp -d)
transmission-daemon -T -g $workdir/transmission-daemon -w $tmp_dir --password '' -p $rpcport
transmission-daemon -T -g transmission-daemon -w temp --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
@ -50,21 +42,21 @@ peertube_api_version_server()
peertube_api_get_all_videos()
{
default_curl_opt "$instance_point/videos?count=100&start=$1" | jj -p | tee $workdir/preload >> /dev/null
default_curl_opt "$instance_point/videos?count=100&start=$1" | jj -p | tee 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 $workdir/preload >> /dev/null
default_curl_opt "$instance_point/videos?count=100&start=$1&isLocal=true" | jj -p | tee preload >> /dev/null
else
default_curl_opt "$instance_point/videos?count=100&start=$1&filter=local" | jj -p | tee $workdir/preload >> /dev/null
default_curl_opt "$instance_point/videos?count=100&start=$1&filter=local" | jj -p | tee 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 $workdir/preload >> /dev/null
default_curl_opt "$instance_point/videos?count=100&start=$1&isLive=true&sort=-publishedAt" | jj -p | tee preload >> /dev/null
}
peertube_api_get_livechat()
@ -97,11 +89,11 @@ peertube_api_get_fulldescription()
peertube_menu_videos()
{
echo "Avalaible $(jj -i $workdir/preload total) videos"
echo "Avalaible $(jj -i preload total) videos"
sub_menu=1
page=0
while [ $sub_menu -eq 1 ]; do
names=$(jj -i $workdir/preload -l 'data.#.name' | nl -s: -v0 -w1)
names=$(jj -i 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 ;;
@ -115,7 +107,7 @@ peertube_menu_videos()
fi ;;
*)
index=$(echo "$menu_videos_choice" | cut -f 1 -d:)
video_uuid=$(jj -i $workdir/preload data."$index".uuid)
video_uuid=$(jj -i preload data."$index".uuid)
if [ "$1" = 'lives' ]; then
peertube_menu_stream "$video_uuid"
else
@ -144,8 +136,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
@ -161,9 +153,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
@ -180,8 +172,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
}
@ -258,18 +250,18 @@ menu_settings()
"$default_res")
resolution=$(echo '144\n240\n288\n480\n720\n1080' | fzy)
jj -i $workdir/config.json prefer_quality_video -v "$resolution" -o $workdir/config.json
jj -i config.json prefer_quality_video -v "$resolution" -o config.json
export pref_video_quality="$resolution" ;;
"$torrent_set")
case $torrent_enabled in
'true')
jj -i $workdir/config.json torrent_enabled -v 'false' -o $workdir/config.json
jj -i config.json torrent_enabled -v 'false' -o config.json
export torrent_enabled='false'
transmission-remote $rpcport --exit ;;
'false')
jj -i $workdir/config.json torrent_enabled -v 'true' -o $workdir/config.json
jj -i config.json torrent_enabled -v 'true' -o config.json
export torrent_enabled='true'
torrent_init ;;
esac
@ -334,7 +326,7 @@ while true; do
empty=1
fi ;;
"Choice from list") instance=$(jj -l -i $workdir/config.json public_list_instances | sed 's/"//g' | fzy) ;;
"Choice from list") instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy) ;;
"Manual input") echo "Type instance (ex. $instance):" && read instance ;;
esac
@ -352,7 +344,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 $workdir/config.json instance -v "$instance" -o $workdir/config.json
jj -i config.json instance -v "$instance" -o config.json
else
echo ''
fi