From 13dc837a52f34c75c144100d38405cbc8e3cb77c Mon Sep 17 00:00:00 2001 From: Florian Stecker Date: Wed, 20 Nov 2024 11:44:35 -0500 Subject: [PATCH] Add description preview --- podcast | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/podcast b/podcast index 19c122e..4230375 100755 --- a/podcast +++ b/podcast @@ -1,21 +1,19 @@ #!/bin/bash -DIR="/home/stek/Dateien/podcasts" -cd "$DIR" +cd "$(dirname "$(realpath "$0")")" if [ "$1" == "sync" ]; then cat "urls"| while read url; do - curl -s -o .tmp.rss-file "$url" - name="$(cat .tmp.rss-file | xq -r '.rss.channel.title')" - mv .tmp.rss-file "${name}.rss" - echo "Updated \"$name\"" + curl -s -o .tmp.rss-file "$url" + name="$(cat .tmp.rss-file | xq -r '.rss.channel.title')" + mv .tmp.rss-file "${name}.rss" + echo "Updated \"$name\"" done elif [ "$1" == "play" ]; then - rss_file="$(ls -1 *.rss | fzf)" - nr=$(cat "$rss_file" | xq -r '.rss.channel.item[].title' | nl -v0 -w1 -s ' ' | fzf --with-nth=2.. --no-sort | cut -d " " -f 1) + rss_file="$(ls -1 *.rss | sed 's/\(.*\)\.rss/\1/g' | fzf).rss" + nr=$(cat "$rss_file" | xq -r '.rss.channel.item[].title' | nl -v0 -w1 -s ' ' | fzf --with-nth=2.. --no-sort --preview "cat \"$rss_file\" | xq -r '.rss.channel.item[{1}].description' | html2text --body-width=\$FZF_PREVIEW_COLUMNS" --bind 'ctrl-p:toggle-preview' --preview-window hidden | cut -d " " -f 1) if [ "$nr" != "" ]; then - echo "Play #$nr"; - mpv "$(cat "$rss_file" | xq -r ".rss.channel.item[$nr].enclosure.\"@url\"")" --no-audio-display + mpv "$(cat "$rss_file" | xq -r ".rss.channel.item[$nr].enclosure.\"@url\"")" --no-audio-display fi fi