servo: transmission: torrent-done: fix typos and add a TR_DEBUG option
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
# transmission invokes this with no args, and the following env vars:
|
# transmission invokes this with no args, and the following env vars:
|
||||||
# - TR_TORRENT_DIR: full path to the folder i told transmission to download it to.
|
# - TR_TORRENT_DIR: full path to the folder i told transmission to download it to.
|
||||||
# e.g. /var/media/torrents/Videos/Film/Jason.Bourne-2016
|
# e.g. /var/media/torrents/Videos/Film/Jason.Bourne-2016
|
||||||
# optionally, perform a dry run by setting TR_DRY_RUN=1
|
# optionally:
|
||||||
|
# - TR_DRY_RUN=1
|
||||||
|
# - TR_DEBUG=1
|
||||||
|
|
||||||
DOWNLOAD_DIR=/var/media/torrents
|
DOWNLOAD_DIR=/var/media/torrents
|
||||||
|
|
||||||
@@ -15,6 +17,12 @@ destructive() {
|
|||||||
"$@"
|
"$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
debug() {
|
||||||
|
if [ -n "${TR_DEBUG-}" ]; then
|
||||||
|
echo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "$TR_TORRENT_DIR" =~ ^.*freeleech.*$ ]]; then
|
if [[ "$TR_TORRENT_DIR" =~ ^.*freeleech.*$ ]]; then
|
||||||
# freeleech torrents have no place in my permanent library
|
# freeleech torrents have no place in my permanent library
|
||||||
echo "freeleech: nothing to do"
|
echo "freeleech: nothing to do"
|
||||||
@@ -36,8 +44,10 @@ destructive find "$MEDIA_DIR" -type d -exec chmod g+rw,a+rx {} \;
|
|||||||
|
|
||||||
# if there's a single directory inside the media dir, then inline that
|
# if there's a single directory inside the media dir, then inline that
|
||||||
subdirs=("$MEDIA_DIR"/*)
|
subdirs=("$MEDIA_DIR"/*)
|
||||||
if [ ${#subdirs} -eq 1 ]; then
|
debug "top-level items in torrent dir:" "${subdirs[@]}"
|
||||||
|
if [ ${#subdirs[@]} -eq 1 ]; then
|
||||||
dirname="${subdirs[0]}"
|
dirname="${subdirs[0]}"
|
||||||
|
debug "exactly one top-level item, checking if directory: $dirname"
|
||||||
if [ -d "$dirname" ]; then
|
if [ -d "$dirname" ]; then
|
||||||
destructive mv "$dirname"/* "$MEDIA_DIR/" && destructive rmdir "$dirname"
|
destructive mv "$dirname"/* "$MEDIA_DIR/" && destructive rmdir "$dirname"
|
||||||
fi
|
fi
|
||||||
@@ -47,7 +57,7 @@ fi
|
|||||||
destructive find "$MEDIA_DIR/" -type f \(\
|
destructive find "$MEDIA_DIR/" -type f \(\
|
||||||
-iname '.*downloaded.?from.*' \
|
-iname '.*downloaded.?from.*' \
|
||||||
-o -iname 'source.txt' \
|
-o -iname 'source.txt' \
|
||||||
-o 'iname 'upcoming.?releases.*' \
|
-o -iname 'upcoming.?releases.*' \
|
||||||
-o -iname 'www.YTS.*.jpg' \
|
-o -iname 'www.YTS.*.jpg' \
|
||||||
-o -iname 'WWW.YIFY*.COM.jpg' \
|
-o -iname 'WWW.YIFY*.COM.jpg' \
|
||||||
-o -iname 'YIFY*.com.txt' \
|
-o -iname 'YIFY*.com.txt' \
|
||||||
|
Reference in New Issue
Block a user