Created
May 12, 2015 16:09
-
-
Save jonjensen/402c9a3b1803dcf764bc to your computer and use it in GitHub Desktop.
Decode Google Earth settings pseudo-URL Unicode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python2 | |
import fileinput | |
import re | |
import urllib | |
def decode_ucs(matchobj): | |
c = matchobj.group(0)[2:] | |
i = int(c, 16) | |
return unichr(i) | |
for line in fileinput.input(): | |
url = re.sub('_', '/', line) | |
url = re.sub(r'\\', '', url) | |
url = urllib.unquote(url).decode('utf8') | |
url = re.sub('%U[A-F0-9]{4}', decode_ucs, url) | |
description = re.sub('^http://kh.google.com:80/', '', url) | |
print(line + description) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment