'''this file is a sandbox for my experiments with differrent methods of the LiveJournal protocol. Though I include this file in the distribution it should rather be used as an example... Misha''' from livejournal import LiveJournal, Config config = Config () config.load ('~/.ljrc') server = config.server lj = LiveJournal (config.misc.version) from pprint import pprint pprint (lj.login (server.username, server.password)) if 0: pprint (lj.checkfriends (lastupdate = '2002-07-24 00:00:00', mask = 1)) elif 0: pprint (lj.getfriends (includefriendof = 1, includegroups = 1)) else: print 'Synchronizing...' value = lj.syncitems () print 'Got information for %d out of %d item(s)' % (value.count, value.total) for item in value.syncitems: print '%s (%s, %s) -- %s (%s)' % (item.item, item.itemid, item.type, item.time, item.action)
config = Config () config.load (evalue ('~/.ljrc', options.config)) server = getattr (config, options.server) username = evalue (server.username, options.username) password = evalue (server.password, options.password) if username is None or password is None: print "You must provide both user name and password" sys.exit (2) lj = LiveJournal (config.misc.version) info = lj.login (username, password) sfrom = list2mask (options.sfrom, info.friendgroups) sto = list2mask (options.sto, info.friendgroups) print 'We are about to change from "%s" to "%s"' % (sfrom, sto) if 0: daycounts = lj.getdaycounts ()['daycounts'] for day in daycounts: # print day['date'], '->', day['count'] events = lj.getevents ('day', day['date']) for event in events: security = getattr (event, 'security', 'public')
props['opt_preformatted'] = 1 if options.mood is not None: props['current_mood'] = options.mood if options.music is not None: props['current_music'] = options.music config = Config () config.load (evalue ('~/.ljrc', options.config)) server = getattr (config, options.server) lj = LiveJournal (config.misc.version) info = lj.login (server.username, server.password) if 0: if subject is not None: subject = unicode (subject, 'koi8-r') event = unicode (event, 'koi8-r') entry = lj.postevent (event, subject = subject, props = props, security = list2mask (options.security, info.friendgroups)) print 'Posted.\nLink to the post: http://www.livejournal.com/talkread.bml?journal=%s&itemid=%s' % (server.username, entry.itemid*256 + entry.anum) else: sys.stdout.write (args2text (info = info, event = event, subject = subject, props = props, security = options.security))