PKGBUILDs/aur/sabnzbd/addnzb.sh

15 lines
755 B
Bash
Raw Normal View History

2011-05-17 22:02:46 +00:00
#!/bin/bash
2011-10-23 19:30:03 +00:00
set -a # export all variables
2011-05-17 22:02:46 +00:00
. /etc/conf.d/sabnzbd
# SABnzbd must be able to read the file, so we copy it to a directory where it
# certainly has rights.
2011-10-23 19:30:03 +00:00
nzbname=$(basename "$1")
2011-05-17 22:02:46 +00:00
TEMP_NZB="/var/tmp/$nzbname"
2011-10-23 19:30:03 +00:00
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"
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"])')
rm "$TEMP_NZB"
2011-05-17 22:02:46 +00:00
exit 0