Compare commits

...

3 Commits

Author SHA1 Message Date
Emre AKYÜZ
3ba7e6da11
Add robust error handling. 2023-11-19 02:37:42 +03:00
Emre AKYÜZ
e15f5ee6df
Add extra error handling 2023-11-19 02:15:32 +03:00
Emre AKYÜZ
2734857902
Use a better way to wait for the network. 2023-11-19 02:09:54 +03:00

View File

@ -1,10 +1,21 @@
#!/bin/dash
sleep 16
while ! ping -c 1 9.9.9.9 > /dev/null 2>&1; do sleep 0.5; done
DATA_DIR="$HOME/.cache/youtube_channels"
CHANNEL_LIST="$HOME/.local/share/channels.txt"
mkdir -p "$DATA_DIR"
mkdir -p "$DATA_DIR" && touch "$CHANNEL_LIST"
error_handling() {
[ -s "$CHANNEL_LIST" ] || {
notify-send "You don't have any channels in 'channels.txt'."
exit 1
}
grep -q "^.*=https://www.youtube.com/@[[:alnum:]]*/videos$" "$CHANNEL_LIST" || {
notify-send "'channels.txt' formatting is wrong."
exit 1
}
}
compare_data() {
local channel_name="$1"
@ -47,4 +58,5 @@ update_all_channels() {
done < "$CHANNEL_LIST"
}
error_handling
update_all_channels