Skip to content

Instantly share code, notes, and snippets.

@guidocella
Last active November 3, 2023 19:47
Show Gist options
  • Save guidocella/a272b6e68f9c44532b011f6596e95c61 to your computer and use it in GitHub Desktop.
Save guidocella/a272b6e68f9c44532b011f6596e95c61 to your computer and use it in GitHub Desktop.
Convert qutebrowser's cookies to Netscape format
#!/bin/sh
{
echo '# Netscape HTTP Cookie File' # needed by youtube-dl
# There is no attempt to url encode $1, but SQLite already handles
# characters like spaces, so only ? % and # should cause issues.
sqlite3 -separator ' ' "file:${1:-$HOME/.local/share/qutebrowser}/webengine/Cookies?nolock=1" "
SELECT
host_key,
IIF(host_key LIKE '.%', 'TRUE', 'FALSE'),
path,
IIF(is_secure, 'TRUE', 'FALSE'),
IIF(expires_utc == 0, 0, expires_utc / 1000000 - 11644473600),
name,
value
FROM cookies;"
} > $XDG_RUNTIME_DIR/cookies.txt
# expires_utc is converted from the Windows NT Time Format to a UNIX timestamp
@dirkf
Copy link

dirkf commented Aug 25, 2023

Also, could this be rendered as a qutebrowser userscript?

@guidocella
Copy link
Author

It should run fine as a userscript. You can even use $QUTE_DATA_DIR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment