aboutsummaryrefslogtreecommitdiff
path: root/sources/wiki
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-10 23:07:39 +0100
committerJochen Topf <jochen@topf.org>2013-01-10 23:07:39 +0100
commitb11c37b6f078afe87de4c9663271c203e96177c4 (patch)
treeb5ad29cf87765e2f7160d1222c650aa53783dc9a /sources/wiki
parentd52e0358934abe60a48ec520825e023452bff21d (diff)
downloadtaginfo-b11c37b6f078afe87de4c9663271c203e96177c4.tar
taginfo-b11c37b6f078afe87de4c9663271c203e96177c4.tar.gz
Bugfix: Wiki images sometimes appeared twice in list
Diffstat (limited to 'sources/wiki')
-rwxr-xr-xsources/wiki/get_image_info.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/sources/wiki/get_image_info.rb b/sources/wiki/get_image_info.rb
index 47d90b8..5a08cd8 100755
--- a/sources/wiki/get_image_info.rb
+++ b/sources/wiki/get_image_info.rb
@@ -62,6 +62,8 @@ db.execute('BEGIN TRANSACTION');
puts "Found #{ image_titles.size } different image titles"
+images_added = {}
+
until image_titles.empty?
some_titles = image_titles.slice!(0, 10)
puts "Get image info for: #{ some_titles.join(' ') }"
@@ -89,7 +91,7 @@ until image_titles.empty?
end
data['query']['pages'].each do |k,v|
- if v['imageinfo']
+ if v['imageinfo'] && ! images_added[v['title']]
info = v['imageinfo'][0]
if info['thumburl'].match(%r{^(.*/)[0-9]{1,4}(px-.*)$})
prefix = $1
@@ -99,6 +101,7 @@ until image_titles.empty?
suffix = nil
puts "Wrong thumbnail format: '#{info['thumburl']}'"
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'],
info['width'],