[pvr] Minor recording fixes

This is a collection of things I found while investigating another thing. It's mostly minor refactoring and cleanup, though the first commit adds a missing call to db.Close() which I guess could actually fix something. If you want me to split that one out I can do that.