warbo-utilities: 5f308002e6fbd8753843e86d3439d21b1d1b344a
1: #!/usr/bin/env bash
2:
3: shopt -s nullglob
4: echo "Looking for YouTube vids" 1>&2
5: NAMES=()
6: while read -r NAME
7: do
8: NAMES+=("$NAME")
9: done < <(grep '^youtube' < "$HOME/.feeds" | cut -f2)
10:
11: function msg {
12: read -r -p "Should we get '$1' video '$2'? (Yes/no/read) " answer
13: [[ -z "$answer" ]] && answer=y
14: answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]' | cut -c1)
15: }
16:
17: for NAME in "${NAMES[@]}"
18: do
19: DIR="$HOME/Mail/feeds/$NAME"
20: [[ -d "$DIR" ]] || continue
21: for F in "$DIR"/new/*
22: do
23: URL=$(grep '^Link: ' < "$F" | head -n1 | grep -o 'http.*' |
24: grep 'youtube.com')
25: [[ -n "$URL" ]] || continue
26: WEBTITLE=$(youtube-dl -e "$URL")
27: MSGTITLE=$(grep '^Subject: ' < "$F" | sed -e 's/^Subject: //g')
28: if [[ -n "$WEBTITLE" ]]
29: then
30: TITLE="$WEBTITLE"
31: else
32: TITLE="$MSGTITLE"
33: fi
34:
35: msg "$NAME" "$TITLE"
36: case "$answer" in
37: y)
38: echo "Queueing" 1>&2
39: pushd "$HOME/Downloads" > /dev/null || exit 1
40: # shellcheck disable=SC2154
41: ts "$youtube_then_mark" "$F" "$URL"
42: popd > /dev/null || exit 1
43: ;;
44: r)
45: echo "Marking as read" 1>&2
46: markRead "$F"
47: ;;
48: n)
49: echo "Skipping" 1>&2
50: ;;
51: esac
52: done
53: done
54:
55: echo "Looking for TED talks" 1>&2
56: for F in "$HOME"/Mail/feeds/TEDTalks/new/*
57: do
58: [[ -e "$F" ]] || continue
59: TITLE=$(grep '^Subject: ' < "$F" | cut -d ' ' -f2-)
60: msg "TED Talk" "$TITLE"
61: case "$answer" in
62: y)
63: URL=$(grep '^Link: ' < "$F" | cut -d ' ' -f2-)
64: echo "Queueing" 1>&2
65: pushd "$HOME/Downloads" > /dev/null || exit 1
66: # shellcheck disable=SC2154
67: ts "$youtube_then_mark" "$F" "$URL"
68: popd > /dev/null || exit 1
69: ;;
70: r)
71: echo "Marking as read" 1>&2
72: markRead "$F"
73: ;;
74: n)
75: echo "Skipping" 1>&2
76: ;;
77: esac
78: done
79:
80: # shellcheck disable=SC2154
81: "$fetch_podcasts"
Generated by git2html.