wikimedia commons downloader

git-svn-id: https://wikiteam.googlecode.com/svn/trunk@337 31edc4fc-5e31-b4c4-d58b-c8bc928bcb95
pull/117/head
emijrp 12 years ago
parent de767fb0a8
commit d3fe649af8

@ -61,8 +61,7 @@ while startdate <= enddate:
md5_ = md5.new(re.sub(' ', '_', original_name.encode("utf-8"))).hexdigest() # do not use img_name_, md5 needs the original name without \"
if original_name != img_name:
os.system('wget -c "http://upload.wikimedia.org/wikipedia/commons/archive/%s/%s/%s" -O "%s/%s"' % (md5_[0], md5_[0:2], img_name_, path, img_name_))
if not os.path.getsize('%s/%s' % (path, img_name_)): #empty file, false XXXXXX! begining? restore original_name to ! version
print 'NOO'
if not os.path.getsize('%s/%s' % (path, img_name_)): #empty file?, false XXXXXX! begining like this http://commons.wikimedia.org/wiki/File:20041028210012!Pilar.jpg ? ok, restore original_name to ! version
#recalculate md5 and other variables that use original_name as source
original_name = img_name
original_name_ = re.sub(r'"', r'\"', re.sub(r' ', r'_', original_name.encode('utf-8')))

Loading…
Cancel
Save