Przeglądaj źródła

Fixing peertube video sync

Bob Mottram 7 lat temu
rodzic
commit
30f6c1fc58
2 zmienionych plików z 31 dodań i 10 usunięć
  1. 28
    7
      src/freedombone-app-peertube
  2. 3
    3
      src/freedombone-syncthing

+ 28
- 7
src/freedombone-app-peertube Wyświetl plik

55
                     MY_EMAIL_ADDRESS)
55
                     MY_EMAIL_ADDRESS)
56
 
56
 
57
 function peertube_import_from_syncthing {
57
 function peertube_import_from_syncthing {
58
+    peertubedomain="https://$PEERTUBE_DOMAIN_NAME"
59
+    nodecmd='node'
60
+
61
+    if [[ "$ONION_ONLY" != 'no' ]]; then
62
+        peertubedomain="http://$(cat /var/lib/tor/hidden_service_peertube/hostname)"
63
+        nodecmd='torsocks node'
64
+    fi
65
+
58
     { echo '#!/bin/bash';
66
     { echo '#!/bin/bash';
59
       echo '';
67
       echo '';
60
       echo "MY_USERNAME=\$(cat /root/${PROJECT_NAME}.cfg | grep MY_USERNAME | awk -F '=' '{print \$2}')";
68
       echo "MY_USERNAME=\$(cat /root/${PROJECT_NAME}.cfg | grep MY_USERNAME | awk -F '=' '{print \$2}')";
71
       echo '    exit 0';
79
       echo '    exit 0';
72
       echo 'fi';
80
       echo 'fi';
73
       echo '';
81
       echo '';
74
-      echo "peertubedomain=\"http://localhost:${PEERTUBE_PORT}\"";
82
+      echo "peertubedomain=\"$peertubedomain\"";
75
       echo "peertubeuser=\$(sed -n 1p < \"\$search_dir/login.txt\")";
83
       echo "peertubeuser=\$(sed -n 1p < \"\$search_dir/login.txt\")";
76
       echo "peertubepassword=\$(sed -n 2p < \"\$search_dir/login.txt\")";
84
       echo "peertubepassword=\$(sed -n 2p < \"\$search_dir/login.txt\")";
77
       echo 'peertubensfw=';
85
       echo 'peertubensfw=';
100
       echo "        if ! grep \"\$video_file\" /root/.peertube_uploaded; then";
108
       echo "        if ! grep \"\$video_file\" /root/.peertube_uploaded; then";
101
       echo "            if ! grep \"\$video_file\" /root/.peertube_uploading; then";
109
       echo "            if ! grep \"\$video_file\" /root/.peertube_uploading; then";
102
       echo "                echo \"\$video_file\" >> /root/.peertube_uploading";
110
       echo "                echo \"\$video_file\" >> /root/.peertube_uploading";
103
-      echo "                if node \$import_script \$peertubensfw \$peertubeprivate -u \"\$peertubedomain\" -U \"\$peertubeuser\" --password \"\$peertubepassword\" -f \"\$video_file\"; then";
111
+      echo "                peertubetitle=\$(basename \"\$video_file\" | awk -F '.' '{print \$1}' | sed 's|_| |g' | sed 's|-| |g')";
112
+      echo "                if $nodecmd \$import_script -n \$peertubetitle \$peertubensfw \$peertubeprivate -u \"\$peertubedomain\" -U \"\$peertubeuser\" --password \"\$peertubepassword\" -f \"\$video_file\"; then";
104
       echo "                    echo \"\$video_file\" >> /root/.peertube_uploaded";
113
       echo "                    echo \"\$video_file\" >> /root/.peertube_uploaded";
105
       echo "                    sed -i \"/\$video_file/d\" /root/.peertube_uploading";
114
       echo "                    sed -i \"/\$video_file/d\" /root/.peertube_uploading";
106
       echo "                    exit 0";
115
       echo "                    exit 0";
242
     peertubensfw=$(sed -n 4p < "$data2")
251
     peertubensfw=$(sed -n 4p < "$data2")
243
     rm -f "$data2"
252
     rm -f "$data2"
244
 
253
 
245
-    peertubedomain="http://localhost:${PEERTUBE_PORT}"
254
+    peertubedomain="https://$PEERTUBE_DOMAIN_NAME"
255
+    nodecmd='node'
256
+
257
+    if [[ "$ONION_ONLY" != 'no' ]]; then
258
+        peertubedomain="http://$(cat /var/lib/tor/hidden_service_peertube/hostname)"
259
+        nodecmd='torsocks node'
260
+    fi
246
 
261
 
247
     data2=$(mktemp 2>/dev/null)
262
     data2=$(mktemp 2>/dev/null)
248
     dialog --title "Choose the video file (select with spacebar)" --fselect "/home/$MY_USERNAME/" 30 60 2> "$data2"
263
     dialog --title "Choose the video file (select with spacebar)" --fselect "/home/$MY_USERNAME/" 30 60 2> "$data2"
270
         nsfwstr='--nsfw'
285
         nsfwstr='--nsfw'
271
     fi
286
     fi
272
 
287
 
273
-    titlestr=
288
+    titlestr=$(basename "$selected_file" | awk -F '.' '{print $1}' | sed 's|_| |g' | sed 's|-| |g')
274
     if [ "$peertubetitle" ]; then
289
     if [ "$peertubetitle" ]; then
275
         titlestr="-n \"$peertubetitle\""
290
         titlestr="-n \"$peertubetitle\""
276
     fi
291
     fi
277
 
292
 
278
     clear
293
     clear
279
-    node $import_script $nsfwstr "$titlestr" -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -f "$selected_file"
294
+    $nodecmd $import_script $nsfwstr "$titlestr" -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -f "$selected_file"
280
 
295
 
281
     dialog --title $"Import video from file" \
296
     dialog --title $"Import video from file" \
282
            --msgbox $"Video imported from $selected_file" 6 75
297
            --msgbox $"Video imported from $selected_file" 6 75
307
     video_url=$(sed -n 3p < "$data2")
322
     video_url=$(sed -n 3p < "$data2")
308
     rm -f "$data2"
323
     rm -f "$data2"
309
 
324
 
310
-    peertubedomain="http://localhost:${PEERTUBE_PORT}"
325
+    peertubedomain="https://$PEERTUBE_DOMAIN_NAME"
326
+    nodecmd='node'
327
+
328
+    if [[ "$ONION_ONLY" != 'no' ]]; then
329
+        peertubedomain="http://$(cat /var/lib/tor/hidden_service_peertube/hostname)"
330
+        nodecmd='torsocks node'
331
+    fi
311
 
332
 
312
     if [ ${#peertubeuser} -lt 3 ]; then
333
     if [ ${#peertubeuser} -lt 3 ]; then
313
         dialog --title $"Import videos from legacy sites" \
334
         dialog --title $"Import videos from legacy sites" \
342
     fi
363
     fi
343
 
364
 
344
     clear
365
     clear
345
-    node $import_script -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -t "$video_url"
366
+    $nodecmd $import_script -u "$peertubedomain" -U "$peertubeuser" --password "$peertubepassword" -t "$video_url"
346
 
367
 
347
     dialog --title $"Import videos from legacy sites" \
368
     dialog --title $"Import videos from legacy sites" \
348
            --msgbox $"Video/s imported from $video_url" 6 75
369
            --msgbox $"Video/s imported from $video_url" 6 75

+ 3
- 3
src/freedombone-syncthing Wyświetl plik

113
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
113
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
114
                 echo "" > $TEMP_IDS_FILE
114
                 echo "" > $TEMP_IDS_FILE
115
                 while read -r line || [[ -n "$line" ]]; do
115
                 while read -r line || [[ -n "$line" ]]; do
116
-                    line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
116
+                    line2=$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
117
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
117
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
118
                         if [ ${#line2} -gt 10 ]; then
118
                         if [ ${#line2} -gt 10 ]; then
119
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
119
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
150
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
150
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
151
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
151
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
152
                 while read -r line || [[ -n "$line" ]]; do
152
                 while read -r line || [[ -n "$line" ]]; do
153
-                    line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
153
+                    line2=$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
154
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
154
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
155
                         if [ ${#line2} -gt 10 ]; then
155
                         if [ ${#line2} -gt 10 ]; then
156
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
156
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
189
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
189
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
190
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
190
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
191
                 while read -r line || [[ -n "$line" ]]; do
191
                 while read -r line || [[ -n "$line" ]]; do
192
-                    line2="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
192
+                    line2=$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
193
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
193
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
194
                         if [ ${#line2} -gt 10 ]; then
194
                         if [ ${#line2} -gt 10 ]; then
195
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
195
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then