aboutsummaryrefslogtreecommitdiff
path: root/scripts/mailing-list-import-mbox.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2019-06-01 18:44:37 -0300
committerEuAndreh <eu@euandre.org>2019-06-01 18:44:37 -0300
commit329bc86a71e32397a131350a7bec26cdaa5a1271 (patch)
tree9d5d816d15940e345e70d3f3c3eb32b23328124b /scripts/mailing-list-import-mbox.sh
parentAdd dosfstools to install.sh nix-shell declaration (diff)
downloaddotfiles-329bc86a71e32397a131350a7bec26cdaa5a1271.tar.gz
dotfiles-329bc86a71e32397a131350a7bec26cdaa5a1271.tar.xz
WIP: add scripts/mailing-list-import-mbox.sh
Still only beginning to work, and only for GNU mailing lists.
Diffstat (limited to 'scripts/mailing-list-import-mbox.sh')
-rwxr-xr-xscripts/mailing-list-import-mbox.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/scripts/mailing-list-import-mbox.sh b/scripts/mailing-list-import-mbox.sh
new file mode 100755
index 0000000..b0bb8ae
--- /dev/null
+++ b/scripts/mailing-list-import-mbox.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+#!/usr/bin/env nix-shell
+#!nix-shell --pure -i bash -p bash
+# shellcheck shell=bash
+set -Eeuo pipefail
+
+MAILING_LIST_NAME="${1:-}"
+GNU_MBOX_ARCHIVE_URL='ftp://lists.gnu.org'
+OUT_MAILDIR="$HOME/mbsync/EuAndreh/mailing-lists/"
+TMP_DIR="$HOME/tmp/mbox-import/"
+usage() {
+ cat <<EOF
+Usage:
+ $0 MAILING_LIST_NAME
+
+ Arguments
+ MAILING_LIST_NAME The name of the mailing list.
+
+Examples:
+ Download and import into mbsync the MBOX archive from info-guix mailing-list:
+ echo 1 | mailing-list-import-mbox.sh info-guix
+
+ Download and import into mbsync the contents for lisp-br Google Groups:
+ echo 2 | mailing-list-import-mbox.sh lisp-br
+EOF
+}
+
+set -x
+gnu_mailing_list_import() {
+ mkdir -p "${TMP_DIR}"
+ pushd "${TMP_DIR}"
+ wget -c -r "${GNU_MBOX_ARCHIVE_URL}/${MAILING_LIST_NAME}/"
+ cat "lists.gnu.org/${MAILING_LIST_NAME}/"* > "${MAILING_LIST_NAME}.all.mbox"
+ mb2md -s "${TMP_DIR}/${MAILING_LIST_NAME}.all.mbox" -d "${OUT_MAILDIR}"
+ popd
+}
+
+google_groups_import() {
+ echo "google groups ${MAILING_LIST_NAME}"
+}
+
+main() {
+ [[ -z "${MAILING_LIST_NAME}" ]] && {
+ red "Missing input argument MAILING_LIST_NAME.\n"
+ usage
+ exit 2
+ }
+
+ echo "(1) - GNU mailing lists (lists.gnu.org)"
+ echo "(2) - Google Groups"
+ read -p "Which type of mailing list do you want to import? " -n 1 -r
+ echo # Move to a new line
+ case "$REPLY" in
+ "1")
+ gnu_mailing_list_import
+ ;;
+ "2")
+ google_groups_import
+ ;;
+ *)
+ red "Unsupported mailing list type."
+ red "Exitting."
+ usage
+ exit 2
+ ;;
+ esac
+}
+
+main "$@"
+
+# notmuch search --output=files tag:spam \
+ # and not folder:${PREFIX}junk \
+ # and not folder:${PREFIX}greyspam \
+ # and not folder:Koumbit/INBOX \
+ # and not path:Koumbit/** \
+ # | while read file; do
+# mv "$file" "$HOME/Maildir/${PREFIX}junk/cur"
+# done
+
+
+# notmuch search --output=files --exclude=false tag:deleted | xargs -I{} rm "{}"
+
+
+
+# https://julien.danjou.info/why-notmuch-is-not-much-good/
+# https://www.reddit.com/r/emacs/comments/6z13yw/notmuch_vs_imap_and_sieve/
+# https://anarc.at/blog/2016-05-12-email-setup/
+# https://duckduckgo.com/?q=notmuch+sieve&t=ffab&atb=v166-1&ia=web