updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / sabnzbd / addnzb.sh
blob47031c6da01c1b208ebc21ae2e18c668ed7ce9c2
1 #!/bin/bash
2 set -a # export all variables
4 . /etc/conf.d/sabnzbd
6 # SABnzbd must be able to read the file, so we copy it to a directory where it
7 # certainly has rights.
8 nzbname=$(basename "$1")
9 TEMP_NZB="/var/tmp/$nzbname"
11 curl -s $(python2 -c 'import urlparse,urllib,sys; print sys.argv[1] if urlparse.urlparse(sys.argv[1]).scheme else urlparse.urlparse(urllib.pathname2url(sys.argv[1]),"file").geturl()' "$1") -o "$TEMP_NZB"
12 curl -f $(python2 -c 'import urllib,os; print os.environ["SABNZBD_PROTOCOL"]+"://"+urllib.quote(os.environ["SABNZBD_USPW"]+os.environ["SABNZBD_IP"])+":"+os.environ["SABNZBD_PORT"]+"/sabnzbd/api?mode=addlocalfile&name="+urllib.quote(os.environ["TEMP_NZB"])+"&apikey="+urllib.quote(os.environ["NZB_KEY"])')
13 rm "$TEMP_NZB"
14 exit 0