]> Cypherpunks.ru repositories - nncp.git/commitdiff
Example aria2c hook for downloaded torrents
authorSergey Matveev <stargrave@stargrave.org>
Tue, 13 Feb 2018 12:51:56 +0000 (15:51 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 13 Feb 2018 12:51:56 +0000 (15:51 +0300)
doc/integration.texi

index c27cb363afdf6852642817bb1e99da1fd2196142..9011ed70cc2089a073b3c993e81f191eb56667a4 100644 (file)
@@ -250,12 +250,32 @@ You can queue you files after they are completely downloaded:
 @verbatim
 % cat send-downloaded.sh
 #!/bin/sh
-nncp-file -chunked $(( 1024 * 100 )) "$3" remote.node
+
+if [ "$2" -eq 0 ]; then
+    # This could be downloaded .torrent file itself
+    exit 0
+fi
+
+if [ "$2" -gt 1 ]; then
+    # This is directory downloaded with BitTorrent
+    wholedir="$(dirname "$3")"
+    name=$(basename "$wholedir")
+    cd "$wholedir"/..
+    tartmp=$(mktemp ./finished.XXXXXX)
+    tar cf $tartmp "$name"
+    nncp-file -chunked $(( 1024 * 100 )) $tartmp remote:"$name".tar
+    rm $tartmp
+else
+    nncp-file -chunked $(( 1024 * 100 )) "$3" remote:
+fi
 
 % aria2c \
     --on-download-complete send-downloaded.sh \
     http://example.org/file.iso \
     http://example.org/file.iso.asc
+% aria2c \
+    --on-bt-download-complete send-downloaded.sh \
+    http://example.org/file.torrent
 @end verbatim
 
 Also you can prepare