Fix for invalidly formed NZB files (patch included)
Posted: February 15th, 2008, 12:47 am
I've recently had an issue with certain NZB files from a forum I frequent. Depending on the size of the NZB, the spooler software will deliver either a RAR or a raw NZB file. It's a pretty neat utility, save that I have to extract the RAR files before SABnzbd+ will accept the files into the blackhole. (The new GZ and ZIP support is awesome by the way!)
The main issue is that the spooler adds a custom DOCTYPE tag that contains square brackets. According to the built-in XML parser, this is an invalid token and the NZB file just disappears with an exception in the logfile. I'd thought about writing a separate utility to handle this case, but figured others might be using even more sketchily-written NZB spooler software and that the main program should at least have an option to handle things.
I've attached a patch that does a regex replace for the DOCTYPE tag in the NZB file. It's not exactly the most efficient way of handling things, but it seems to fix my specific issue. I've only tested it with a stub launcher - the entire SABnzbd+ app doesn't seem to want to compile under PyDev on Win32, which is probably my stupid fault for running Win32 anyways. Also, please don't shoot me if this code is crap, as I've only briefly looked at Python before; I'm more of a PHP/MySQL guy.
Other devs: Please let me know what you think - this is probably something that should be set with a global preference, but I didn't want to go changing code all over the place in the event that this was a "you suck and shouldn't waste your time" issue.
The main issue is that the spooler adds a custom DOCTYPE tag that contains square brackets. According to the built-in XML parser, this is an invalid token and the NZB file just disappears with an exception in the logfile. I'd thought about writing a separate utility to handle this case, but figured others might be using even more sketchily-written NZB spooler software and that the main program should at least have an option to handle things.
I've attached a patch that does a regex replace for the DOCTYPE tag in the NZB file. It's not exactly the most efficient way of handling things, but it seems to fix my specific issue. I've only tested it with a stub launcher - the entire SABnzbd+ app doesn't seem to want to compile under PyDev on Win32, which is probably my stupid fault for running Win32 anyways. Also, please don't shoot me if this code is crap, as I've only briefly looked at Python before; I'm more of a PHP/MySQL guy.
Other devs: Please let me know what you think - this is probably something that should be set with a global preference, but I didn't want to go changing code all over the place in the event that this was a "you suck and shouldn't waste your time" issue.