From a2ce2ec5448a98678cdaeb99b673e11ffcc8845f Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sun, 8 Mar 2015 23:24:26 +0100 Subject: Fix up thumbnail image URLs from Wikimedia Commons. --- sources/wiki/get_image_info.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sources/wiki') 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'], -- cgit v1.2.3