Last active
March 17, 2019 12:16
-
-
Save josuecau/bb176d1eb65e8992ada92333a329a3cd to your computer and use it in GitHub Desktop.
Select .torrent file to upload to seed box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Description: Select .torrent file to upload to seed box. | |
# Usage: $ seedbox | |
# Author: Josué CAU <[email protected]> | |
# Version: v0.1.1 | |
# Dependencies: fzf(1) | |
# Env: SEEDBOX_ADDRESS | |
set -e | |
if [ -z "$SEEDBOX_ADDRESS" ]; then | |
echo 'Environment variable SEEDBOX_ADDRESS must be set' | |
exit 1 | |
fi | |
dir="$HOME/Downloads" | |
remote="$SEEDBOX_ADDRESS/watch" | |
listing () { | |
find "$dir" -type f -name '*.torrent' -print0 \ | |
| xargs -0 basename -s '.torrent' \ | |
| sort \ | |
| fzf --exit-0 | |
} | |
choice=$(listing) | |
torrent="$dir/$choice.torrent" | |
filetype=$(file -b --mime-type "$torrent") | |
if [ "$filetype" != 'application/x-bittorrent' ]; then | |
echo "Unexpected file type: $filetype" | |
exit 1 | |
fi | |
scp "$torrent" "$remote" | |
mv "$torrent" "$torrent.backup" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment