#! /bin/sh # Script to generate (invalid) HTML file from places.sqlite DB # Copyright (C) 2009 Matous J. Fialka, # Released under the terms of The MIT License # Hint: bmh ~/.conkeror.mozdev.org/conkeror/xxxxxxxx.default/places.sqlite | elinks -force-html # Note: this script is crap! if [ "|"$1"|" == "||" ]; then exit 1 fi if [ -r $1 ]; then cp $1 /tmp/places.sqlite.tmp || exit 2 fi sqlite3 /tmp/places.sqlite.tmp ' SELECT b.id, p.url, p.title, b.title FROM moz_bookmarks b INNER JOIN moz_places p ON b.fk = p.id ORDER BY b.id DESC ;' | \ awk -F'|' ' BEGIN { u = 0; printf("
\n")
}

{
	gsub($3, /^[[:blank:]]+/, "")
	gsub($4, /^[[:blank:]]+/, "")
	gsub($3, /[[:blank:]]+$/, "")
	gsub($4, /[[:blank:]]+$/, "");

	printf("%07d: %s\nRemarks: %s\nRaw URL: %s\n\n",
		($1),
		($2),
		($3 != "") ? $3 : ("Untitled #" ++u),
		($4 == $3) ? "None" : (($4 != "") ? $4 : "None"),
		($2))
}

END {
	printf("
\n") exit(0); }' if [ -w /tmp/places.sqlite.tmp ]; then rm -f /tmp/places.sqlite.tmp || exit 3 fi exit 0