瀏覽代碼

Fixing peertube video sync

Bob Mottram 7 年之前
父節點
當前提交
30f6c1fc58
共有 2 個文件被更改,包括 31 次插入10 次删除
  1. 28
    7
      src/freedombone-app-peertube
  2. 3
    3
      src/freedombone-syncthing

+ 28
- 7
src/freedombone-app-peertube 查看文件

@@ -55,6 +55,14 @@ peertube_variables=(PEERTUBE_DOMAIN_NAME
55 55
                     MY_EMAIL_ADDRESS)
56 56
 
57 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 66
     { echo '#!/bin/bash';
59 67
       echo '';
60 68
       echo "MY_USERNAME=\$(cat /root/${PROJECT_NAME}.cfg | grep MY_USERNAME | awk -F '=' '{print \$2}')";
@@ -71,7 +79,7 @@ function peertube_import_from_syncthing {
71 79
       echo '    exit 0';
72 80
       echo 'fi';
73 81
       echo '';
74
-      echo "peertubedomain=\"http://localhost:${PEERTUBE_PORT}\"";
82
+      echo "peertubedomain=\"$peertubedomain\"";
75 83
       echo "peertubeuser=\$(sed -n 1p < \"\$search_dir/login.txt\")";
76 84
       echo "peertubepassword=\$(sed -n 2p < \"\$search_dir/login.txt\")";
77 85
       echo 'peertubensfw=';
@@ -100,7 +108,8 @@ function peertube_import_from_syncthing {
100 108
       echo "        if ! grep \"\$video_file\" /root/.peertube_uploaded; then";
101 109
       echo "            if ! grep \"\$video_file\" /root/.peertube_uploading; then";
102 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 113
       echo "                    echo \"\$video_file\" >> /root/.peertube_uploaded";
105 114
       echo "                    sed -i \"/\$video_file/d\" /root/.peertube_uploading";
106 115
       echo "                    exit 0";
@@ -242,7 +251,13 @@ function peertube_import_from_file {
242 251
     peertubensfw=$(sed -n 4p < "$data2")
243 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 262
     data2=$(mktemp 2>/dev/null)
248 263
     dialog --title "Choose the video file (select with spacebar)" --fselect "/home/$MY_USERNAME/" 30 60 2> "$data2"
@@ -270,13 +285,13 @@ function peertube_import_from_file {
270 285
         nsfwstr='--nsfw'
271 286
     fi
272 287
 
273
-    titlestr=
288
+    titlestr=$(basename "$selected_file" | awk -F '.' '{print $1}' | sed 's|_| |g' | sed 's|-| |g')
274 289
     if [ "$peertubetitle" ]; then
275 290
         titlestr="-n \"$peertubetitle\""
276 291
     fi
277 292
 
278 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 296
     dialog --title $"Import video from file" \
282 297
            --msgbox $"Video imported from $selected_file" 6 75
@@ -307,7 +322,13 @@ function peertube_import_videos {
307 322
     video_url=$(sed -n 3p < "$data2")
308 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 333
     if [ ${#peertubeuser} -lt 3 ]; then
313 334
         dialog --title $"Import videos from legacy sites" \
@@ -342,7 +363,7 @@ function peertube_import_videos {
342 363
     fi
343 364
 
344 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 368
     dialog --title $"Import videos from legacy sites" \
348 369
            --msgbox $"Video/s imported from $video_url" 6 75

+ 3
- 3
src/freedombone-syncthing 查看文件

@@ -113,7 +113,7 @@ function create_syncthing_config {
113 113
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
114 114
                 echo "" > $TEMP_IDS_FILE
115 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 117
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
118 118
                         if [ ${#line2} -gt 10 ]; then
119 119
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
@@ -150,7 +150,7 @@ function create_syncthing_config {
150 150
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
151 151
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
152 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 154
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
155 155
                         if [ ${#line2} -gt 10 ]; then
156 156
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then
@@ -189,7 +189,7 @@ function create_syncthing_config {
189 189
         if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
190 190
             if [ -f "/home/$USERNAME/$SYNCTHING_USER_IDS_FILE" ]; then
191 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 193
                     if [[ $line2 != *"#"* && $line2 != *"*"* && $line2 != *'/'*  && $line2 == *"-"* ]]; then
194 194
                         if [ ${#line2} -gt 10 ]; then
195 195
                             if ! grep -q "$line2" $TEMP_IDS_FILE; then