Friday, 9 November 2007

Installing SABnzbd on Ubuntu Gutsy Gibbon

SABnzbd does a great job of easing the pain of leveraging Newzbin NZB files for liberating compressed multi-part binaries from Usenet. This short guide details the process of installing the latest version of SABnzbd on Ubuntu 7.10 Gutsy Gibbon. Although we'll rely on packages available in the official Ubuntu apt repositories for this how-to it's worth noting that if you're using either Debian Etch or an older release of Ubuntu that the install process is the same. Copy and paste these commands into a terminal for usenet.

Installing dependencies with apt-get

$ sudo apt-get install python2.5 python-cheetah python-cherrypy unzip par2 unrar python-yenc python-feedparser wget


Getting and installing SABnzbd from source
$ cd ~/
$ wget http://surfnet.dl.sourceforge.net/sourceforge/sabnzbd/SABnzbd-0.2.5.tar.gz
$ tar xfvz SABnzbd-0.2.5.tar.gz
$ cd SABnzbd-0.2.5/
$ sudo python setup.py install


Making working directories and moving things into place

Here we'll make a couple of directories in our home folder that SABnzbd can use to do it's work.
$ mkdir ~/usenet/complete/ -p
$ mkdir ~/usenet/session/
$ mkdir ~/usenet/watch/

We also need to copy the web interface templates from the source files we extracted
$ mv templates/ ~/usenet/


Final configuration

To finsh the setup lets copy and rename the SABnzbd.ini.sample configuration file in the source to the root of our home directory and edit it with nano.
$ mv SABnzbd.ini.sample ~/.sajavascript:void(0)bnzbd.ini
$ nano ~/.sabnzbd.ini

Here what your sabnzbd.ini may end up looking like:
__version__ = 016

[misc]
## host we should listen on, leave "" for localhost
host = ""

## port we should listen on
port = 8080

## username for the web-interface
username = ""

## password for the web-interface
password = ""

## web file dir for (custom) Cheetah templates and the default.css file
web_dir = "/path/to/usenet/templates"

## dir to put downloads to, won't be created automatically
download_dir = "/path/to/usenet/session"

## dir to put completed downloads to, won't be created automatically
complete_dir = "/path/to/usenet/complete"

## If specified, .nzbs fetched by postid (or added by the dirscanner) will
## be backed up to this readable/writeable dir
nzb_backup_dir = ""

## dir to store cache and cookie files, windows users should
## leave this at .
cache_dir = "/path/to/media/usenet/session"

## location of your log directory, "" to disable logging
log_dir = "/path/to/usenet/session"

## dirscan directory
## SABnzbd will consume everything in that dir
## while trying to add it to the queue
dirscan_dir = "/path/to/usenet/watch"

## Scheduling options
## Syntax: minute hour day action
## 1st argument must be 0-59 (minute)
## 2nd argument must be 0-24 (hour)
## 3rd argument must be 1-7 (day) or *
## 4th argument must be resume or pause
##
## e.g schedlines = 0 7 * pause, 0 21 * resume
## to pause SABnzbd at 7:00 and resume operation at 21:00
schedlines = ,

## default options for dirscan added items
## 0 = None
## 1 = +Repair
## 2 = +Unpack
## 3 = +Delete
dirscan_opts = 3

## Enable/disable filejoining
## 0 = Disabled
## 1 = Enabled
enable_filejoin = 1

## Enable/disable unraring
## 0 = Disabled
## 1 = Enabled
enable_unrar = 1

## Enable/disable unzipping
## 0 = Disabled
## 1 = Enabled
enable_unzip = 1

## Enable/disable periodic queue saving
## 0 = Disabled
## 1 = Enabled
## Enable this on unstable systems
enable_save = 1

## Enable/disable
## 0 = Disabled
## 1 = Enabled
## Enable to cleanup par2 files
## (only if verifiying/repairing succeded)
enable_par_cleanup = 1

## should we failover on yenc crc errors
## 0 = no
## 1 = yes
fail_on_crc = 0

## should we download to group folders?
## (i.e /my/download/dir/alt.bin.whatever/somepost/)
## 0 = no
## 1 = yes
create_group_folders = 0

## bandwith limit
## 0 == ignore
## Slowdown factor, try values between 0.01 and 1.0.
bandwith_limit = 0

## Cleanup List
## List of file_extensions that should be deleted
## Example: ".nfo," or ".nfo, .sfv"
cleanup_list = ,

## Only get articles from topmost collection
## Enable for less memory usage
## Disable for more efficient downloading
## 0 = Disabled
## 1 = Enabled
top_only = 1

## Automatically sort by average age
## 0 = No
## 1 = Yes
auto_sort = 0

## Send group command before requesting articles
## 0 = No
## 1 = Yes
send_group = 0

## Article cache limit
## 0 = Disable Cache
## -1 = Unlimited cache
## >0 = Maximum memory (in bytes) to use for cache
cache_limit = 0

## Umask to use for directories/files
umask = 755

[logging]
## max size of SABnzbd.log (in bytes)
max_log_size = 5242880

## how many backups of SABnzbd.log to keep around
log_backups = 5

## enable cherrypy logging
## 0 = no
## 1 = yes
enable_cherrypy_logging = 1

## Fill in your servers here
## If your server doesn't need password auth set
## username and password to ''
## fillserver field must be 0 for non-fillservers (>0 otherwise)
[servers]
[[server 0]]
host = news.ngroups.net
port = 119
username =
password =
connections = 8
fillserver = 0
# [[server 1]]
# host = news.myfillserver.com
# port = 119
# username = ""
# password = ""
# connections = 8
# fillserver = 1

## www.newzbin.com support
[newzbin]
username = "username"
password = "password"

## Place downloads into newzbin.com category folders
## 0 = No
## 1 = Root category only
## 2 = Root category + subcategory
create_category_folders = 0


Test drive
Lets try and start SABnzbd
$ SABnzbd.py -f ~/.sabnzbd.ini

Now navigate to http://localhost:8080/sabnzbd and you should reach the web interface. If you don't then take a look at the output on the terminal and see if SABnzbd is complaining about not being able to find some of the working directories, you may need to go back and double check the paths you set in the sabnzbd.ini

The final countdown

If everything went okay with the test drive shutdown SABnzbd and restart it with the -d switch:
$ SABnzbd.py -f ~/.sabnzbd.ini -d

This will set SABnzbd running in background daemon mode. You can now close your terminal window and SABnzbd will continue to run in the background until you shut it down from the web interface.

Tuesday, 6 November 2007

Installing MPlayer with MacPorts on Mac OS X 10.5.0 Leopard

MPlayer is a great media player app. It features codecs that will decode the majority of video and audio you'll find on the internet today, and with the bundled mencoder encoder you get a complete solution for media playback, transcoding and compression on your UNIX-like desktop or server.

The Problem
If you are a Mac OS X Leopard early adopter who has previously relied on the macports package manager to install and update MPlayer you may be feeling slightly hard-done-by right now, that's because MPlayer cannot currently be installed with out-of-the-box Macports 1.5 on leopard. In fact, macports won't even begin to build the MPlayer sources because the lzo2 dependency fails to compile, and even if you do have a working lzo2 installation MPlayer itself will fail to build. This is apparently x86 specific and is caused by problems building MMX and SSE assembly code.

The Solution
The short answer? Download and install the GUI MPlayer OS X 1.0rc1 OSX binaries provided at the mplayer download page. It's not as powerful as the cli version, but for simple playback of media files it's pretty great.

The long answer? Thankfully the lzo2 portfile in the latest development revisions of macports has been fixed for 10.5, you can substitute this new file for the unusable one, and afterwards edit the MPlayer portfile to disable compile options that cause the build to fail ...

In the Terminal
If you've already tried to build MPlayer with macports and the installation has failed at building lzo2 we'll first remove the evidence of that:

$ sudo rm -rf /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_archivers_lzo2/


Lets navigate to the location of the current lzo2 Portfile and rename it.
$ cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/archivers/lzo2/
$ sudo mv Portfile Portfile.old


Now, become superuser and grab the development lzo2 portfile from the macports project website.
$ sudo -s
# curl http://trac.macports.org/projects/macports/browser/trunk/dports/archivers/lzo2/Portfile?format=raw >> Portfile
# exit


Now lets go ahead and build that pesky dependency
$ sudo port install lzo2
---> Fetching lzo2
---> Verifying checksum(s) for lzo2
---> Extracting lzo2
---> Configuring lzo2
---> Building lzo2 with target all
---> Staging lzo2 into destroot
---> Installing lzo2 2.02_2+darwin_9
---> Activating lzo2 2.02_2+darwin_9
---> Cleaning lzo2

SUCCESS!

But we're only half-way there. We still have to build and install MPlayer itself.

If you've already attempted to build MPlayer with macports remove the old build files
$ sudo rm -rf /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_multimedia_MPlayer/ports_multimedia_MPlayer/


Install the lzop dependancy
$ sudo port install lzop


Now navigate to the Mplayer Portfile directory open the portfile with a text editor
$ cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/multimedia/mplayer
$ nano Portfile


...and edit the "configure.args-append" section by appending the following onto it
--disable-mmx --disable-sse --disable-xinerama


Now lets build and install MPlayer
$ sudo port install mplayer
Portfile changed since last build; discarding previous state.
---> Fetching MPlayer
---> Verifying checksum(s) for MPlayer
---> Extracting MPlayer
---> Applying patches to MPlayer
---> Configuring MPlayer
---> Building MPlayer with target all
---> Staging MPlayer into destroot
---> Installing MPlayer 1.0rc1try3_0+darwin_i386+macosx
---> Activating MPlayer 1.0rc1try3_0+darwin_i386+macosx
---> Cleaning MPlayer

$ mplayer
MPlayer 1.0rc1-4.0.1 (C) 2000-2006 MPlayer Team
CPU: Genuine Intel(R) CPU 1400 @ 1.83GHz (Family: 6, Model: 14, Stepping: 8)
MMX supported but disabled
MMX2 supported but disabled
SSE supported but disabled
CPUflags: MMX: 0 MMX2: 0 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 1
Compiled for x86 CPU with extensions: SSE2
...

ITS ALIVE!

And there we have it, working MPlayer on Leopard with MacPorts. Having said that, the installation may be sluggish without the MMX and SSE code, your mileage and performance may vary. Let's cross our fingers that this will all be fixed in the next milestone release of Macports.