|
@@ -149,56 +149,120 @@ function peertube_disable_signups {
|
149
|
149
|
systemctl restart peertube
|
150
|
150
|
}
|
151
|
151
|
|
|
152
|
+function peertube_import_from_file {
|
|
153
|
+ read_config_param MY_USERNAME
|
|
154
|
+ read_config_param PEERTUBE_DOMAIN_NAME
|
|
155
|
+ read_config_param ONION_ONLY
|
|
156
|
+
|
|
157
|
+ data2=$(mktemp 2>/dev/null)
|
|
158
|
+ dialog --backtitle $"Freedombone Control Panel" \
|
|
159
|
+ --title $"Import Video from file" \
|
|
160
|
+ --form $"Enter your PeerTube login details and video title" 10 65 4 \
|
|
161
|
+ $"Username:" 1 1 "$MY_USERNAME" 1 18 16 15 \
|
|
162
|
+ $"Password:" 2 1 "" 2 18 40 10000 \
|
|
163
|
+ $"Video Title:" 3 1 "" 3 18 40 1000 \
|
|
164
|
+ $"NSFW:" 4 1 $"no" 4 18 4 4 \
|
|
165
|
+ 2> "$data2"
|
|
166
|
+ sel=$?
|
|
167
|
+ case $sel in
|
|
168
|
+ 1) rm -f "$data2"
|
|
169
|
+ return;;
|
|
170
|
+ 255) rm -f "$data2"
|
|
171
|
+ return;;
|
|
172
|
+ esac
|
|
173
|
+ peertubeuser=$(sed -n 1p < "$data2")
|
|
174
|
+ peertubepassword=$(sed -n 2p < "$data2")
|
|
175
|
+ peertubetitle=$(sed -n 3p < "$data2")
|
|
176
|
+ peertubensfw=$(sed -n 4p < "$data2")
|
|
177
|
+ rm -f "$data2"
|
|
178
|
+
|
|
179
|
+ peertubedomain="http://localhost:${PEERTUBE_PORT}"
|
|
180
|
+
|
|
181
|
+ data2=$(mktemp 2>/dev/null)
|
|
182
|
+ dialog --title "Choose the video file (select with spacebar)" --fselect "/home/$MY_USERNAME/" 30 60 2> "$data2"
|
|
183
|
+ selected_file=$(cat "$data2")
|
|
184
|
+ rm -f "$data2"
|
|
185
|
+ if [ ! "$selected_file" ]; then
|
|
186
|
+ return
|
|
187
|
+ fi
|
|
188
|
+ if [[ "$selected_file" != *'.ogv' && "$selected_file" != *'.mp4' && "$selected_file" != *'.webm' ]]; then
|
|
189
|
+ dialog --title $"Import video from file" \
|
|
190
|
+ --msgbox $"The video should be in ogv, mp4 or webm format" 6 75
|
|
191
|
+ return
|
|
192
|
+ fi
|
|
193
|
+
|
|
194
|
+ cd $PEERTUBE_DIR || exit 32468356
|
|
195
|
+ import_script=$PEERTUBE_DIR/dist/server/tools/upload.js
|
|
196
|
+ if [ ! -f $import_script ]; then
|
|
197
|
+ dialog --title $"Import videos" \
|
|
198
|
+ --msgbox $"upload script was not found" 6 75
|
|
199
|
+ return
|
|
200
|
+ fi
|
|
201
|
+
|
|
202
|
+ nsfwstr=
|
|
203
|
+ if [[ "$peertubensfw" == *'y'* || "$peertubensfw" == *'Y'* ]]; then
|
|
204
|
+ nsfwstr='--nsfw'
|
|
205
|
+ fi
|
|
206
|
+
|
|
207
|
+ titlestr=
|
|
208
|
+ if [ "$peertubetitle" ]; then
|
|
209
|
+ titlestr="-n \"$peertubetitle\""
|
|
210
|
+ fi
|
|
211
|
+
|
|
212
|
+ clear
|
|
213
|
+ node $import_script $nsfwstr "$titlestr" -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -f "$selected_file"
|
|
214
|
+
|
|
215
|
+ dialog --title $"Import video from file" \
|
|
216
|
+ --msgbox $"Video imported from $selected_file" 6 75
|
|
217
|
+}
|
|
218
|
+
|
152
|
219
|
function peertube_import_videos {
|
153
|
220
|
read_config_param MY_USERNAME
|
154
|
221
|
read_config_param PEERTUBE_DOMAIN_NAME
|
155
|
222
|
read_config_param ONION_ONLY
|
156
|
223
|
|
157
|
|
- data=$(mktemp 2>/dev/null)
|
|
224
|
+ data2=$(mktemp 2>/dev/null)
|
158
|
225
|
dialog --backtitle $"Freedombone Control Panel" \
|
159
|
|
- --title $"Import Videos" \
|
160
|
|
- --form "Enter a channel of video URL for YouTube/Vimeo/Dailymotion" 10 75 4 \
|
|
226
|
+ --title $"Import Videos from legacy sites" \
|
|
227
|
+ --form $"Enter a channel of video URL for YouTube/Vimeo/Dailymotion" 10 75 4 \
|
161
|
228
|
$"Username:" 1 1 "$MY_USERNAME" 1 28 16 15 \
|
162
|
229
|
$"Password:" 2 1 "" 2 28 40 10000 \
|
163
|
230
|
$"Video/Channel URL:" 3 1 "" 3 28 40 10000 \
|
164
|
|
- 2> "$data"
|
|
231
|
+ 2> "$data2"
|
165
|
232
|
sel=$?
|
166
|
233
|
case $sel in
|
167
|
|
- 1) rm -f "$data"
|
|
234
|
+ 1) rm -f "$data2"
|
168
|
235
|
return;;
|
169
|
|
- 255) rm -f "$data"
|
|
236
|
+ 255) rm -f "$data2"
|
170
|
237
|
return;;
|
171
|
238
|
esac
|
172
|
|
- peertubeuser=$(sed -n 1p < "$data")
|
173
|
|
- peertubepassword=$(sed -n 2p < "$data")
|
174
|
|
- video_url=$(sed -n 3p < "$data")
|
175
|
|
- rm -f "$data"
|
|
239
|
+ peertubeuser=$(sed -n 1p < "$data2")
|
|
240
|
+ peertubepassword=$(sed -n 2p < "$data2")
|
|
241
|
+ video_url=$(sed -n 3p < "$data2")
|
|
242
|
+ rm -f "$data2"
|
176
|
243
|
|
177
|
|
- peertubedomain="https://$PEERTUBE_DOMAIN_NAME"
|
178
|
|
- if [[ "$ONION_ONLY" != 'no' ]]; then
|
179
|
|
- peertubedomain="http://$(cat /var/lib/tor/hidden_service_peertube/hostname)"
|
180
|
|
- fi
|
|
244
|
+ peertubedomain="http://localhost:${PEERTUBE_PORT}"
|
181
|
245
|
|
182
|
246
|
if [ ${#peertubeuser} -lt 3 ]; then
|
183
|
|
- dialog --title $"Import videos" \
|
|
247
|
+ dialog --title $"Import videos from legacy sites" \
|
184
|
248
|
--msgbox $"Username was not valid" 6 75
|
185
|
249
|
return
|
186
|
250
|
fi
|
187
|
251
|
|
188
|
252
|
if [ ${#peertubepassword} -lt 3 ]; then
|
189
|
|
- dialog --title $"Import videos" \
|
|
253
|
+ dialog --title $"Import videos from legacy sites" \
|
190
|
254
|
--msgbox $"Password was not valid" 6 75
|
191
|
255
|
return
|
192
|
256
|
fi
|
193
|
257
|
|
194
|
258
|
if [[ "$video_url" == *' '* || "$video_url" == *','* || "$video_url" == *'@'* ]]; then
|
195
|
|
- dialog --title $"Import videos" \
|
|
259
|
+ dialog --title $"Import videos from legacy sites" \
|
196
|
260
|
--msgbox $"Video/channel URL was not valid" 6 75
|
197
|
261
|
return
|
198
|
262
|
fi
|
199
|
263
|
|
200
|
264
|
if [ ${#video_url} -lt 8 ]; then
|
201
|
|
- dialog --title $"Import videos" \
|
|
265
|
+ dialog --title $"Import videos from legacy sites" \
|
202
|
266
|
--msgbox $"Video/channel URL was not valid" 6 75
|
203
|
267
|
return
|
204
|
268
|
fi
|
|
@@ -206,7 +270,7 @@ function peertube_import_videos {
|
206
|
270
|
cd $PEERTUBE_DIR || exit 32468356
|
207
|
271
|
import_script=$PEERTUBE_DIR/dist/server/tools/import-videos.js
|
208
|
272
|
if [ ! -f $import_script ]; then
|
209
|
|
- dialog --title $"Import videos" \
|
|
273
|
+ dialog --title $"Import videos from legacy sites" \
|
210
|
274
|
--msgbox $"import-videos script was not found" 6 75
|
211
|
275
|
return
|
212
|
276
|
fi
|
|
@@ -214,7 +278,7 @@ function peertube_import_videos {
|
214
|
278
|
clear
|
215
|
279
|
node $import_script -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -t "$video_url"
|
216
|
280
|
|
217
|
|
- dialog --title $"Import videos" \
|
|
281
|
+ dialog --title $"Import videos from legacy sites" \
|
218
|
282
|
--msgbox $"Video/s imported from $video_url" 6 75
|
219
|
283
|
}
|
220
|
284
|
|
|
@@ -224,11 +288,12 @@ function configure_interactive_peertube {
|
224
|
288
|
data=$(mktemp 2>/dev/null)
|
225
|
289
|
dialog --backtitle $"Freedombone Control Panel" \
|
226
|
290
|
--title $"PeerTube" \
|
227
|
|
- --radiolist $"Choose an operation:" 11 70 5 \
|
|
291
|
+ --radiolist $"Choose an operation:" 12 70 6 \
|
228
|
292
|
1 $"Set administrator email address" off \
|
229
|
293
|
2 $"Disable or enable signups" off \
|
230
|
|
- 3 $"Import videos" off \
|
231
|
|
- 4 $"Exit" on 2> "$data"
|
|
294
|
+ 3 $"Import videos from YouTube/Vimeo/Dailymotion" off \
|
|
295
|
+ 4 $"Import video from file" off \
|
|
296
|
+ 5 $"Exit" on 2> "$data"
|
232
|
297
|
sel=$?
|
233
|
298
|
case $sel in
|
234
|
299
|
1) break;;
|
|
@@ -238,7 +303,8 @@ function configure_interactive_peertube {
|
238
|
303
|
1) peertube_set_admin_email;;
|
239
|
304
|
2) peertube_disable_signups;;
|
240
|
305
|
3) peertube_import_videos;;
|
241
|
|
- 4) rm -f "$data"
|
|
306
|
+ 4) peertube_import_from_file;;
|
|
307
|
+ 5) rm -f "$data"
|
242
|
308
|
break;;
|
243
|
309
|
esac
|
244
|
310
|
rm -f "$data"
|