Example #1
0
File: lj.py Project: sa2ajj/ljpy
#! /usr/bin/python
# -*- coding: utf-8 -*-

'''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)
Example #2
0
File: ljcs.py Project: sa2ajj/ljpy
options, args = parser.parse_args ()

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'])
Example #3
0
File: ljac.py Project: sa2ajj/ljpy
encoding = evalue (defaultenc, options.encoding)

config = Config ()
config.load (evalue ('~/.ljrc', options.config))

server = getattr (config, options.server)
ljac = config.ljac

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)

if info.message is not None:
    for line in info.message.split ('\n'):
        print 'Server:', line

def execute (commands):
    result = lj.consolecommand (commands)

    for i in range (len (result)):
        item = result[i]

        if item.success:
            print 'Success:',
Example #4
0
config = Config ()
config.load (evalue ('~/.ljrc', options.config))

server = getattr (config, options.server)
ljbackup = config.ljbackup

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)

backupname = evalue (ljbackup.file, options.file)

lj = LiveJournal (config.misc.version)

info = lj.login (username, password)

if info.message is not None:
    print 'Server:', info.message

backup = open (expanduser (backupname), 'w')

print 'Synchronizing...'

value = lj.syncitems ()

print 'Got information for %d out of %d item(s)' % (value.count, value.total)

print >> backup, '''<?xml version='1.0'?>
Example #5
0
	output += "</ul><small>Automagically shipped by <a href=\"http://github.com/palfrey/murmur/\">Murmur</a></small></lj-cut>"
	try:
		print output
	except UnicodeEncodeError:
		print "Can't print output due to unicode issues"

	if opts.post:
		from livejournal import LiveJournal, list2list, list2mask

		subject = u"Daily mutterings"
		body = output

		username = m.config.get("livejournal","username")
		password = m.config.get("livejournal","password")
		usejournal = username

		try:
			xmlrpc = m.config.get("livejournal","xmlrpc")
			lj = LiveJournal (0, base=xmlrpc)
		except NoOptionError: # default to LJ
			lj = LiveJournal (0)
		info = lj.login (username, password)
		security = list2mask (m.config.get("livejournal","security"), info.friendgroups)

		entry = lj.postevent (unicode(body),
						subject = subject,
						security = security,
						props = {"taglist":"twitter"})

		print 'Posted'
Example #6
0
File: ljp.py Project: sa2ajj/ljpy
    config = Config ()
    config.load (evalue ('~/.ljrc', options.config))

    server = getattr (config, options.server)
    ljp = config.ljp

    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)

    usejournal = evalue (None, options.journal)

    lj = LiveJournal (config.misc.version)

    info = lj.login (username, password)

    security = list2mask (options.security, info.friendgroups)

    if evalue (None, ljp.batch, options.batch):
        body = body + '\n' + sys.stdin.read ()
    else:
        # At this point we have the following variables holding useful information:
        #  -- body
        #  -- subject
        #  -- props
        #  -- usejournal
        #  -- security
Example #7
0
File: lje.py Project: sa2ajj/ljpy
if options.preformatted:
    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)