]> wagner.pp.ru Git - oss/ljdump.git/commitdiff
handle server url properly
authorgreg <greg@7994a137-d0a5-da11-ade6-0050bffea3d9>
Tue, 10 Jan 2006 04:19:31 +0000 (04:19 +0000)
committergreg <greg@7994a137-d0a5-da11-ade6-0050bffea3d9>
Tue, 10 Jan 2006 04:19:31 +0000 (04:19 +0000)
git-svn-id: file:///home/svn/ljdump/trunk@16 7994a137-d0a5-da11-ade6-0050bffea3d9

ChangeLog
ljdump.config.sample
ljdump.py

index 53e4200b7c1a6c69532213e12cdc8b6ee4e237b7..72e8b3865f43f541991446204f6e9fee40087cd5 100644 (file)
--- 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
index 7b65eb35b884cc2db028c83cefaae42adf8f4a71..1d6bb92465a4c930c52272f59f3991d41a32ea93 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <ljdump>
-    <server>http://livejournal.com/interface/xmlrpc</server>
+    <server>http://livejournal.com</server>
     <username>myaccount</username>
     <password>mypassword</password>
 </ljdump>
index 751dfffca02771f93405f44dbd755e1fbfd3cb85..066f9765a73504d7991e79fd0518eb24b838ee52 100755 (executable)
--- 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"):