Hi Jan,
python is a bit "different" if you're not used to it
But: In your error message you may notice the last two lines:
File "<string>", line 59, in parse_index
UnboundLocalError: local variable 'title' referenced before assignment
This refers to your script. In line 59 you use a variable "title", and python complains that there is no value assigned. You wanted to assign something two lines earlier, so my guess is that the "if" condition was actually false. Try to start debugging there.
Best reagrds,
Bernd