Import video to pertube from file
This commit is contained in:
parent
3bba0ea621
commit
b8c927a2a6
|
@ -149,56 +149,120 @@ function peertube_disable_signups {
|
|||
systemctl restart peertube
|
||||
}
|
||||
|
||||
function peertube_import_from_file {
|
||||
read_config_param MY_USERNAME
|
||||
read_config_param PEERTUBE_DOMAIN_NAME
|
||||
read_config_param ONION_ONLY
|
||||
|
||||
data2=$(mktemp 2>/dev/null)
|
||||
dialog --backtitle $"Freedombone Control Panel" \
|
||||
--title $"Import Video from file" \
|
||||
--form $"Enter your PeerTube login details and video title" 10 65 4 \
|
||||
$"Username:" 1 1 "$MY_USERNAME" 1 18 16 15 \
|
||||
$"Password:" 2 1 "" 2 18 40 10000 \
|
||||
$"Video Title:" 3 1 "" 3 18 40 1000 \
|
||||
$"NSFW:" 4 1 $"no" 4 18 4 4 \
|
||||
2> "$data2"
|
||||
sel=$?
|
||||
case $sel in
|
||||
1) rm -f "$data2"
|
||||
return;;
|
||||
255) rm -f "$data2"
|
||||
return;;
|
||||
esac
|
||||
peertubeuser=$(sed -n 1p < "$data2")
|
||||
peertubepassword=$(sed -n 2p < "$data2")
|
||||
peertubetitle=$(sed -n 3p < "$data2")
|
||||
peertubensfw=$(sed -n 4p < "$data2")
|
||||
rm -f "$data2"
|
||||
|
||||
peertubedomain="http://localhost:${PEERTUBE_PORT}"
|
||||
|
||||
data2=$(mktemp 2>/dev/null)
|
||||
dialog --title "Choose the video file (select with spacebar)" --fselect "/home/$MY_USERNAME/" 30 60 2> "$data2"
|
||||
selected_file=$(cat "$data2")
|
||||
rm -f "$data2"
|
||||
if [ ! "$selected_file" ]; then
|
||||
return
|
||||
fi
|
||||
if [[ "$selected_file" != *'.ogv' && "$selected_file" != *'.mp4' && "$selected_file" != *'.webm' ]]; then
|
||||
dialog --title $"Import video from file" \
|
||||
--msgbox $"The video should be in ogv, mp4 or webm format" 6 75
|
||||
return
|
||||
fi
|
||||
|
||||
cd $PEERTUBE_DIR || exit 32468356
|
||||
import_script=$PEERTUBE_DIR/dist/server/tools/upload.js
|
||||
if [ ! -f $import_script ]; then
|
||||
dialog --title $"Import videos" \
|
||||
--msgbox $"upload script was not found" 6 75
|
||||
return
|
||||
fi
|
||||
|
||||
nsfwstr=
|
||||
if [[ "$peertubensfw" == *'y'* || "$peertubensfw" == *'Y'* ]]; then
|
||||
nsfwstr='--nsfw'
|
||||
fi
|
||||
|
||||
titlestr=
|
||||
if [ "$peertubetitle" ]; then
|
||||
titlestr="-n \"$peertubetitle\""
|
||||
fi
|
||||
|
||||
clear
|
||||
node $import_script $nsfwstr "$titlestr" -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -f "$selected_file"
|
||||
|
||||
dialog --title $"Import video from file" \
|
||||
--msgbox $"Video imported from $selected_file" 6 75
|
||||
}
|
||||
|
||||
function peertube_import_videos {
|
||||
read_config_param MY_USERNAME
|
||||
read_config_param PEERTUBE_DOMAIN_NAME
|
||||
read_config_param ONION_ONLY
|
||||
|
||||
data=$(mktemp 2>/dev/null)
|
||||
data2=$(mktemp 2>/dev/null)
|
||||
dialog --backtitle $"Freedombone Control Panel" \
|
||||
--title $"Import Videos" \
|
||||
--form "Enter a channel of video URL for YouTube/Vimeo/Dailymotion" 10 75 4 \
|
||||
--title $"Import Videos from legacy sites" \
|
||||
--form $"Enter a channel of video URL for YouTube/Vimeo/Dailymotion" 10 75 4 \
|
||||
$"Username:" 1 1 "$MY_USERNAME" 1 28 16 15 \
|
||||
$"Password:" 2 1 "" 2 28 40 10000 \
|
||||
$"Video/Channel URL:" 3 1 "" 3 28 40 10000 \
|
||||
2> "$data"
|
||||
2> "$data2"
|
||||
sel=$?
|
||||
case $sel in
|
||||
1) rm -f "$data"
|
||||
1) rm -f "$data2"
|
||||
return;;
|
||||
255) rm -f "$data"
|
||||
255) rm -f "$data2"
|
||||
return;;
|
||||
esac
|
||||
peertubeuser=$(sed -n 1p < "$data")
|
||||
peertubepassword=$(sed -n 2p < "$data")
|
||||
video_url=$(sed -n 3p < "$data")
|
||||
rm -f "$data"
|
||||
peertubeuser=$(sed -n 1p < "$data2")
|
||||
peertubepassword=$(sed -n 2p < "$data2")
|
||||
video_url=$(sed -n 3p < "$data2")
|
||||
rm -f "$data2"
|
||||
|
||||
peertubedomain="https://$PEERTUBE_DOMAIN_NAME"
|
||||
if [[ "$ONION_ONLY" != 'no' ]]; then
|
||||
peertubedomain="http://$(cat /var/lib/tor/hidden_service_peertube/hostname)"
|
||||
fi
|
||||
peertubedomain="http://localhost:${PEERTUBE_PORT}"
|
||||
|
||||
if [ ${#peertubeuser} -lt 3 ]; then
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"Username was not valid" 6 75
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ${#peertubepassword} -lt 3 ]; then
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"Password was not valid" 6 75
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$video_url" == *' '* || "$video_url" == *','* || "$video_url" == *'@'* ]]; then
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"Video/channel URL was not valid" 6 75
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ${#video_url} -lt 8 ]; then
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"Video/channel URL was not valid" 6 75
|
||||
return
|
||||
fi
|
||||
|
@ -206,7 +270,7 @@ function peertube_import_videos {
|
|||
cd $PEERTUBE_DIR || exit 32468356
|
||||
import_script=$PEERTUBE_DIR/dist/server/tools/import-videos.js
|
||||
if [ ! -f $import_script ]; then
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"import-videos script was not found" 6 75
|
||||
return
|
||||
fi
|
||||
|
@ -214,7 +278,7 @@ function peertube_import_videos {
|
|||
clear
|
||||
node $import_script -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -t "$video_url"
|
||||
|
||||
dialog --title $"Import videos" \
|
||||
dialog --title $"Import videos from legacy sites" \
|
||||
--msgbox $"Video/s imported from $video_url" 6 75
|
||||
}
|
||||
|
||||
|
@ -224,11 +288,12 @@ function configure_interactive_peertube {
|
|||
data=$(mktemp 2>/dev/null)
|
||||
dialog --backtitle $"Freedombone Control Panel" \
|
||||
--title $"PeerTube" \
|
||||
--radiolist $"Choose an operation:" 11 70 5 \
|
||||
--radiolist $"Choose an operation:" 12 70 6 \
|
||||
1 $"Set administrator email address" off \
|
||||
2 $"Disable or enable signups" off \
|
||||
3 $"Import videos" off \
|
||||
4 $"Exit" on 2> "$data"
|
||||
3 $"Import videos from YouTube/Vimeo/Dailymotion" off \
|
||||
4 $"Import video from file" off \
|
||||
5 $"Exit" on 2> "$data"
|
||||
sel=$?
|
||||
case $sel in
|
||||
1) break;;
|
||||
|
@ -238,7 +303,8 @@ function configure_interactive_peertube {
|
|||
1) peertube_set_admin_email;;
|
||||
2) peertube_disable_signups;;
|
||||
3) peertube_import_videos;;
|
||||
4) rm -f "$data"
|
||||
4) peertube_import_from_file;;
|
||||
5) rm -f "$data"
|
||||
break;;
|
||||
esac
|
||||
rm -f "$data"
|
||||
|
|
Loading…
Reference in New Issue