GithubHelp home page GithubHelp logo

lxyu / kindle-clippings Goto Github PK

View Code? Open in Web Editor NEW
144.0 144.0 49.0 13 KB

A simple python script to extract clippings from 'My Clippings.txt', organize, store and output them in a more elegant way.

Home Page: http://lxyu.github.com/kindle-clippings/

Python 100.00%

kindle-clippings's People

Contributors

lxyu avatar tevino avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kindle-clippings's Issues

Missing notes

Highlights have data like "Location 1513-1514" but notes can look like "Location 1514" so these are not picked up by the script. Maybe a regex like 'Location (\d+)' instead of '(\d+)-\d+'

msgpack instead of JSON?

I know msgpack is great, but I don't see any significant benefits in this project. 😢
Isn't that great if this project comes with no external dependency? πŸ˜ƒ

book titles with invalid characters for filename under windows arise error

I have the same problem described here
http://stackoverflow.com/questions/22620965/ioerror-errno-22-invalid-mode-wb-or-filename

I was wondering whether the filename could be normalized, at least under windows, before creating the file with the filename of the title.

For the moment I'm importing unicodedata and using the following verbose code (and not immune to errors, as I allow the \ to be in the filename, as it is used for referring to the partial path) in export_txt to make things work:

        try:
            with open(filename, 'wb') as f:
                f.write("\n\n---\n\n".join(lines))
        except:
            oldfilename = filename
            filename = unicodedata.normalize('NFKD', filename).encode('ascii','ignore')
            valid_chars = '\\-_.() abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
            filename = ''.join(c for c in filename if c in valid_chars)
            print 'Converting', oldfilename, 'to', filename
            with open(filename, 'wb') as f:
                f.write("\n\n---\n\n".join(lines))

Thanks

original order of clips by location is not maintained

For each book, a dict X is created using a string of the clip position as key.
Then clips are written for each pos in sorted(X), so that e.g. "3748" comes before "410".
For the moment I'm using an inefficient:

for pos in sorted([int(x) for x in clips[book].keys()]):

in export_txt.

TypeError: a bytes-like object is required, not 'str'

Traceback (most recent call last):
  File "kindle.py", line 94, in <module>
    main()
  File "kindle.py", line 89, in main
    save_clips(clips)
  File "kindle.py", line 70, in save_clips
    json.dump(clips, f)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 180, in dump
    fp.write(chunk)
TypeError: a bytes-like object is required, not 'str'

Split titles

Documents can have titles split with a newline, currently the script assumes the title is a single line so it does not find the Location in the expected line. Maybe get_sections can remove the newlines in the title.

It might be worth showing an error when a Location can't be found - this situation should not exist ?

Please add a maintainer

Looks like this repo has fallen out of maintenance. Could you please hand over maintenance to someone else? If no one else is enthusiastic about doing it, I could.

output dir

To allow the script to be installed on a path it might be nice to create the output dir if it does not exist (rather than assuming the script is run from within the repository only). Thanks for making this available!

γ€ζ±‚εŠ©γ€‘θΏθ‘Œι”™θ――γ€‚

ι”™θ――δ»£η ε¦‚δΈ‹οΌš
Traceback (most recent call last):
File "kindle.py", line 94, in
main()
File "kindle.py", line 90, in main
export_txt(clips)
File "kindle.py", line 50, in export_txt
with open(filename, 'w') as f:
IOError: [Errno 2] No such file or directory: u'output/Who Moved My Cheese? (Spencer Johnson).md'

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.