In one of my projects I'm using cgi.escape() to escape a set of titles that I get from a resource. These titles could be from Youtube or anywhere else, and may need to be escaped. 
The issue I'm having is that if a title is already escaped from Youtube and I pass it into cgi.escape(), I end up getting double-escaped titles, which is messing up later parts of my project.
Is there a library that will escape strings but check if a piece is already escaped, and ignore it?
If you know your input is already escaped, unescape it first. Then later escape it just before where it needs to be.
Escaping characters in Python, but ignoring already escaped characters