From: Greg Hewgill Date: Thu, 8 Jan 2009 10:46:33 +0000 (+1300) Subject: download and save userpic images X-Git-Tag: ljdump-1.3.2~9 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=7cf3cc3b1175e5584bf2e4b5f9266bebe10795a5;p=oss%2Fljdump.git download and save userpic images --- diff --git a/ChangeLog b/ChangeLog index 9e05c74..183f4af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ ChangeLog - ljdump Version 1.3.1 - 2009-01-08 - Handle userpic keywords with non-ASCII characters +- Download and save userpic images Version 1.2 - 2006-09-08 diff --git a/ljdump.py b/ljdump.py index e2114b3..e7534a9 100755 --- a/ljdump.py +++ b/ljdump.py @@ -46,9 +46,15 @@ # # Copyright (c) 2005-2006 Greg Hewgill -import codecs, md5, os, pickle, pprint, re, sys, urllib2, xml.dom.minidom, xmlrpclib +import codecs, md5, os, pickle, pprint, re, shutil, sys, urllib2, xml.dom.minidom, xmlrpclib from xml.sax import saxutils +MimeExtensions = { + "image/gif": ".gif", + "image/jpeg": ".jpg", + "image/png": ".png", +} + def calcchallenge(challenge, password): return md5.new(challenge+md5.new(password).hexdigest()).hexdigest() @@ -256,11 +262,18 @@ f = open("%s/user.map" % Username, "w") pickle.dump(usermap, f) f.close() +print "Fetching userpics for: %s" % Username f = open("%s/userpics.xml" % Username, "w") print >>f, """""" print >>f, "" for p in userpics: print >>f, """""" % (p, userpics[p]) + pic = urllib2.urlopen(userpics[p]) + ext = MimeExtensions.get(pic.info()["Content-Type"], "") + picf = open("%s/%s%s" % (Username, codecs.utf_8_decode(p)[0], ext), "wb") + shutil.copyfileobj(pic, picf) + pic.close() + picf.close() print >>f, "" f.close()