Code Monkey home page Code Monkey logo

python-lj's Introduction

Format Versions Versions

Python LiveJournal

Feel free to make pull requests!

A python realization of LiveJournal (LJ) API A full description of the protocol can be found at: http://www.livejournal.com/doc/server/ljp.csp.xml-rpc.protocol.html

Installation

Just type (pip integration is work in progress):

pip install lj

Usage example

from lj import lj
ljclient = lj.LJServer("Python-Blog3/1.0", "http://daniil-r.ru/bots.html; [email protected]")
ljclient.login("yourusername", "yourpassword")
ljclient.postevent("Awesome post", "Awesome subject", props={"taglist": "github,livejournal"})

python-lj's People

Contributors

bitdeli-chef avatar daniilr avatar dottedmag avatar halcyonshift avatar kemayo avatar rominf avatar umaxik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-lj's Issues

Non-UTF-8 characters cause traceback.

Looks like there's a bit of an explosion on Python 2.7.6 (Ubuntu 14.04) if the entry has non-UTF8 characters in it. I'm investigating... This is again the 0.2 release.

Traceback (most recent call last):
  File "./src/myarchive/main.py", line 154, in <module>
    main()
  File "./src/myarchive/main.py", line 147, in main
    ljapi.download_journals_and_comments(db_session=tag_db.session)
  File "/mnt/bulk/repos/projects/myarchive/src/myarchive/ljlib.py", line 59, in download_journals_and_comments
    nc = update_journal_comments(server=self._server, journal=self.journal)
  File "/usr/local/lib/python2.7/dist-packages/lj/backup.py", line 143, in update_journal_comments
    initial_meta = get_meta_since(journal['last_comment'], server, session)
  File "/usr/local/lib/python2.7/dist-packages/lj/backup.py", line 167, in get_meta_since
    meta = server.fetch_comment_meta(highest, session)
  File "/usr/local/lib/python2.7/dist-packages/lj/lj.py", line 547, in fetch_comment_meta
    self.host + "export_comments.bml?get=comment_meta&startid=%d" % int(startid), session)
  File "/usr/local/lib/python2.7/dist-packages/lj/lj.py", line 517, in __request_with_cookie
    data = io.StringIO(response.read().decode('utf8'))
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte

Library throws an exception talking to dreamwidth.org

Dreamwidth is Live-Journal based and uses the same XML-RPC interface (maybe a slightly older version?). This should work, but blows up with the following error.

Note that oddly, ljdump doesn't blow up talking to dw, so it is possible for this to work, but ljdump is not nearly the fully featured library this is. I'm investigating what it's doing differently...

Updated 68 entries and 2 comments
Downloading journal entries
69 entries to download
getting entries starting at 2015-09-24 23:22:44
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/lj/lj.py", line 326, in _getevents
    response = self.__request('getevents', arguments)
  File "/usr/local/lib/python3.4/dist-packages/lj/lj.py", line 78, in __request
    response = method(args)
  File "/usr/lib/python3.4/xmlrpc/client.py", line 1098, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.4/xmlrpc/client.py", line 1437, in __request
    verbose=self.__verbose
  File "/usr/lib/python3.4/xmlrpc/client.py", line 1140, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.4/xmlrpc/client.py", line 1156, in single_request
    return self.parse_response(resp)
  File "/usr/lib/python3.4/xmlrpc/client.py", line 1327, in parse_response
    return u.close()
  File "/usr/lib/python3.4/xmlrpc/client.py", line 657, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 406: "Client error: Client is making repeated requests.  Perhaps it's broken?">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./src/myarchive/main.py", line 161, in <module>
    main()
  File "./src/myarchive/main.py", line 154, in main
    ljapi.download_journals_and_comments(db_session=tag_db.session)
  File "/mnt/bulk/repos/projects/myarchive/src/myarchive/ljlib.py", line 55, in download_journals_and_comments
    nj = update_journal_entries(server=self._server, journal=self.journal)
  File "/usr/local/lib/python3.4/dist-packages/lj/backup.py", line 117, in update_journal_entries
    sync = server.getevents_syncitems(one_second_before(syncitems[0][1]))
  File "/usr/local/lib/python3.4/dist-packages/lj/lj.py", line 362, in getevents_syncitems
    return self._getevents(selecttype="syncitems", lastsync=lastsync, **kwds)
  File "/usr/local/lib/python3.4/dist-packages/lj/lj.py", line 328, in _getevents
    raise LJException(v)
lj.lj.LJException: <Fault 406: "Client error: Client is making repeated requests.  Perhaps it's broken

HTTPS by default for connections.

If you use the default URL, all data is transmitted in the clear, including the challenges and weakly hashed passwords. This is asking for a data breach. Please change it to https to protect your users! (It works!)

Traceback on journal['last_comment_meta'] in backup.py

This is from the 0.2 release. Looks like the journal['last_comment_meta'] field occasionally comes back None, which blows up backup.py.

Traceback (most recent call last):
  File "./src/myarchive/main.py", line 156, in <module>
    main()
  File "./src/myarchive/main.py", line 146, in main
    ljapi.download_journals_and_comments()
  File "/mnt/bulk/repos/projects/myarchive/src/myarchive/ljlib.py", line 39, in download_journals_and_comments
    nc = update_journal_comments(server=self._server, journal=self.journal)
  File "/usr/local/lib/python2.7/dist-packages/lj/backup.py", line 148, in update_journal_comments
    if len(journal['comments']) == 0 or days_ago(journal['last_comment_meta']) > 30:
  File "/usr/local/lib/python2.7/dist-packages/lj/backup.py", line 61, in days_ago
    return (datetime.datetime.today() - datetime_from_string(s)).days
  File "/usr/local/lib/python2.7/dist-packages/lj/backup.py", line 57, in datetime_from_string
    return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S")
TypeError: must be string, not None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.