mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2025-10-07 07:22:36 +02: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"
|
||||
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() {
|
||||
local channel_name="$1"
|
||||
@ -49,4 +58,5 @@ update_all_channels() {
|
||||
done < "$CHANNEL_LIST"
|
||||
}
|
||||
|
||||
error_handling
|
||||
update_all_channels
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user