12-21-2011, 08:48 AM | #1 |
Member
Posts: 11
Karma: 78
Join Date: Jun 2011
Location: Villejuif, France
Device: Kindle 3
|
Extract quotes from reader
Hi people!
I just made this smallish piece of code to extract the quotes from a PRS-T1. It has to be run on cygwin or in a whatever OS terminal. Just change the path to your sqlite3 binary and run this from your "READER" mount point. It creates a "quotes.txt" with all your quotes. It could probably be improved with details about the quotes' pages but I only intended to get the full text quotes. Enjoy! Code:
#!/bin/bash OUTPUT_FILE='quotes.txt' SQLITE='./sqlite3.exe' AWK='awk' #add the UTF-8 BOM to the generated file echo -ne '\xEF\xBB\xBF' > $OUTPUT_FILE $SQLITE Sony_Reader/database/books.db 'select b.author, b.title, a.marked_text FROM annotation a INNER JOIN books b on a.content_id=b._id' | \ $AWK -F '|' '{ print "--------------------\nAuthor: "$1"\nTitle: "$2"\n--------------------\n"$3"\n--------------------" }'| \ unix2dos >> $OUTPUT_FILE Last edited by damaki; 12-21-2011 at 11:14 AM. |
12-21-2011, 10:36 AM | #2 |
Zealot
Posts: 110
Karma: 5368
Join Date: Apr 2010
Location: Italy
Device: Sony PRS-T1 Sony PRS-350 Nook Touch Glow
|
Wonderful!!!
For very lazy people, version for MAcOS: #!/bin/bash -vx OUTPUT_FILE='quotes.txt' SQLITE='sqlite3' AWK='awk' ICONV='iconv' #add the UTF-8 BOM to the generated file echo -ne '\xEF\xBB\xBF' > $OUTPUT_FILE $SQLITE Sony_Reader/database/books.db 'select b.author, b.title, a.marked_text FROM annotation a INNER JOIN books b on a.content_id=b._id' | \ $AWK -F '|' '{ print "--------------------\nAuthor: "$1"\nTitle: "$2"\n--------------------\n"$3"\n--------------------" }'| \ $ICONV -t UTF-8 -f UTF-8 >> $OUTPUT_FILE |
Advert | |
|
12-21-2011, 11:12 AM | #3 |
Member
Posts: 11
Karma: 78
Join Date: Jun 2011
Location: Villejuif, France
Device: Kindle 3
|
By the way, iconv should not be required as I figured out how to add the BOM manually (and that iconv was totally useless for that).
This should be the proper piece of code : Code:
#!/bin/bash OUTPUT_FILE='quotes.txt' SQLITE='./sqlite3.exe' AWK='awk' #add the UTF-8 BOM to the generated file echo -ne '\xEF\xBB\xBF' > $OUTPUT_FILE $SQLITE Sony_Reader/database/books.db 'select b.author, b.title, a.marked_text FROM annotation a INNER JOIN books b on a.content_id=b._id' | \ $AWK -F '|' '{ print "--------------------\nAuthor: "$1"\nTitle: "$2"\n--------------------\n"$3"\n--------------------" }'| \ unix2dos >> $OUTPUT_FILE |
12-21-2011, 03:29 PM | #4 |
Addict
Posts: 332
Karma: 6220000
Join Date: Jul 2011
Location: Germany
Device: Kobo Aura HD
|
Cool, I haven't used the quote feature of the T1 yet, but it's nice to know that you don't need to sync with the Sony software to get them.
Thanks and K+ for that. Do you think there is any way of integrating that into Calibre, as an extra plugin maybe? |
12-23-2011, 04:11 AM | #5 |
Member
Posts: 11
Karma: 78
Join Date: Jun 2011
Location: Villejuif, France
Device: Kindle 3
|
Probably. Sqlite is quite a standard database and it should't be too hard to get inspiration from the Odyssey calibre driver which can already export quotes. But I'd rather build a small standalone app that I can leave it on my T1 and use it without Calibre. I cannot really see the point in Calibre integration as it has no quote database, as far as I know.
|
Advert | |
|
12-23-2011, 05:54 AM | #6 |
Avid Reader
Posts: 161
Karma: 36472
Join Date: Sep 2008
Location: Look for rain, hail and snow...
Device: PRS-505, PRS-600, PRS T1, Kobo Glo
|
You would still be able to fill in a custom field... That would be quite nice.
|
12-23-2011, 09:51 AM | #7 |
Member
Posts: 14
Karma: 50
Join Date: Jan 2010
Device: Sony PRS 505
|
I just tried to do this for my book on my W7 PC....
Unfortunately, I failed to do this. Can somebody pleasre give the not so technophile people an elaborate example as to how to use this (with directories). I tried to put this line of code into the cmd-console, but I just did not know where and what exactly to put in for my sd-card with the database. So can somebody please help me? |
12-23-2011, 12:25 PM | #8 |
...
Posts: 226
Karma: 514506
Join Date: Sep 2011
Device: Sony PRS-T1
|
fei-d, you might have to wait until someone converts this to batch if you're not up for the task, otherwise if you want to try to make it work you will need to install cygwin, make sure you have following packages selected: bash, awk, sqlite3
|
12-25-2011, 04:21 AM | #9 |
Member
Posts: 14
Karma: 50
Join Date: Jan 2010
Device: Sony PRS 505
|
So, I installed cygwin and pasted the line of code from the OP. But I just get the error that "-bash: ./sqlite3.exe: No such file or directory".
Obviously, I did not specify the correct path to my database with the highlights. So where should I put the database or what path should I specify. Where should I change the code? |
12-25-2011, 05:28 PM | #10 |
Avid Reader
Posts: 161
Karma: 36472
Join Date: Sep 2008
Location: Look for rain, hail and snow...
Device: PRS-505, PRS-600, PRS T1, Kobo Glo
|
Try changing
SQLITE='./sqlite3.exe' to SQLITE='sqlite3' That should work in cygwin (Linux here, so I can't test this, sorry) |
12-26-2011, 09:19 AM | #11 |
...
Posts: 226
Karma: 514506
Join Date: Sep 2011
Device: Sony PRS-T1
|
fei-d also, make sure you have sqlite3 selected in the package manager of cygwin I don't think it's included by default.
You don't have to reinstall, if you you re-run setup.exe and point it to the same path of your previous install (it should have already remembered what you did last time) make sure the sqlite3 package is installed. |
12-29-2011, 06:38 AM | #12 | |
Member
Posts: 14
Karma: 50
Join Date: Jan 2010
Device: Sony PRS 505
|
So I checked again if I had installed sqlite3 and even installed it again...
Opitzs's advice seemed to help. Now cygwin at least runs the code. But now I get another error: "Error: unable to open database "Sony_Reader/database/books.db": unable to open database file" This is really getting frustrating... I tried the following code: Quote:
|
|
12-29-2011, 10:57 AM | #13 |
Avid Reader
Posts: 161
Karma: 36472
Join Date: Sep 2008
Location: Look for rain, hail and snow...
Device: PRS-505, PRS-600, PRS T1, Kobo Glo
|
Did you first change the directory to
cd /cygdrives/<whatever drive letter your reader has> The script opens Sony_Reader/database/books.db without any drive assignment, this only works, if you are there already, otherwise it won't find the path... |
12-30-2011, 06:50 AM | #14 |
Member
Posts: 14
Karma: 50
Join Date: Jan 2010
Device: Sony PRS 505
|
Thanks a lot!!! It finally does work.
I am very gratefule to you two (opitzs and log) for taking your time with me and helping me. In the end my last problem was to go to the right drive and execute the code there. But now there seems to be a limit at how much is extracted, because it only extracted up to 200 characters; longer highlighted sections were not completely extracted.... Though one can live with this it is still annoying. Maybe this is more of a problem with the T1 than the code itself. Then again, the ebooks I use are DRM-free and should not cause such problems for the T1. |
12-30-2011, 07:48 AM | #15 | |
Connoisseur
Posts: 83
Karma: 1224
Join Date: Dec 2011
Location: Gijon (Spain)
Device: Sony PRS-T1 black
|
Quote:
Code:
#!/bin/bash OUTPUT_FILE='quotes.txt' SQLITE='./sqlite3.exe' AWK='awk' #add the UTF-8 BOM to the generated file echo -ne '\xEF\xBB\xBF' > $OUTPUT_FILE $SQLITE Sony_Reader/database/books.db 'select b.author, b.title, a.marked_text FROM annotation a INNER JOIN books b on a.content_id=b._id' | \ $AWK -F '|' '{ print "--------------------\nAuthor: "$1"\nTitle: "$2"\n--------------------"; $1=""; $2=""; print $0"\n--------------------" }'| \ unix2dos >> $OUTPUT_FILE |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change single quotes to double quotes | Elfwreck | Workshop | 16 | 04-26-2013 10:06 AM |
Auto extract | atjnjk | Calibre | 2 | 10-23-2010 11:52 AM |
Single quotes to double quotes? | lunixer | General Discussions | 35 | 10-10-2010 05:47 AM |
convert straight quotes to curly quotes | alansplace | Calibre | 3 | 09-25-2010 03:51 PM |
Extract html from epub | Waltarro | ePub | 3 | 08-27-2009 05:21 AM |