add kvpairs2td
[hband-tools.git] / user-tools / convert_chromium_cookies_to_netscape.sh
blob764fdfd6efdb8b5314de078378a596f6d0a044a4
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 convert_chromium_cookies_to_netscape.sh - Convert Chromium and derivative web browser's cookies to Netscape format (used by wget and curl)
10 =cut
12 EOF
15 set -e
16 set -u
18 if [ -z "${1:-}" ]
19 then
20 sql_where=1
21 else
22 hostset=''
23 for host in "$@"
25 hostset="$hostset${hostset:+,}'.$host','$host'"
26 done
27 sql_where="host_key IN ($hostset)"
30 vivaldiCookieFile=~/.config/vivaldi/Default/Cookies
32 LD_PRELOAD=/usr/lib/yazzy-preload/ignore_read_lock.so \
33 sqlite3 -noheader "$vivaldiCookieFile" .dump 2>/dev/null |\
35 sed -e '/^CREATE INDEX/d'
36 echo "SELECT host_key, path, name, secure,
37 strftime('%s', datetime(expires_utc / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch')),
38 hex(encrypted_value)
39 FROM cookies WHERE $sql_where;"
40 }|\
41 sqlite3 -list -noheader :memory: 2>/dev/null |\
42 CHROMIUM_DECRYPT_PASS=peanuts chromium_cookie_decrypt.py 5 |\
44 while read -r host_key path name secure expireTimestamp value
46 host_key=${host_key#.}
47 [ secure = 0 ] && issecure=FALSE || issecure=TRUE
49 echo "$host_key TRUE $path $issecure $expireTimestamp $name $value"
50 done