[Download] custom automation script for SABnzbd downloading


Recommended Posts

This is my first script in python and thought it might be useful to others as well. I chose python since it is already installed with SABnzbd. Please let me know if you find this useful, have any tips, bugs, etc. I've been using it for a few weeks with no issues so far.

 

The only decent broadband in my town is capped at 50GB which is not a lot if you download much.

However my ISP does not count bandwidth from 12AM to 8AM. I frequently use SABnzbd on my unraid box to download.

I have tomato firmware on my router and have it set up to wake up my unraid box at midnight. After that this script takes over:

 

1. I used the go script instead of a cronjob because some servers take longer than others to start. If the hour is 12:XXAM

it continues, else it quits. That way it won't interfere with daily use and if the server turns on at 12:00 but isn't completely

ready until 12:01 or 12:04 or even 12:59, it will still run the script. I could have done this with a cronjob but this just seemed

better to me.

2. Waits for 2 minutes to load files from the watch folder or for files to be passed to it from other programs like Sickbeard.

3. Starts a loop. If it is 8:00AM it shutsdown (make sure powerdown script is installed).

4. If it is not 8:00AM then it checks if the queue is empty and the history is empty (in other words, idle).

5. If SABnzbd isn't downloading anything and the history isn't moving, extracting, reapairing, etc, then it shuts down. I know

you can tell SABnzbd to shutdown while the history is still processing and it will just wait for it to finish but I wrote in

a check anyway.

 

In short, once the script runs and it is indeed midnight it starts a loop that continually (well every 10 seconds) checks to see if

SABnzbd is idle or if it is 8AM yet. It will safely shutdown unraid if either of those conditions are met, provided you have

the powerdown script installed.

 

Add this file to the root of your flash, make SURE you have the powerdown script installed, and add this line to your go script:

 

python /boot/sabnzbd_powerdown.py

 

You will also have to change lines 43 and 48 of this script to the proper URL and api key of your setup of SABnzbd. I also have SABnzbd set to start paused and unpause at midnight.

sabnzbd_shutdown.zip

Link to comment

if you go to the menu there should be a scheduler option. you can have it run terminal commands at a specific time. i dont remember the actual command for wol off the top of my head but i think it was just "wakeonlan" followed by the mac address of the server. so something like this:

 

wakeonlan de:ad:be:ef:ca:fe

 

of course you need to make sure your server is set up for WOL in the bios and everything. if you arent familiar with wake-on-lan let me know if you have any questions.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.