06 agosto 2021 [PeerTube, Programming, Tech]
Mi servidor Peertube no funciona, por lo que necesito mover mis videos a otro. El guión oficial no parece cubrir bien este caso, así que esto es lo que hice.
Mi secuencia de comandos toma el video y sus detalles y lo sube a un nuevo servidor a través de la API de Peertube.
Se aceptan contribuciones: no pude copiar la descripción del video y era demasiado vago, así que codifiqué la cantidad de etiquetas. Además, no creé un repositorio de git para nada de esto porque sentí que necesitaba más reflexión, pero siéntete libre de iniciar uno y estaré encantado de contribuir con él.
Este script copia todos los videos en un canal de Peertube a un servidor diferente. Tienes que encontrar el ID numérico del canal en el nuevo servidor para copiar, lo cual hice mirando la respuesta en la pestaña Red de las herramientas de desarrollo de Firefox cuando hice clic en su nombre en la interfaz web. Requiere bash, curl, youtube-dl y jq.
Aquí está peertube-migrate-channel.bash:
#!/bin/bash
set -u
set -e
# Modify these for your setup
OLD_SERVER="INSERT OLD SERVER e.g.
OLD_CHANNEL="INSERT CHANNEL URL-NAME e.g. trials_fusion"
NEW_SERVER="INSERT NEW SERVER e.g.
NEW_CHANNEL="INSERT NEW CHANNEL ID e.g. 4103"
USERNAME="INSERT_USERNAME for new server e.g. trials"
PASSWORD="INSERT PASSWORD for new server"
TAG1="INSERT_A_TAG e.g trials"
TAG2="INSERT_A_TAG e.g. gaming"
TAG3="INSERT_A_TAG e.g. gameing"
DIR=$(mktemp -d)
API_PATH="$NEW_SERVER/api/v1"
# Find out how many videos are in the channel
curl -s \
"$OLD_SERVER/api/v1/video-channels/$OLD_CHANNEL/videos/?count=1" \
> "$DIR/videos-total.json"
TOTAL=$(jq .total < "$DIR/videos-total.json")
CURRENT=0
PAGE_SIZE=10
# Get a list of URLS for all the videos
echo -n "" > "$DIR/urls.txt"
while (( CURRENT < TOTAL )); do
FILE="$DIR/videos-page-$CURRENT.json"
curl -s \
"$OLD_SERVER/api/v1/video-channels/$OLD_CHANNEL/videos/?start=$CURRENT&count=$PAGE_SIZE&skipCount=true" \
> "$FILE"
jq ".data | map(.uuid) | .[]" -r < "$FILE" >> "$DIR/urls.txt"
CURRENT=$((CURRENT + PAGE_SIZE))
done
# Log in to the new server
client_id=$(curl -s "$API_PATH/oauth-clients/local" | jq -r ".client_id")
client_secret=$(curl -s "$API_PATH/oauth-clients/local" | jq -r ".client_secret")
token=$(curl -s "$API_PATH/users/token" \
--data client_id="$client_id" \
--data client_secret="$client_secret" \
--data grant_type=password \
--data response_type=code \
--data username="$USERNAME" \
--data password="$PASSWORD" \
| jq -r ".access_token")
# Download and upload each video
tac "$DIR/urls.txt" \
| while read ID; do
URL="$OLD_SERVER/api/v1/videos/$ID"
curl -s "$URL" > "$DIR/info-$ID.json"
NAME=$(jq -r .name < "$DIR/info-$ID.json")
CATEGORY=$(jq -r .category.id < "$DIR/info-$ID.json")
LICENCE=$(jq -r .licence.id < "$DIR/info-$ID.json")
LANGUAGE=$(jq -r .language.id < "$DIR/info-$ID.json")
PRIVACY=$(jq -r .privacy.id < "$DIR/info-$ID.json")
OLD_VIDEO="
mkdir "$DIR/dl-$ID"
youtube-dl "$OLD_VIDEO" --output="$DIR/dl-$ID/dl.mp4"
echo "Uploading $OLD_VIDEO"
curl "$API_PATH/videos/upload" \
--silent \
-H "Authorization: Bearer $token" \
--output "$DIR/curl-out-$ID.txt" \
--max-time 6000 \
--form name="$NAME" \
--form videofile=@"$DIR/dl-$ID/dl.mp4" \
--form channelId=$NEW_CHANNEL \
--form category=$CATEGORY \
--form licence=$LICENCE \
--form description="TODO VIDEO DESCRIPTION" \
--form language=$LANGUAGE \
--form privacy=$PRIVACY \
--form tags="$TAG1" \
--form tags="$TAG2" \
--form tags="$TAG3"
done
Agen Togel Terpercaya
Bandar Togel
Sabung Ayam Online
Berita Terkini
Artikel Terbaru
Berita Terbaru
Penerbangan
Berita Politik
Berita Politik
Software
Software Download
Download Aplikasi
Berita Terkini
News
Jasa PBN
Jasa Artikel
News
Breaking News
Berita