sjp/GOMstreamer — pull request #11 by fj128 (2011-11-30 12:10:08+00:00)
Title: Support for alternative streams + various general improvements.

Hi!

GOMtv now usually has two code-A streams (for instance, at the moment of writing it's Khaldor on one and Wolf&Doa on another), so I added the ability to select a stream, but in the process got somewhat carried away and touched a lot of code...

So, first of all I finally did the thing that I wanted to do since forever, now there's a generator `iteratePossibleLivePageURLs` that provides possible Live page urls, and a loop that wraps all the following processing in a try/catch block and tries the next url if an error occurs at any point.

Live page url candidates currently are: `/main/goLive.gom`, the target of the 'Live' button on the main page, the contents of the `season.txt` on your server.

If `-a/--alternative-stream N` is specified, then the 'Live' button is examined first, it might have multiple targets, the N-th is selected (if N > number of targets, then the last one is selected).

While I was working on it I also had to replace all `sys.exit()` calls with (re)throwing of an exception obviously. And add some more try/catch blocks. And while doing that, I decided to channel all output through `logging`, dump all stuff >= logging.INFO to stdout, and all stuff together to `gomstreamer.log` if `debug` is specified. Because raw html dumps were really distracting, but a separate log file without all the stuff that was simply `print`ed was confusing. It's not ideal, it can be improved by adding a custom formatter that would omit stack traces when printing to stdout, but that's not a priority I think.

And that's it, basically. I've checked that it works on most normal paths and some error paths, but not exhaustively, so it would be nice if you read my changes with a fresh eye. Also, I haven't updated the README. Also, I modified all launcher scripts to pass any parameters to the program, so I can use `play.cmd -a 1` for example.