From 6e6710a07421b6f6d220173709f31b77bd72d140 Mon Sep 17 00:00:00 2001
From: Gregor Kleen <gkleen@yggdrasil.li>
Date: Sun, 22 Mar 2020 21:56:53 +0100
Subject: ...

---
 odin/strm.nix              |  4 ++--
 odin/strm/download_youtube | 11 ++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/odin/strm.nix b/odin/strm.nix
index 70034404..8fe4a68b 100644
--- a/odin/strm.nix
+++ b/odin/strm.nix
@@ -1,5 +1,5 @@
 { stdenv
-, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, rolling-directory
+, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, rolling-directory, qprint, coreutils
 , buildPerlPackage, perlPackages
 }:
 
@@ -46,7 +46,7 @@ in stdenv.mkDerivation {
 
   phases = [ "unpackPhase" "buildPhase" "installPhase" ];
 
-  inherit zsh pv notmuch rss2email;
+  inherit zsh pv notmuch rss2email coreutils qprint;
   ffmpeg = ffmpeg-full;
   youtubedl = youtube-dl;
   rollingdirectory = rolling-directory;
diff --git a/odin/strm/download_youtube b/odin/strm/download_youtube
index ccb3a7bc..72dcd40a 100644
--- a/odin/strm/download_youtube
+++ b/odin/strm/download_youtube
@@ -74,9 +74,18 @@ printf ">>> %s <<<\n  %s\n" "${msgId}" "${message}"
       tmpFile=$(mktemp --tmpdir=/home/gkleen/rss/tmp .writeOut.XXXXXX)
       printf "Decoding base64 message content for ā€˜%s’" ${message}
       sed '/^Content-Transfer-Encoding: */d; /^$/q' ${message} >! $tmpFile
-      sed '1,/^$/d' ${message} | base64 -d >> $tmpFile
+      sed '1,/^$/d' ${message} | @coreutils@/bin/base64 -d >> $tmpFile
       mv -v $tmpFile ${message}
   fi
+  
+  if [[ 'quoted-printable' == $(sed '/^Content-Transfer-Encoding: */!d; s///;q' ${message}) ]]; then
+      tmpFile=$(mktemp --tmpdir=/home/gkleen/rss/tmp .writeOut.XXXXXX)
+      printf "Decoding quoted printable message content for ā€˜%s’" ${message}
+      sed '/^Content-Transfer-Encoding: */d; /^$/q' ${message} >! $tmpFile
+      sed '1,/^$/d' ${message} | @qprint@/bin/qprint -d >> $tmpFile
+      mv -v $tmpFile ${message}
+  fi
+
 
   from=$(mungefilename $(awk '/^From/ { gsub("^\"", "", $2); print $2; exit; }' "${message}"))
   if grep -q "<p>Enclosure: <a" "${message}"; then
-- 
cgit v1.2.3