From e3eb2f016aafa2f5a9540d45a6d08f29aa96e43a Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Sat, 10 Jan 2009 13:52:42 +1300 Subject: [PATCH] prompt for username and password if no config file --- ChangeLog | 4 ++++ README.txt | 9 +++++++++ ljdump.py | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5cfd73d..bc062fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ ChangeLog - ljdump +Version 1.3.3 - 2009-01-10 + +- Feature: ljdump now prompts for login info if ljdump.config does not exist + Version 1.3.2 - 2009-01-09 - Bugfix: Handle case where userpic keywords contain a / or \. diff --git a/README.txt b/README.txt index d9deccb..d00a7d0 100644 --- a/README.txt +++ b/README.txt @@ -3,6 +3,15 @@ ljdump - livejournal archiver This program reads the journal entries from a livejournal (or compatible) blog site and archives them in a subdirectory named after the journal name. +The simplest way to run this is to execute the ljdump.py script with Python. +Depending on your OS, you may be able to double-click the ljdump.py script +directly, or you may need to open a Terminal/Command Prompt window to run it. +Either way, it will prompt you for your Livejournal username and password, +then download all your journal entries, comments, and userpics. + +If you want to save your username and password so you don't have to type +it every time you run ljdump, you can save it in the configuration file. + The configuration is read from "ljdump.config". A sample configuration is provided in "ljdump.config.sample", which should be copied and then edited. The configuration settings are: diff --git a/ljdump.py b/ljdump.py index 604774e..a6d7db3 100755 --- a/ljdump.py +++ b/ljdump.py @@ -322,8 +322,19 @@ def ljdump(Server, Username, Password): print "%d errors" % errors if __name__ == "__main__": - config = xml.dom.minidom.parse("ljdump.config") - server = config.documentElement.getElementsByTagName("server")[0].childNodes[0].data - username = config.documentElement.getElementsByTagName("username")[0].childNodes[0].data - password = config.documentElement.getElementsByTagName("password")[0].childNodes[0].data + if os.access("ljdump.config", os.F_OK): + config = xml.dom.minidom.parse("ljdump.config") + server = config.documentElement.getElementsByTagName("server")[0].childNodes[0].data + username = config.documentElement.getElementsByTagName("username")[0].childNodes[0].data + password = config.documentElement.getElementsByTagName("password")[0].childNodes[0].data + else: + from getpass import getpass + print "ljdump - livejournal archiver" + print + print "Enter your Livejournal username and password." + print + server = "http://livejournal.com" + username = raw_input("Username: ") + password = getpass("Password: ") + print ljdump(server, username, password) -- 2.39.5