forked from organicmaps/organicmaps
[crawler] Add script to do manual renames.
This commit is contained in:
parent
9ac54155a6
commit
704b2fe733
1 changed files with 18 additions and 0 deletions
18
crawler/wikitravel-manual-rename.py
Executable file
18
crawler/wikitravel-manual-rename.py
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/opt/local/bin/python
|
||||
import hashlib
|
||||
import json
|
||||
import os.path
|
||||
import sys
|
||||
import string
|
||||
|
||||
for i, line in enumerate(sys.stdin):
|
||||
(url, title, fileName1) = json.loads(line)
|
||||
page1 = url[27:]
|
||||
page2 = page1.replace('(', '%28').replace(')', '%29')
|
||||
fileName2 = page2.replace('/', '_') + '_' + hashlib.md5(page2).hexdigest()[:8];
|
||||
suffix = '.google_geocoded'
|
||||
if os.path.exists(fileName2 + suffix):
|
||||
if not os.path.exists(fileName1 + suffix):
|
||||
cmd = 'mv "%s" "%s"' % (fileName2 + suffix, fileName1 + suffix)
|
||||
print(cmd)
|
||||
os.system(cmd)
|
Loading…
Add table
Reference in a new issue