diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2021-02-20 10:39:25 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2021-02-20 10:39:25 -0300 |
commit | c88ec356e8cb417d84c8712b00c8921263c0813c (patch) | |
tree | ef21ca4650f1ed9f881fd215eb38eb8e0156989a | |
parent | 294bcbb4dbea571f417dc3be6de6d32c0a956bba (diff) | |
download | scripts-c88ec356e8cb417d84c8712b00c8921263c0813c.tar.gz scripts-c88ec356e8cb417d84c8712b00c8921263c0813c.tar.bz2 |
Fix: export-firefox-bookmarks: support for a single profile
-rwxr-xr-x | export-firefox-bookmarks | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/export-firefox-bookmarks b/export-firefox-bookmarks index 8347211..45878dd 100755 --- a/export-firefox-bookmarks +++ b/export-firefox-bookmarks @@ -4,10 +4,37 @@ # Based on https://github.com/pirate/ArchiveBox/blob/master/bin/export_browser_history.sh # -# Base folder to work on -BASEDIR="$HOME/.mozilla" +# Parameters +BASENAME="`basename $0`" +BASEDIR="$HOME/.mozilla/firefox" +PROFILES="$BASEDIR/profiles" +PROFILE="$1" +#SECTION="moz_${2:-bookmarks}" + +# Export from a single database +function export_firefox_bookmark { + sqlite3 $1 "SELECT \"[\" || group_concat(json_object('timestamp', b.dateAdded, 'description', b.title, 'href', f.url)) || \"]\" FROM moz_bookmarks AS b JOIN moz_places AS f ON f.id = b.fk" +} + +# Check +#if [ ! -e "$BASEDIR/profiles.ini" ]; then +# echo "$BASENAME: not found: $BASEDIR/profiles.ini" +# exit 1 +#fi + +#PROFILES="grep "^Name=" $BASEDIR/profiles.ini | cut -d = -f 2 | xargs" # There might be many places.sqlite on many profiles -find $BASEDIR -name places.sqlite | while read file; do \ - sqlite3 $file "SELECT \"[\" || group_concat(json_object('timestamp', b.dateAdded, 'description', b.title, 'href', f.url)) || \"]\" FROM moz_bookmarks AS b JOIN moz_places AS f ON f.id = b.fk" -done +if [ -z "$PROFILE" ]; then + find $BASEDIR -name places.sqlite | while read file; do \ + export_firefox_bookmark $file + done +else + # Assumption: when a $PROFILE is given, search at $PROFILES + if [ -e "$PROFILES/$PROFILE/places.sqlite" ]; then + export_firefox_bookmark $PROFILES/$PROFILE/places.sqlite + else + echo "$BASENAME: file not found: $PROFILES/$PROFILE/places.sqlite" + exit 1 + fi +fi |