Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Sony Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 10-25-2006, 10:18 AM   #1
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Mac OS X lit2rtf AppleScript thingy (Now with PDF goodness!)

I might be the only Mac guy here, but whatever. I just wrote an AppleScript that ties together convertlit, some XML parsing, and textutil to convert an unprotected lit file to a rtf. It even keeps the title and author from the lit file.

You'll need the OS X binary of Convert LIT, the XML Tools scripting addition, and, of course, the script.

[Edit to add: PDF support too! You'll need htmldoc. Easiest way to get it is with MacPorts.]

Once you download the script, you'll need to edit it (just double click on it) to tell it where you put convertlit and how big you want your text. Then just save it as an application, put it somewhere convenient, and drag and drop a lit onto it. Be patient (there's no progress display), and in a few seconds there should be a rtf in the same folder as the lit.
[Edit: For a PDF, rename the script lit2pdf or edit it to prompt for the format]

The code is ugly and poorly commented. I might fix that... eventually. Also, I've only tested it on two lit files. Your results may vary. Void where prohibited. Do not taunt happy fun ball.

Last edited by FourOhFour; 10-26-2006 at 06:11 PM.
FourOhFour is offline   Reply With Quote
Old 10-25-2006, 10:39 AM   #2
ultim8fury
Addict
ultim8fury has a complete set of Star Wars action figures.ultim8fury has a complete set of Star Wars action figures.ultim8fury has a complete set of Star Wars action figures.ultim8fury has a complete set of Star Wars action figures.
 
ultim8fury's Avatar
 
Posts: 219
Karma: 368
Join Date: Jan 2006
Location: UK
Device: PRS500, Looking at 700
You're not the only Mac user around here. Your work is appreciated.
ultim8fury is offline   Reply With Quote
Advert
Old 10-25-2006, 01:51 PM   #3
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Well, I stumbled upon a .lit that the script didn't like. (The content was made up of multiple HTML documents.) Just uploaded 0.3 which properly combines them instead of making an RTF from just the first one. This version also names the rtf file based off the lit file's name instead of the name of the html inside it.

For my next trick... well, I dunno. NetNewsWire Lite isn't scriptable, otherwise I'd try a rss2rtf script.
FourOhFour is offline   Reply With Quote
Old 10-26-2006, 06:21 PM   #4
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Hey hey, me again.

Just added support to create PDFs using htmldoc. (Why create PDFs? Well, then images and links work.)

Just download and install htmldoc (I suggest using MacPorts) and the new version of the script (0.4), rename the script lit2pdf, and you're off.

Edit to add: Posted 0.5 and 0.6. 0.5 is some slight code cleanup and doesn't really warrant a new version except I wanted to have it to go back to if 0.6 fell flat on its face. 0.6 will increase the image sizes in PDFs.

Edit again: 0.7! 0.7 will copy title and author over to the pdf.

Known problems:
  • The script is turning into an ugly mess of spaghetti code.
  • Images in PDFs will be tiny. Seems to be htmldoc's doing. I might try and figure out a way to scale the images up before making the PDF.
  • Metadata isn't copied over to the PDF. (htmldoc has no way to specify it) Instead, the title for the file will be the title for the HTML file inside the lit, which is usually ugly but usable. No author will be listed (at least, it wasn't in the one I made...).

Last edited by FourOhFour; 10-27-2006 at 12:44 PM.
FourOhFour is offline   Reply With Quote
Old 10-28-2006, 03:48 AM   #5
phobus
Junior Member
phobus began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Oct 2006
This is awesome! Thanks!

Is there any way to specify the font?
phobus is offline   Reply With Quote
Advert
Old 10-28-2006, 10:04 AM   #6
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Quote:
Originally Posted by phobus
This is awesome! Thanks!

Is there any way to specify the font?
Not when converting to RTF. (textutil does have a -font option, but the documentation says it is only for converting from plain text)

To specify the font when converting to PDF, add "--bodyfont helvetica" (or "courier" or "times") to htmldoc_options near the top of the script. (I don't know if the documentation lists those three fonts as examples or if those are the only ones available. Then again, I don't know what's available on the Reader either.)
FourOhFour is offline   Reply With Quote
Old 01-18-2007, 07:08 AM   #7
Evan
... loves his toys!
Evan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it isEvan knows what time it is
 
Posts: 47
Karma: 2419
Join Date: Oct 2005
Location: Viena, VA
Device: Treo 650
Wonderful! Thank you!!!!
Evan is offline   Reply With Quote
Old 02-03-2007, 10:50 PM   #8
fonix
Junior Member
fonix began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2007
Device: PRS-500, iPaq 2215
Just wanted to give you kudos... I had been doing this by hand, and it took *forever*. I also learned a bit about scripting by looking at this, maybe I'll give it a go on some other projects. Thanks a ton!
fonix is offline   Reply With Quote
Old 02-07-2007, 05:50 PM   #9
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Quote:
Originally Posted by fonix
Just wanted to give you kudos... I had been doing this by hand, and it took *forever*. I also learned a bit about scripting by looking at this, maybe I'll give it a go on some other projects. Thanks a ton!
Cool! I'm sorry I didn't comment it better now, didn't expect someone to actually try to read it. ;-)

Few things I've noticed since writing this: OS X's RTF generation (which this script uses) seems to sometimes create RTF files that the Reader cannot properly read. When this happens, it shows up as missing sections or garbage characters. Short of finding another way to convert HTML to RTF that is AppleScriptable (or a command line tool), there's nothing to be done about it.

PDFs, on the other hand, work fine. However, page turns get absurdly slow at higher page numbers.

Last edited by FourOhFour; 02-07-2007 at 05:52 PM.
FourOhFour is offline   Reply With Quote
Old 04-26-2007, 10:39 PM   #10
autumnmist
Junior Member
autumnmist began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Apr 2007
Wow, I recently switched from Windows to Mac and I was searching for a way to read my .lit books in OS X. Thanks so much.

I have run into a problem with your script, however--when attempting to do lit2pdf, with some of my files, it says that the "author" is a missing value so it can't create the quoted form of it... I think this might be a problem in the part of the script that uses perl, but I'm not very familiar with Applescript yet.
autumnmist is offline   Reply With Quote
Old 05-02-2007, 09:47 PM   #11
FourOhFour
HTTP Error
FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.FourOhFour ought to be getting tired of karma fortunes by now.
 
FourOhFour's Avatar
 
Posts: 84
Karma: 3000000
Join Date: Oct 2006
Device: Kindle Paperwhite
Quote:
Originally Posted by autumnmist
Wow, I recently switched from Windows to Mac and I was searching for a way to read my .lit books in OS X. Thanks so much.

I have run into a problem with your script, however--when attempting to do lit2pdf, with some of my files, it says that the "author" is a missing value so it can't create the quoted form of it... I think this might be a problem in the part of the script that uses perl, but I'm not very familiar with Applescript yet.
Well... huh. That shouldn't happen; every time I try to create the quoted form of the author, I check to make sure it isn't a missing value first.

If you run it from inside Script Editor, you should be able to copy and paste the exact error message from the event log tab at the bottom.

If you could tell me exactly where it is failing, or better yet, send me a copy of the file it is failing on, that'd be great.




Edit to add: Reading PDFs on the Reader is awful. It seems ok or merely poor at first, but towards the end of a novel-length PDF, the page turns take far too long to be usable, sadly. I don't know that I'd bother adding PDF support to the script if I hadn't already, and I'd really suggest using RTF. (Not to say that I won't fix the script - if I can find the problem I certainly will - just that you may decide after converting all these files that you'd rather have them in RTF anyway. Well, unless they have images...)

Last edited by FourOhFour; 05-02-2007 at 09:57 PM.
FourOhFour is offline   Reply With Quote
Old 08-11-2007, 12:02 AM   #12
Nelly
Junior Member
Nelly doesn't litterNelly doesn't litter
 
Posts: 5
Karma: 116
Join Date: Aug 2007
Location: Tasmania, Australia
Device: Onyx Boox Nova Pro
Thumbs up Great, I love it!

Thanks so much for this great tool. Before I had this I was having to go over to a friend's place to use his PC, what a pain! Now I can do it at home on the Mac, its great!

Thanks again!

Nelly
Nelly is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript Wrapper Application for Kindlegen pdurrant Kindle Formats 50 02-18-2020 01:16 AM
Kindlestrip Python script and AppleScript wrapper pdurrant Kindle Formats 137 08-15-2017 01:16 AM
Useful Applescript for Mac OS X users pdurrant Kindle Formats 11 07-23-2011 05:00 AM
Unutterably Silly Tech-Button-Thingy for Logo beachwanderer Lounge 1 03-30-2009 10:02 AM
When using calibre newspaper download thingy Dragoro Amazon Kindle 6 03-10-2009 09:02 AM


All times are GMT -4. The time now is 07:32 PM.


MobileRead.com is a privately owned, operated and funded community.