mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
Add robust error handling.
This commit is contained in:
parent
e15f5ee6df
commit
3ba7e6da11
@ -4,9 +4,18 @@ while ! ping -c 1 9.9.9.9 > /dev/null 2>&1; do sleep 0.5; done
|
|||||||
|
|
||||||
DATA_DIR="$HOME/.cache/youtube_channels"
|
DATA_DIR="$HOME/.cache/youtube_channels"
|
||||||
CHANNEL_LIST="$HOME/.local/share/channels.txt"
|
CHANNEL_LIST="$HOME/.local/share/channels.txt"
|
||||||
mkdir -p "$DATA_DIR"; touch $CHANNEL_LIST
|
mkdir -p "$DATA_DIR" && touch "$CHANNEL_LIST"
|
||||||
|
|
||||||
[ ! -s $CHANNEL_LIST ] && notify-send "You don't have any channels in "channels.txt". Refer to documentation."
|
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() {
|
compare_data() {
|
||||||
local channel_name="$1"
|
local channel_name="$1"
|
||||||
@ -49,4 +58,5 @@ update_all_channels() {
|
|||||||
done < "$CHANNEL_LIST"
|
done < "$CHANNEL_LIST"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_handling
|
||||||
update_all_channels
|
update_all_channels
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user