1
0

more pig stuff

This commit is contained in:
dtb 2022-11-02 00:55:00 -04:00
parent 8ee09ede65
commit bcc6b0d3ac
6 changed files with 34 additions and 6 deletions

0
rss/pig_fetch Normal file → Executable file
View File

8
rss/pig_fetch.youtube Normal file → Executable file
View File

@ -1,7 +1,9 @@
#!/bin/sh
id(){
youtube-dl --skip-download --print-json --playlist-items 1 "$1" | jq '.channel_id' | tr -d '"'
youtube-dl --skip-download --print-json --playlist-items 1 "$1" \
| jq '.channel_id' \
| tr -d '"'
}
feedurl(){
@ -9,6 +11,6 @@ feedurl(){
}
case "$1" in
channel) feedurl "$(id "$2")"
id) feedurl "$2"
channel) feedurl "$(id "$2")" ;;
id) feedurl "$2" ;;
esac | xargs curl -o - --

3
rss/pig_name Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
printf "%s\n" "$1" | tr -cd '[:alnum:]' | xargs printf "%s.xml\n"

6
rss/pig_pen Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
str isvalue "$XDG_CONFIG_HOME" \
&& printf "%s\n" "$XDG_CONFIG_HOME" && exit 0 \
|| printf "%s/.pigpen" "$HOME" && exit 0 \
|| exit 1

14
rss/pig_recall Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -e
filename="$(pig_pen)/$(pig_name $1)"
loop=0
while streq $loop 0; do
loop=1
if test -e "$filename"; then
cat "$filename"
else
pig_stow "$1" && loop=0
fi
done

9
rss/pig_stow Normal file → Executable file
View File

@ -1,9 +1,12 @@
#!/bin/sh
set -x
set -e
str isvalue "$pig_fetch" \
|| pig_fetch="$(command -v pig_fetch)"
while str isvalue "$1"; do
sh pig_fetch | xq -x "$(
$pig_fetch | xq -x "$(
printf '.
+ {
pig: {
@ -13,7 +16,7 @@ while str isvalue "$1"; do
}
}' "$1" \
| tr -d '[:space:]' \
)" >"$(printf "%s\n" "$1" | tr -cd "[:alnum:]")".xml
)" >"$(pig_pen)/$(pig_name "$1")"
shift
done