From f53a6a49c684e3cd88d8bd4a6c207ac6ff012d45 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Wed, 25 Sep 2024 15:33:51 +0000 Subject: new filters and update --- filters/email-libravatar-hover.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 filters/email-libravatar-hover.py (limited to 'filters/email-libravatar-hover.py') diff --git a/filters/email-libravatar-hover.py b/filters/email-libravatar-hover.py new file mode 100755 index 0000000..352122b --- /dev/null +++ b/filters/email-libravatar-hover.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import sys +import hashlib +import codecs +import os + +# Read and process the email address from command line arguments +email = sys.argv[1].lower().strip() +if email[0] == '<': + email = email[1:] +if email[-1] == '>': + email = email[:-1] + +# Read the page argument (not used in this script but passed for compatibility) +page = sys.argv[2] + +# Ensure correct encoding for stdin and stdout +sys.stdin = codecs.getreader("utf-8")(sys.stdin.detach()) +sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) + +# Calculate MD5 hash of the email +md5 = hashlib.md5(email.encode()).hexdigest() + +# Read the standard input to get the buffer text +buffer = sys.stdin.read().strip() + +# Determine the base URL based on HTTPS environment variable +baseurl = "https://seccdn.libravatar.org/" if os.getenv("HTTPS") else "http://cdn.libravatar.org/" + +# Generate the HTML output with Libravatar images +html_output = ( + f"" + f"Libravatar" + f"Libravatar" + f" {buffer}" +) + +# Print the HTML output +print(html_output) -- cgit v1.2.3-59-g8ed1b