From 71a5512e5bc7c48cbe8137ff1083d80d0ea581d3 Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Fri, 9 Jan 2009 00:06:41 +1300 Subject: [PATCH] resume download if interrupted --- ChangeLog | 7 ++++--- ljdump.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47a8778..32daf7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,9 +2,10 @@ ChangeLog - ljdump Version 1.3.1 - 2009-01-08 -- Handle userpic keywords with non-ASCII characters -- Download and save userpic images -- Handle unexpected empty item +- Feature: Download and save userpic images +- Feature: Resume download where it left off if interrupted +- Bugfix: Handle userpic keywords with non-ASCII characters +- Bugfix: Handle unexpected empty item Version 1.2 - 2006-09-08 diff --git a/ljdump.py b/ljdump.py index 534e683..0c9ec89 100755 --- a/ljdump.py +++ b/ljdump.py @@ -106,6 +106,12 @@ def writedump(fn, event): dumpelement(f, "event", event) f.close() +def writelast(): + f = open("%s/.last" % Username, "w") + f.write("%s\n" % lastsync) + f.write("%s\n" % lastmaxid) + f.close() + def createxml(doc, name, map): e = doc.createElement(name) for k in map.keys(): @@ -201,6 +207,7 @@ while True: pprint.pprint(x) errors += 1 lastsync = item['time'] + writelast() # The following code doesn't work because the server rejects our repeated calls. # http://www.livejournal.com/doc/server/ljp.csp.xml-rpc.getevents.html @@ -324,10 +331,7 @@ while True: lastmaxid = maxid -f = open("%s/.last" % Username, "w") -f.write("%s\n" % lastsync) -f.write("%s\n" % lastmaxid) -f.close() +writelast() if origlastsync: print "%d new entries, %d new comments (since %s)" % (newentries, newcomments, origlastsync) -- 2.39.5