X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ljdump.py;h=a347dc285e666ac5e5d8358cb5d8a6c3a92da17f;hb=a1ab8ec4b8c816003df57d3e57010eefaa8bb19b;hp=fbae90ad37f5cacbe938c1069e1ce949e7bca9d2;hpb=acf8f188feeb3d368a97ca90cc54f098dcae94ce;p=oss%2Fljdump.git diff --git a/ljdump.py b/ljdump.py index fbae90a..a347dc2 100755 --- a/ljdump.py +++ b/ljdump.py @@ -2,7 +2,7 @@ # # ljdump.py - livejournal archiver # Greg Hewgill http://hewgill.com -# Version 1.3.1 +# Version 1.3.2 # # $Id$ # @@ -284,7 +284,14 @@ 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") + picfn = re.sub(r"[\/]", "_", p) + try: + picfn = codecs.utf_8_decode(picfn)[0] + picf = open("%s/%s%s" % (Username, picfn, ext), "wb") + except: + # for installations where the above utf_8_decode doesn't work + picfn = "".join([ord(x) < 128 and x or "?" for x in picfn]) + picf = open("%s/%s%s" % (Username, picfn, ext), "wb") shutil.copyfileobj(pic, picf) pic.close() picf.close()