]> git.rmz.io Git - dotfiles.git/blob - bin/addnzb
nvim: stick to bufferline keymaps
[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 # set priority to high
37 extra_data=(-F priority=1)
38 if [[ -n $category ]]; then
39 extra_data+=(-F cat=$category)
40 fi
41
42 for f in ${args[@]}; do
43 curl --silent --show-error \
44 $URL/sabnzbd/api \
45 -F apikey="$API_KEY" \
46 -F mode="addfile" \
47 -F name="@$f" \
48 "${extra_data[@]}"
49 if [[ $? -eq 0 ]]; then
50 echo "Uploaded '$f'"
51 rm $f
52 else
53 echo "Failed to upload '$f'"
54 fi
55 done