peertube_torrent_url/get_torrent_url.sh

64 lines
1.5 KiB
Bash
Raw Normal View History

2022-03-05 10:52:07 +00:00
#!/bin/sh
2022-03-06 22:42:00 +00:00
# dep: jj sed curl
2022-03-05 10:52:07 +00:00
domain='xxivproduction.video'
2022-03-21 21:01:17 +00:00
channel='lies_channel'
2022-03-09 20:02:21 +00:00
count=1 # set to 1 for get latest video from channel
2022-03-05 10:52:07 +00:00
peertube_api_get_channel_videos ()
{
2022-03-05 23:12:47 +00:00
curl -S "https://$domain/api/v1/video-channels/$channel/videos?count=$count&skipCount=true"
2022-03-05 10:52:07 +00:00
}
peertube_api_get_video ()
{
2022-03-05 23:12:47 +00:00
curl -S "https://$domain/api/v1/videos/$1"
2022-03-05 10:52:07 +00:00
}
echo 'Getting uuids...'
get_uuids=$(peertube_api_get_channel_videos | jj -l data.#.uuid | sed 's/"//g')
echo 'Done\n'
2022-03-06 14:17:17 +00:00
2022-03-06 18:04:23 +00:00
get_all_torrents ()
2022-03-06 14:17:17 +00:00
{
2022-03-06 18:04:23 +00:00
echo 'Getting names and torrents'
2022-03-06 14:17:17 +00:00
for uuid in $get_uuids; do
2022-03-06 18:04:23 +00:00
echo $uuid
2022-03-06 14:17:17 +00:00
video=$(peertube_api_get_video $uuid)
2022-03-06 18:09:45 +00:00
echo $video | jj name >> "$channel".txt
echo $video | jj -l 'streamingPlaylists' | jj -l 'files.#.torrentUrl' | sed 's/"//g' >> "$channel".txt
2022-03-06 14:17:17 +00:00
sleep 1
done
}
2022-03-06 18:04:23 +00:00
get_latest_torrent_video ()
2022-03-06 14:17:17 +00:00
{
2022-03-06 22:42:00 +00:00
echo 'Getting name and torrent url...'
2022-03-06 14:17:17 +00:00
for uuid in $get_uuids; do
2022-03-06 18:04:23 +00:00
echo $uuid
2022-03-06 14:17:17 +00:00
video=$(peertube_api_get_video $uuid)
2022-03-06 18:09:45 +00:00
echo $video | jj name >> temp_"$channel".txt
echo $video | jj -l 'streamingPlaylists' | jj -l 'files.#.torrentUrl' | sed 's/"//g' >> temp_"$channel".txt
cat "$channel".txt >> temp_"$channel".txt
mv temp_"$channel".txt "$channel".txt
2022-03-06 14:17:17 +00:00
done
}
2022-03-12 21:47:32 +00:00
get_sizes ()
{
echo 'Getting sizes...'
for uuid in $get_uuids; do
echo $uuid
video=$(peertube_api_get_video $uuid)
echo $video | jj -l 'streamingPlaylists' | jj -l 'files.#.size' | sed 's/"//g' >> datasizes
done
awk '{s+=$1} END {printf "%.0f", s}' datasizes
}
2022-03-06 18:04:23 +00:00
if [ $count -ge 2 ]; then
get_all_torrents
elif [ $count -eq 1 ]; then
get_latest_torrent_video
2022-03-06 14:17:17 +00:00
fi
2022-03-12 21:47:32 +00:00
echo '\nDone'