diff options
author | Jochen Topf <jochen@topf.org> | 2015-03-08 23:24:26 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2015-03-08 23:24:26 +0100 |
commit | a2ce2ec5448a98678cdaeb99b673e11ffcc8845f (patch) | |
tree | 28521f3eb3ffe6b3ca4905aea1a8a13867a1f8de | |
parent | 48240be189cb6453465103ff535c3f22aed48f8e (diff) | |
download | taginfo-a2ce2ec5448a98678cdaeb99b673e11ffcc8845f.tar taginfo-a2ce2ec5448a98678cdaeb99b673e11ffcc8845f.tar.gz |
Fix up thumbnail image URLs from Wikimedia Commons.
-rwxr-xr-x | sources/wiki/get_image_info.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sources/wiki/get_image_info.rb b/sources/wiki/get_image_info.rb index 7d37528..6656baa 100755 --- a/sources/wiki/get_image_info.rb +++ b/sources/wiki/get_image_info.rb @@ -100,6 +100,14 @@ db.transaction do |db| suffix = nil puts "Wrong thumbnail format: '#{info['thumburl']}'" end + + # The OSM wiki reports the wrong thumbnail URL for images + # transcluded from Wikimedia Commons. This fixes those + # URLs. + if info['url'].match(%r{^http://upload.wikimedia.org/wikipedia/commons}) + prefix.sub!('http://wiki.openstreetmap.org/w/images', 'http://upload.wikimedia.org/wikipedia/commons') + end + images_added[v['title']] = 1 db.execute("INSERT INTO wiki_images (image, width, height, size, mime, image_url, thumb_url_prefix, thumb_url_suffix) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", v['title'], |