]> git.rmz.io Git - dotfiles.git/blob - bin/addnzb
alias: only set vim function in VIM_TERMINAL
[dotfiles.git] / bin / addnzb
1 #!/bin/sh
2
3 set -e
4
5 source $XDG_CONFIG_HOME/sabnzbd/config
6
7 version="0.1"
8
9 function usage ()
10 {
11 echo "Usage : $0 [options]
12
13 Options:
14 --category Sets the category
15 -h,--help Display this message
16 -v,--version Display script version"
17 }
18
19 # Parse arguments
20 declare -a args
21 while [[ $# -gt 0 ]]; do
22 opt="$1"
23
24 case $opt in
25 -h|--help) usage; exit 0 ;;
26 -v|--version) echo "$0 -- Version $version"; exit 0 ;;
27 --category) category=$2; shift 2 ;;
28 -* )
29 echo -e "\n Option does not exist : $opt\n"
30 usage; exit 1 ;;
31
32 *) args+=("$opt"); shift ;;
33 esac
34 done
35
36 if [[ -n $category ]]; then
37 extra_data="-F cat=$category"
38 fi
39
40 for f in ${args[@]}; do
41 curl -s -F apikey="$API_KEY" -F mode="addfile" -F name=@"$f" $extra_data $URL/sabnzbd/api &> /dev/null
42 if [[ $? -eq 0 ]]; then
43 echo "Uploaded '$f'"
44 rm $f
45 else
46 echo "Failed to upload '$f'"
47 fi
48 done