Skip to content

Commit

Permalink
md5 compatibility
Browse files Browse the repository at this point in the history
git-svn-id: http://wikiteam.googlecode.com/svn/trunk@342 31edc4fc-5e31-b4c4-d58b-c8bc928bcb95
  • Loading branch information
emijrp committed Feb 28, 2012
1 parent f7de8bf commit 3117fbb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion commonsdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import sys

filename = 'commonssql.csv'
filename = 'a.csv'
startdate = ''
enddate = ''
delta = datetime.timedelta(days=1)
Expand Down Expand Up @@ -63,7 +64,7 @@
original_name_ = re.sub(r'"', r'\"', re.sub(r' ', r'_', original_name.encode('utf-8'))) # do not use ur'', it is encoded
img_name_ = re.sub(r'"', r'\"', re.sub(r' ', r'_', img_name.encode('utf-8'))) # do not use ur'', it is encoded
print img_name, img_name_, img_timestamp
md5_ = md5.new(re.sub(' ', '_', original_name.encode("utf-8"))).hexdigest() # do not use img_name_, md5 needs the original name without \"
md5_ = md5(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 like this http://commons.wikimedia.org/wiki/File:20041028210012!Pilar.jpg ? ok, restore original_name to ! version
Expand Down

0 comments on commit 3117fbb

Please sign in to comment.