Friday, February 19, 2010

SABnzbd Java API

For all you SABnzbd fans, i've got a real treat for you. I've just put together a Java API (must admit didn't take long) to support various functions that SABnzbd supports. Here is a sneak preview of what you will be able to do with the API:



String[] nzbs =
{"http://www.newzbin.com/browse/post/5569239/nzb",
"http://www.newzbin.com/browse/post/5568352/nzb"};

String sabURL= "http://sabserverurl";
SABnzbd mySabServer= new SABnzbd(sabURL, "uname", "pwd");

System.out.println("Current download speed: " + mySabServer.getDownloadSpeed());

for(String nzb: nzbs)
{
mySabServer.download(nzb);
}

List queue = mySabServer.getQueue();

if (queue.isEmpty()) {
System.out.println("No download entries");
} else {
for (QueueEntry qu : queue) {
System.out.println("---- New Entry --- ");
System.out.println("Category: " + qu.getCategory());
System.out.println("Name: " + qu.getName());
System.out.println("Reamining " + qu.getRemain());
System.out.println("Total:" + qu.getTotal());
System.out.println("ETA: " + qu.getEta());
}
}