This is Google's cache of http://bilbo.online.bg/~assen/cng.htm. It is a snapshot of the page as it appeared on Dec 17, 2011 03:39:56 GMT. The current page could have changed in the meantime. Learn more

Text-only version
 
Hacking Complete National Geographic

Hacking Complete National Geographic

by Assen Totin <assen at online dot bg>

Note: There is neither illegal content here nor anything targeted at circumventing copyright. Hacking is not about that. Hacking is about fun and Linux is about fun too.

This article will show you two things:

  1. How to get the Complete National Geographic work on your Linux machine, and
  2. How to get rid of the nasty DVDs you need to change so often.

1. Getting Complete National Geographic to work on a Linux host

Wouldn't it be nice if the Complete National Geographic (CNG) with its more than 1,200 issues could be installed on your Linux machine (although it "officially" only runs on Windows and MacOS)? Well, it can and is easier than one would expect.

First, go buy a copy from the NG store. You can chose from the 6 DVD set or a hard-disk version. Since the HDD is up to 3 times more expensive than the DVD set, the choice seems obvious.

Second, find your ways around. The NGC application is nothing more than a Flash movie (SWF), albeit packed in a fancy Adobe AIR wrapper. So, you'll need Adobe AIR:

After setting up AIR you'll get a menu entry in your desktop menu, usualy in Accessories, called "Adobe AIR Installer". We'll need it shortly.

Third, get the CGN application itself. It comes in a cross-platform .air package, but (amazingly!) you won't find it on the DVDs - instead there are Windows and MacOS OS-dependent installers. So, better go for the real thing and get it on the net: http://www.nationalgeographic.com/updates/products/cng120/cng120/air/CNGViewer-latest.air . Be prepared for its size, some 100+ MB!

As you can easily guess, the CNG viewer has to be installed system-wide. This means, you have (or the installer has) to be root when installing it. Here comes the fun: Adobe AIR does not know how to ask you for super-user privileges (i.e. how to ask for the root password and how to spawn a root process), therefore, the installation will fail unless you take a good care; even worse, it will fail silently without telling you anything: bad programming, indeed!:

You'll notice your system does quite some work installing the viewer; this is because it will first build an RPM, .deb or whatever your system requires and will then install it (a rather unusual, to say the least, approach for simply copying a flash movie and a dozen of pictures). So, be patient.

When the setup is complete, you should be able to run CNG - it will ask you for the fist DVD. As with other Adobe's attempts on Linux, it is also slow and consumes a lot of CPU - be ready for this.

If you don't want to constantly swap DVDs for CNG, read on.

2. Getting rid of the nasty DVDs

I'm not going to discuss whether copying the DVDs to the hard disk of your PC violates any copyright; as I only do it for my own convenience and do not share the files outside the usual family circle (whom I can also give the physical discs should need arise), I conider my actions to be legitimate. If you disagree, stop reading now.

First things first: copy the DVDs to your had drive. You'll need about 50 GB of space (disks are dual-layer). On each disk you'll find a directory named "disc1", "disc2" etc. - these are the ones we need. On the first disc there are also Windows and MacOS installers as well as some other stuff you can safely skip.

When finished copying, merge all files and sub-directories under the "disc1" directory:

for i in {2..5}; do mv disc$i/* disc1; rm -rf disc$i; done

Fix file permissions:

cd disc1

chown -R root.root *

chmod -R 755 *

Second, we need to figure out how to tweak CNG into using HDD instead of DVDs. We'll exploit a weakness in the AIR's desing: it has no built-in detection for optical disk drives; instead, an application should probe known locations for known files. Indeed, running "strace" on the application reveals that is simply probes for "disc1", "disc2" etc. in all first-level directories inside two popular mount points: /mnt and /media. If it finds one, it uses its number to figure out which disc is inserted. Therefore, all we need is set up a symlink under "/mnt" to the "disc1" directory:

ln -s "path to your disc1 directory" /mnt/disc1

The final task is to fix CNG applciation to seek all files under the same "disc1" directory (i.e. make ot "forget" it was originally constructed for a set of 6 discs). Looking around the CGN directory as well as user's home directory shows that CNG creates a user directory in ~/.appdata naming it rather unfiendly with a long name plus some random charactes in the end:

com.nationalgeographic.products.cng120.68B1CC4249876152EBE333BD4B7514ADB4D94062.1

If it is not there, run the CNG once and it will create it.

Inside it you'll find another directory named "Local Store"; go for it. Inside there lies a hidden treasure, a file which holds everything we need: a SQLite database. Make a backup copy in case something goes wrong:

cp cnguser.sqlite3 cnguser.sqlite3.orig

The, run the sqlite broswer againts it (you might need to apt-get or yum it, but you should know how to do it).

sqlite3 cnguser.sqlite3

Looking around the database shows we need to update two tables:

a) the "discs" table which lists the discs and serves as a key for lookup of each issue's location; it also lists the size of each DVD (although the rationale behind this remains a mystery). We'll play their game: update the first record with the summary size of all 6 discs and then delete the rest 5 records:

update discs set size_mb=46157 where id=1;

delete from discs where id>1;

b) the "issue_links" table that says which isse on which disc resides; obviously, we want all isues to point to the first disc:

update issue_links set disc_id=1;

.exit

Well, thats it :-) Wasn't that hard, yep? As I sad, Linux is about hacking and hacking is fun. Enjoy your Complete National Geographic, now on Linux and completelly liberated from DVD swapping!