Bookmark Scrubber : Python Script


Quick View

Here's how to use the Bookmarks Scrubber Python script in a nutt shell:
prompt> bkmkscrub.py --help
Usage: bkmkscrub.py [options]

Options are:
	-h --help                This usage message.

	-o filename              Output results to [ filename ]
	--output=filename        or else, output to [ stdout ].

	-i filename              Read JSON data from [ filename ]
	--input=filename         or else, read data from [ stdin ].

	-f --flip                Flip first sub-children list order.
	                         Note: flag is ignored during -H --HTML

	-s --scrub               Scrub [ DO_NOT_EXPORT ] JSON entries.

	-t title                 Additional FOLDERS (titles) to scrub out.
	--scrubtitles=title      This can be stacked.

	-H --HTML                Generate HTML bookmarks instead of JSON data.

Flip option:
	The Firefox Bookmark Organizer's restore feature flips the first
	sub-children list.  This option "fixes up" the streamlined data
	for the restore procedure to work properly.

Scrub Title option:
	An optional array parameter that specifies additional folders to
	"scrubout".  This can be used to filter folders which do not have
	description boxes (i.e. "Bookmarks Menu", "Tags", "Unsorted
	Bookmarks", etc.). 
	This can be stacked: --scrubtitle=title1 --scrubtitle=title2 etc.

View the bookmark scrubber Python script.


Streamlined Output: JSON

The JSON text data will be output to a human readable format, with nested indenting on all children lists and contain the a minimum number of entries for the Firefox Bookmark Organizer's import feature to work.

Restore Issues
The Bookmark Organizer's restore feature does something strange to the first sub-children list. Here's what I mean. This is what the original order is for the Toolbar:

But importing the streamlined JSON data shows this:

The first sub-children array is restored flipped. (Again, this only happends on the first children.children array. All other sub-of-a-sub children array are treated as you would expect it to.)

Long story short, there is no need for the following values in the streamlined version (but found in the original bookmark JSON data):

I can see a need for this in a SQL database. But it is not necessary for the importer to work.

Why not use the index value to sort this out properly? If one items gets inserted in the list (say at the top) causing everyone else to shift down by one - the index number causes every item in that list to CHANGE. A big no-no as far as I'm concerned when trying to keep this diff-edit-merge friendly. To help make the Bookmark Organizer's restore feature to function properly, there's an option to "fixup" the streamlined data.

	-f --flip                Flip first sub-children list order.
	                         Note: flag is ignored during -H --HTML

Flip option:
	The Firefox Bookmark Organizer's restore feature flips the first
	sub-children list.  This option "fixes up" the streamlined data
	for the restore procedure to work properly.

Scrubbed Output: JSON & HTML

The option to generate a scrubbed output is:
	-s --scrub               Scrub [ DO_NOT_EXPORT ] JSON entries.
Note: Tags & Unsorted Bookmarks are still scrubbed out reguardless of the scrub flag settings. [1]

When an item (page or folder) has "DO_NOT_EXPORT" in the description box - the entry will be SCRUBBED from the generated file. Why the description box and not tags? There are no tag entries for folders.

The scrub option also automatically filters any bookmarks that finds the following matches in the URI:

An additional list of folders to scrub can be passed in:

	-t title                 Additional FOLDERS (titles) to scrub out.
	--scrubtitles=title      This can be stacked.

Scrub Title option:
	An optional array parameter that specifies additional folders to
	"scrubout".  This can be used to filter folders which do not have
	description boxes (i.e. "Bookmarks Menu", "Tags", "Unsorted
	Bookmarks", etc.). 
	This can be stacked: --scrubtitle=title1 --scrubtitle=title2 etc.

Why only folders and not also bookmarks? This option was meant to be on the fly, massive gross culling and flexible. I feel that bookmarks needs to be handled a little bit more delicately. Whereas folders (text/x-moz-place-container) can be used with an ax.


Notes

[1] What happened to "Tags" & "Unsorted Bookmarks"? These are those "root" folders that are seen in the Bookmark Organizer. They will be automatically omitted from the generated files just like how the Bookmark Organizer's HTML exporter omits them as well.


Copyright © 2010 by ESTSS. All Rights Reserved.