Friday, July 11. 2008
D recently bought one of those new-fangled Amazon Kindle thingies for purchasing and reading books in an electronic form. (She loves it.)
I like to read books in an electronic form on my iPhone, but find that it’s pretty hard to come by them legally; there are many different sellers and formats, some of which have certain books but not others. Sometimes they have the book, but not in a format I can do anything with. It’s generally easier just to illegally download them from torrent sites.
Amazon has tons and tons of books available for Kindle, and have chosen the standard MobiPocket format as the one their reader uses, meaning it is theoretically trivial to purchase them and convert them to something else. Except that they won’t sell them to you unless you have already purchased a $400ish Kindle on which to read them. Meaning you don’t need to convert them…
In any case, now that our household has a Kindle, it frees me up to purchase books from Amazon in Kindle format without actually having a Kindle myself. I then just remove the DRM that Amazon puts in the files (to keep people from converting them, natch), and then convert them to HTML or txt to read in Books.app on iPhone. Want to know how to do the same thing?
Howto:
Step 1) Find someone with a Kindle.
Step 2) On their Kindle, go to the Settings menu, and type ‘411’ on the keypad. This will bring up a little information dialog with a bunch of things in it, of which you only need the Serial. It is a 16-character string of letters and numbers. Write it down.
Step 3) Ask the Kindle’s owner to buy a book for you. Give them some money so you don’t look like a mooch. Once you’ve given them the money, ask them to log in to their Amazon account and navigate to their ‘Kindle Downloads‘ page from your computer. When they complain, mention that you’ve already given them money. The Kindle Downloads page will list all the books they’ve purchased, and yours should be right at the top. Click ‘Download to computer’ and you’ll get a file named ‘Title-of-Book.azw’
Step 4) Download MobiDeDRM.zip, which is a small suite of Python scripts that some kind soul wrote and then distributed through links that expire all the time and can be kind of a pain to track down. I’ve hosted them from my site so that they won’t expire. This .zip file contains mobidedrm.py, mobidedrm2.py, kindlepid.py and mobihuff.py.
(These scripts require that you install Python on your system, which is something outsite the scope of this howto. I’m on linux, but there’s a Python for Windows called “ActiveState Python.” Google will help.)
After unzipping the archive, open up a terminal window and pass the Kindle’s serial # (which you previously wrote down) to kindlepid.py. Something like this:
python kindlepid.py XXXXXXXXXXXXXXXX
Where all those Xs are replaced with the Kindle serial number. It will return something that looks like this:
Mobipocked PID for Kindle serial# XXXXXXXXXXXXXXXX is Z1QFCDQ*74
Make note of that last 10-character gibberish. That’s the secret code (or PID) we’ll need to remove the DRM from any books purchased for that Kindle.
Step 5) Now it’s time to remove the DRM. Do this:
python mobidedrm.py Title-of-Book.azw Title-of-Book.mobi Z1QFCDQ*74
where my 10-character gibberish string is replaced with the one you made note of in the last step. This will take about a minute, and when it finishes you’ll see:
Decrypting. Please wait... done
Now you will have a decrypted MobiPocket-formatted ebook that you can read in any MobiPocket reader.
If, however, you want to convert it to HTML to read on any device you wish, you’ll want to install MobiPerl. (This, of course, will require you to install Perl. MobiPerl’s website will walk you through that.)
6) With MobiPerl installed, do this:
mobi2html Title-of-Book.mobi
This will create a directory named ‘unpacked’ that will contain Title-of-Book.html
Things that can go wrong:
Amazon seems to compress longer books in a slightly different manner than shorter books. If your resulting .mobi file and/or .html file are oddly gibberishy (for example, if the first line starts in the middle of a sentence, and clearly not the beginning of the book), let’s go back to step 5.
Step 5b) These ‘huffdic-compressed’ books require a slightly different script to remove the DRM. Do this:
python mobidedrm2.py Title-of-Book.azw Title-of-Book.mobi Z1QFCDQ*74
Note the ‘2’ in ‘mobidedrm2.py’ in this one and remember to replace my gibberish PID with yours.
6b) The ‘huffdic-compressed’ files also require a different script to convert them to HTML. Do this:
python mobihuff.py Title-of-Book.mobi Title-of-Book.html
This script will output the .html file in the directory from which you are running it.
All in all, this is as much of a pain as it looks, but the selection and availability of books on Amazon makes it worthwhile to me. They have far more books than The Pirate Bay does, and I feel better paying for them
Good luck.
Sunday, July 6. 2008
I’ve been recently toying with OpenID stuff, and found that it is far more useful than it seems at first glance. What’s not apparent is that if you have a website, you can configure things to use its URL as your OpenID even if you’re using AOL/LiveJournal/MyOpenID.net/etc for your OpenID authentication. This allows you to re-configure it at a later date using any service you’d like, without having to change your OpenID sign-in info. It doesn’t get much more “open” than that.
It’s kind of complicated, and it requires a fair bit of reasearch to find the info you need to make it work, so people who are aware of this functionality probably don’t care enough to do the work. It’s with that in mind that I’ve done the research and created a little configurator-thingy to make it as easy as possible for anyone hosting a website to set this up.
Introducing MOREopenID.org. One selection and two input boxes gets you one file to upload to your server and a short block of tags to paste into your website’s head section, putting you in complete control of your OpenID identity forever. If you decide to change OpenID providers at some point, simply come back and do the steps again.
Things are still pretty rough at this stage, so I’d appreciate it if you wouldn’t social-network it to death (yet) or anything, but I’d be much obliged if you’d try it out and give me feedback on what I should do to make it better — and especially so if you have any problems. If any part of it at all is confusing, I would like to hear about it.
Thanks a ton.
Tuesday, May 22. 2007
Tired of nearly every video I watch on YouTube and Google video being displayed at the improper aspect ratio, I decided to do a little testing to determine just what you need to do to get your widescreen video to display correctly on these web video services.
First up, I decided to see whether either of these services respected the aspect ratio flag video encoders can set to alter the aspect ratio at playback time. This is most commonly seen on so-called “anamorphic” DVDs, where the video is encoded at 720×480, but is scaled up to 854×480 to display the picture at the proper 16:9 aspect ratio. This is the most efficient way to encode content, as you get the benefit of both a smaller resolution and proper widescreen playback. The problem, however, is that many lazily-coded applications such as freeware DVD rippers, freeware screenshot grabbers, Windows Media Player, etc ignore them completely, choosing to instead display them at the resolution at which it was encoded rather than the one at which it’s supposed to be played back. This results in tall skinny people — and one very annoyed internet curmudgeon. (That’s me.)
With this in mind, I crafted a short video that’s encoded at 320×240, but set to display at 426×240. (426 / 240 = ~1.78 = 16 /9)
It looks like this:
I then submitted said video to both YouTube and GooVid, resulting in this:
YouTube:
As you can see, both YouTube and GooVid ignore the aspect ratio setting. This method is right out.
Next up I decided to try pre-letterboxing the video to 4:3 before submitting. I suspected that both GooVid and YouTube would display them just fine. It looks like this:
YouTube:
GooVid:
As you can see, this worked OK, but it’s less than ideal. You have to increase the size of your file by encoding black bars, not to mention the extra effort required to add them. There’s got to be a better way. Let’s just try encoding the video at a resolution that matches the aspect ratio. I chose 426×240, but you can choose any resolution you want; just make sure that when you divide the width by the height you get as close to 1.78 as possible. As an easy reference, just take the desired height of your video, and multiply it by (16/9) in your calculator. (240 * (16/9) = 426) This is the proper width to which you’d scale your video. Let’s take a look at the results:
YouTube:
GooVid:
As you can see, this works flawlessly on both GooVid and YouTube, and is the best method to follow when preparing your widescreen video. No black bars. No fuss. No muss. (Hint: you can also use any aspect ratio you want. If your clip’s aspect ratio needs to be 1.5:1, then just encode the video such that the width is 1.5 times the height. So: 400×266.)
If you’d like to do the same test on any of the other video sites I don’t have accounts on, I’ve provided the videos below. If you do these tests, please let me know the results so I can update this page with them.
testaspect-320×240-16×9.avi, testaspect-320×240-4×3+Letterbox.avi, testaspect-426×240-16×9.avi
UPDATE: Emalyse submitted the test videos to dailymotion, wherein we learned that they too ignore the aspect ratio bit, and both pre-letterboxing to 4:3 and setting the video resolution to a 16:9 aspect work perfectly. Dailymotion goes one step further, not bothering to add in letterboxing, rather it just displays the video at the proper aspect. On Dailymotion the properly aspected resolution option becomes even more attracctive than the other video services.
Testaspect-320×240-16×9
Uploaded by emalyse
Testaspect-320×240-4×3+Letterbox
Uploaded by emalyse
Testaspect-426×240-16×9
Uploaded by emalyse
Friday, April 13. 2007
Tired of seeing this every time you use Firefox’s built-in RSS handling to add a site’s feed to your Google Reader account?
Me too, so I figured out a way to get rid of it. Now I’ll show you how too.
Simply type ‘about:config’ into your url bar, and as soon as all that scary-looking stuff loads, scroll down until you see ‘browser.contentHandlers.types.2.uri’, and then double click it.
A dialog will pop up asking for a uri, and will be pre-filled with ‘http://fusion.google.com/add?feedurl=%s’.
Simply replace it with ‘http://google.com/reader/preview/*/feed/%s’ then restart Firefox.
Next time you click on an RSS feed, you’ll see a preview of it in Google Reader, completely bypassing the option to add it to your Google homepage.
Note: You’ll need to actually click the ‘subscribe’ button in the preview window to subscribe, so the sum total of clicks will be the same, they just won’t be dealing with Google’s bad UI decision. Besides, it’s nice to see the contents of the feed before committing to it. I routinely change my mind if a feed is only a partial-text feed.
Friday, April 6. 2007
So you’ve got your blog all set up, you’ve been publishing for a while, and all of a sudden you learn that people have been “hotlinking” to your images. This outrages you, so you set up an .htaccess rule to replace any “hotlinked” images with a graphic that says “Stealing Images Makes You A Jerk!”
That ought to teach those jerks for stealing your images… right? Sure it will, but I’ve got a question for you: Do you have an RSS feed?
Oh, you do?
Well, you’ve also just prevented all those “jerks” who subscribe to your feed from “stealing” your images too. Wait, you want them to be able to see your images? Of course you do.
The trick is to set up your .htaccess file to allow certain websites to be able to display your images, while blocking everyone else. You’d do it by making your .htaccess file look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.)?livejournal.com(/)?.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?google.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?bloglines.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?newsgator.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?yahoo.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?rojo.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?newsburst.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?pluck.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?aol.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?msn.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?ixquick.com.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.)?skweezer.$ [NC]
RewriteRule /images/(.*).(jpg|jpeg|png|gif|bmp) /images/DoNotSteal.png [NC]
What that does is look to see if your image is being loaded from some other website. If it is it then checks to see if that website is one of the “approved” ones. If the site in question is in the list, the image is displayed normally — but if it’s not, your “Do Not Steal” graphic gets displayed instead.
That list is all of the online RSS aggregators I know of. If you want to add your friend’s site to your approved list, just copy one of the lines up there, substituting in the proper domain name. Don’t include the “www,” because that little “(.*)?” will match that if it’s there.
If you use a reader that’s not in that list, let me know so I can update the list here.
Friday, September 30. 2005
Earlier in the week I posted a little video of me doing a one-handed shuffle (badly), and said that if there was any interest, I’d post a more step-by-step instructional video. There was, so here I go.
I’d just like to take a second to say that if you’ve ever tried to do a one handed shuffle while making sure your shot is framed and your camera isn’t running out of space and trying to mentally think about what you’re saying and indicating with your hands, then you know just how difficult this is. I left in me spraying cards everywhere in so that you can see that while it happens alot at first, it happens less frequently as you get better. I’m pretty good at it, but it still happens to me.
During editing, I found that my verbalizations are neither coherent nor grammatically correct. I feel kind of stupid about saying things George W. Bush says from time to time, but I now understand what causes him to do it. “A little bit more fancier,” indeed.
In any case, here’s the video:
Continue reading "One Hand Shuffle Howto"
|
|