Skip to content

Instantly share code, notes, and snippets.

@rustybird
Last active December 9, 2022 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rustybird/3cd28096c640ff77c936cd72ba573ffd to your computer and use it in GitHub Desktop.
Save rustybird/3cd28096c640ff77c936cd72ba573ffd to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# "Manage Bookmarks" (Ctrl-Shift-o) - "Import and Backup" - "Backup..."
# split-browser-bookmark-json2tsv <bookmarks-2022-03-04.json >>bookmarks.tsv
# (Conversion happens in a diposable qube, which must have jq installed.)
set -e -u -o pipefail
jq_filter='recurse(.children[]?) |
select(.typeCode==1) |
(.dateAdded | tostring) + "\t" + .uri + "\t" + (.title | gsub("[\t\n]"; " "))'
qvm-run-vm @dispvm "jq -r ${jq_filter@Q}" |
LC_ALL=C stdbuf -oL tr -c '\040-\176\t\n' _ |
grep -Ex $'[0-9]{15,16}(\t[^\t]+){2}' |
sort -sn |
uniq |
while IFS=$'\t' read -r microseconds url title; do
date=$(date --rfc-3339=seconds --date=@$(( microseconds / 1000000 )))
printf '%s\t%s\t%s\n' "$date" "$url" "$title"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment