added feature: seeding videos

This commit is contained in:
localhost_frssoft 2022-04-05 19:16:13 +03:00
parent da2baa7cac
commit 79da2a4a0a
5 changed files with 121 additions and 8 deletions

6
.gitignore vendored
View File

@ -1,2 +1,8 @@
temp
transmission-daemon/resume
transmission-daemon/torrents
transmission-daemon/blocklists
transmission-daemon/dht.dat
transmission-daemon/stats.json
preload
instance.hist

View File

@ -3,7 +3,8 @@ Just for fun. Simple "player" API script for PeerTube instances.
Features:
* Select videos and play
* Switch instance from public list in config.json[1] or manual input. Also recent used instance list.
* Seeding videos[1]
* Switch instance from public list in config.json[2] or manual input. Also recent used instance list.
* All others futures maybe working 50/50
Depends:
@ -12,5 +13,8 @@ Depends:
* [curl](https://curl.se/)
* [fzy](https://github.com/jhawthorn/fzy)
[1]**Warning:** "Public" list instances in config.json may content _unofficial instance_
Opt. depends:
* [1]transmisson-daemon - for seeding videos when playing (but video still load from server).
[2]**Warning:** "Public" list instances in config.json may content _unofficial instance_

View File

@ -1,6 +1,7 @@
{
"instance": "xxivproduction.video",
"prefer_quality_video": 480
"torrent_enabled": false
"public_list_instances": [
]

View File

@ -2,12 +2,20 @@
instance=$(jj -i config.json instance)
pref_video_quality=$(jj -i config.json prefer_quality_video)
torrent_enabled=$(jj -i config.json torrent_enabled)
instance_hist='instance.hist'
ordering='title'
default_player_command='mpv --network-timeout=30 --profile=low-latency'
instance_point="https://$instance/api/v1"
torrent_init()
{
if [ "$torrent_enabled" = 'true' ]; then
transmission-daemon -T -g transmission-daemon -w temp --password ''
fi
}
peertube_api_check_ratelimit()
{
curl -s --head "$instance_point/" | grep rate
@ -55,14 +63,22 @@ peertube_menu_video()
"Back") sub2_menu=0 ;;
"Play")
video_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.id=$pref_video_quality].fileUrl)
torrent_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.id=$pref_video_quality].torrentUrl)
if [ -z "$video_url" ]; then
echo "Resolution $pref_video_quality\\p not avalaible"
echo "Resolution $pref_video_quality\p not avalaible"
echo 'Please choice:'
resolution=$(echo $get_video | jj -l streamingPlaylists.0.files.#.resolution.label | fzy)
video_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.label=$resolution].fileUrl)
torrent_url=$(echo $get_video | jj streamingPlaylists.0.files.#[resolution.label=$resolution].torrentUrl)
fi
echo 'Loading may long time for big video'
$default_player_command $video_url ;;
if [ "$torrent_enabled" = 'true' ]; then
transmission-remote 9095 -a $torrent_url
$default_player_command $video_url
transmission-remote 9095 -t 1 -rad
else
$default_player_command $video_url
fi ;;
esac
done
}
@ -71,18 +87,34 @@ menu_settings()
{
sub_menu=1
while [ $sub_menu -eq 1 ]; do
set_nane=$(echo "Main menu\nDefault resolution (current: $pref_video_quality)" | fzy)
case $set_nane in
default_res="Default resolution (current: $pref_video_quality)"
torrent_set="Torrent (current: $torrent_enabled)"
set_name=$(echo "Main menu\n$default_res\n$torrent_set" | fzy)
case $set_name in
"Main menu") sub_menu=0 ;;
"Default resolution (current: $pref_video_quality)")
"$default_res")
resolution=$(echo '144\n240\n288\n480\n720\n1080' | fzy)
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 config.json torrent_enabled -v 'false' -o config.json
export torrent_enabled='false'
transmission-remote 9095 --exit ;;
'false')
jj -i config.json torrent_enabled -v 'true' -o config.json
export torrent_enabled='true'
torrent_init ;;
esac
esac
done
}
torrent_init
videosmenu='All Videos'
videosmenulocal='Local Videos'
changepod='Switch instance'
@ -140,7 +172,9 @@ while true; do
"$checkapilimits") peertube_api_check_ratelimit ;;
"$Exit") exit 0 ;;
"$Exit")
if [ $torrent_enabled = 'true' ]; then transmission-remote 9095 --exit; fi
exit 0 ;;
esac

View File

@ -0,0 +1,68 @@
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "temp",
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "temp",
"incomplete-dir-enabled": true,
"lpd-enabled": true,
"message-level": 2,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 49910,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": true,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": true,
"preallocation": 0,
"prefetch-enabled": true,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "127.0.0.1",
"rpc-enabled": true,
"rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": true,
"rpc-password": "",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "",
"rpc-whitelist": "127.0.0.1,::1",
"rpc-whitelist-enabled": true,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-slots-per-torrent": 14,
"utp-enabled": true
}