diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-10 23:07:39 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-10 23:07:39 +0100 |
commit | b11c37b6f078afe87de4c9663271c203e96177c4 (patch) | |
tree | b5ad29cf87765e2f7160d1222c650aa53783dc9a /sources/wiki | |
parent | d52e0358934abe60a48ec520825e023452bff21d (diff) | |
download | taginfo-b11c37b6f078afe87de4c9663271c203e96177c4.tar taginfo-b11c37b6f078afe87de4c9663271c203e96177c4.tar.gz |
Bugfix: Wiki images sometimes appeared twice in list
Diffstat (limited to 'sources/wiki')
-rwxr-xr-x | sources/wiki/get_image_info.rb | 5 |
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'], |