From: greg Date: Tue, 10 Jan 2006 04:19:31 +0000 (+0000) Subject: handle server url properly X-Git-Tag: ljdump-1.3.2~16 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=59535734f145ccbe8927c6d88ad4959573426185;p=oss%2Fljdump.git handle server url properly git-svn-id: file:///home/svn/ljdump/trunk@16 7994a137-d0a5-da11-ade6-0050bffea3d9 --- diff --git a/ChangeLog b/ChangeLog index 53e4200..72e8b38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ ChangeLog - ljdump +Version 1.1 - 2006-01-09 + +- Add comment downloading. + Version 1.0.3 - 2005-12-25 - Get updated journal entries in addition to new entries diff --git a/ljdump.config.sample b/ljdump.config.sample index 7b65eb3..1d6bb92 100644 --- a/ljdump.config.sample +++ b/ljdump.config.sample @@ -1,6 +1,6 @@ - http://livejournal.com/interface/xmlrpc + http://livejournal.com myaccount mypassword diff --git a/ljdump.py b/ljdump.py index 751dfff..066f976 100755 --- a/ljdump.py +++ b/ljdump.py @@ -46,7 +46,7 @@ # # Copyright (c) 2005-2006 Greg Hewgill -import codecs, md5, os, pickle, pprint, sys, urllib2, xml.dom.minidom, xmlrpclib +import codecs, md5, os, pickle, pprint, re, sys, urllib2, xml.dom.minidom, xmlrpclib from xml.sax import saxutils def calcchallenge(challenge, password): @@ -67,10 +67,10 @@ def flatresponse(response): return r def getljsession(username, password): - r = urllib2.urlopen("http://livejournal.com/interface/flat", "mode=getchallenge") + r = urllib2.urlopen(Server+"/interface/flat", "mode=getchallenge") response = flatresponse(r) r.close() - r = urllib2.urlopen("http://livejournal.com/interface/flat", "mode=sessiongenerate&user=%s&auth_method=challenge&auth_challenge=%s&auth_response=%s" % (username, response['challenge'], calcchallenge(response['challenge'], password))) + r = urllib2.urlopen(Server+"/interface/flat", "mode=sessiongenerate&user=%s&auth_method=challenge&auth_challenge=%s&auth_response=%s" % (username, response['challenge'], calcchallenge(response['challenge'], password))) response = flatresponse(r) r.close() return response['ljsession'] @@ -118,6 +118,10 @@ Server = config.documentElement.getElementsByTagName("server")[0].childNodes[0]. Username = config.documentElement.getElementsByTagName("username")[0].childNodes[0].data Password = config.documentElement.getElementsByTagName("password")[0].childNodes[0].data +m = re.search("(.*)/interface/xmlrpc", Server) +if m: + Server = m.group(1) + print "Fetching journal entries for: %s" % Username try: os.mkdir(Username) @@ -127,7 +131,7 @@ except: ljsession = getljsession(Username, Password) -server = xmlrpclib.ServerProxy(Server) +server = xmlrpclib.ServerProxy(Server+"/interface/xmlrpc") newentries = 0 newcomments = 0 @@ -219,7 +223,7 @@ except: maxid = lastmaxid while True: - r = urllib2.urlopen(urllib2.Request("http://livejournal.com/export_comments.bml?get=comment_meta&startid=%d" % (maxid+1), headers = {'Cookie': "ljsession="+ljsession})) + r = urllib2.urlopen(urllib2.Request(Server+"/export_comments.bml?get=comment_meta&startid=%d" % (maxid+1), headers = {'Cookie': "ljsession="+ljsession})) meta = xml.dom.minidom.parse(r) r.close() for c in meta.getElementsByTagName("comment"): @@ -246,7 +250,7 @@ f.close() newmaxid = maxid maxid = lastmaxid while True: - r = urllib2.urlopen(urllib2.Request("http://livejournal.com/export_comments.bml?get=comment_body&startid=%d" % (maxid+1), headers = {'Cookie': "ljsession="+ljsession})) + r = urllib2.urlopen(urllib2.Request(Server+"/export_comments.bml?get=comment_body&startid=%d" % (maxid+1), headers = {'Cookie': "ljsession="+ljsession})) meta = xml.dom.minidom.parse(r) r.close() for c in meta.getElementsByTagName("comment"):