acpid: inc/dec brightness by 1 instead of 10
[julm/julm-nix.git] / nixpkgs / overlays / podl.sh
index 30b49a36ef7d09ccbfa0b0afe8ece426c694e0b0..c73018b9928686edc99025611e1f655b0db293c3 100644 (file)
@@ -1,11 +1,12 @@
 #!/usr/bin/env bash
 # shellcheck disable=SC1004
 # shellcheck disable=SC2016
+# shellcheck disable=SC2064
 # shellcheck disable=SC2086
 # shellcheck disable=SC2155
 # Name: podl - podcast downloader with caching
 # Version: 2021-10-22
-# Last version: https://git.code.sourcephile.fr/~julm/julm-nix/tree/main/item/nixpkgs/overlays/podl.sh
+# Latest version: https://git.sourcephile.fr/julm/julm-nix/tree/main/item/nixpkgs/overlays/podl.sh
 # Synopsis:
 #   $ mkdir LaMéthodeScientifique 3Blue1Brown
 #   $ echo >LaMéthodeScientifique/.feed http://radiofrance-podcast.net/podcast09/rss_14312.xml
 #   it creates next to those ".feed" files;
 #   avoiding the cost of network activity when not necessary.
 # Environment:
-#   - $SKIP_DOWNLOAD: if set, skip the download command
+#   - $PODL_SKIP_DOWNLOAD: if set, skip the download command
 #     but still register the entry in ".downloaded".
 #     Useful when adding the feed if you only want
 #     a few entries from the feed:
-#     run SKIP_DOWNLOAD=set podl, then edit ".downloaded"
+#     run PODL_SKIP_DOWNLOAD=set podl, then edit ".downloaded"
 #     to remove the entries you want, then run podl again.
 #     This trick does not work with ".page" downloads.
 #   - $YT: options passed to yt-dlp.
-#   - $XTRACE: if set, enables set -x on the generated commands.
+#   - $PODL_XTRACE: if set, enables set -x on the generated commands.
 # Files:
 #   - ".yt-dlp": optional yt-dlp config,
 #     (looked up in parent directories).
@@ -76,7 +77,7 @@ while IFS= read -r found; do
   case $found in
    (*/.page)
     yt-dlp $YT \
-     ${SKIP_DOWNLOAD:+--skip-download} \
+     ${PODL_SKIP_DOWNLOAD:+--skip-download} \
      --download-archive .downloaded \
      --batch-file "$src"
     ;;
@@ -135,7 +136,7 @@ while IFS= read -r found; do
             grep -qxF -e "url $url" -e "guid $guid" .downloaded || {
               published=$(date +%Y-%m-%d -d "$published")
               echo >&2 "$dst/$published - $title"
-              if test ! "${SKIP_DOWNLOAD:+set}"
+              if test ! "${PODL_SKIP_DOWNLOAD:+set}"
               then
                 yt-dlp $YT \
                  --output "$published - ${title//%/%%}.%(ext)s" \
@@ -160,7 +161,7 @@ while IFS= read -r found; do
             grep -qxF "youtube $id" .downloaded || {
               published=$(date +%Y-%m-%d -d "$published")
               echo >&2 "$dst/$published - $title.$id"
-              if test "${SKIP_DOWNLOAD:+set}"
+              if test "${PODL_SKIP_DOWNLOAD:+set}"
               then
                 { flock --exclusive 3
                   echo >&3 "youtube $id"
@@ -168,13 +169,15 @@ while IFS= read -r found; do
               else
                 yt-dlp $YT \
                  --download-archive .downloaded \
-                 --output "$published - ${title//%/%%}.%(id)s.%(format_id)s.%(ext)s" \
+                 --output "%(release_date>%Y-%m-%d,upload_date>%Y-%m-%d|$published)s - ${title//%/%%}.%(id)s.%(format_id)s.%(ext)s" \
                  "$url"
               fi
             }
            ';;
       esac |
-      "$SHELL" -seu${XTRACE:+x}
+      "$SHELL" -seu${PODL_XTRACE:+x}
+      rm -f '$file'
+      trap '' EXIT
       )
     done;;
   esac