vidl: Allow getting current status

Can now get the current status with -p option (either running or
stopped) and currently remaining queue items with -P option.
This commit is contained in:
Marty Oehme 2025-01-23 16:49:40 +01:00
parent 6002c49a16
commit 284c12f781
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -33,7 +33,7 @@ Options:
urls=("$@")
while getopts "t:f:d:hcp" opt; do
while getopts "t:f:d:hcpP" opt; do
case "$opt" in
# v) verbose=1
# ;;
@ -50,6 +50,9 @@ while getopts "t:f:d:hcp" opt; do
ONLY_DO=clear
;;
p)
ONLY_DO=status
;;
P)
ONLY_DO=remaining
;;
h | \? | *)
@ -155,6 +158,7 @@ is_in_queue() { # 1=url
}
add_to_queue() { # 1=url
if is_in_queue "$1"; then return; fi
echo "$1" >>"$queue_file"
echo "added $url to queue."
@ -193,6 +197,14 @@ print_queue_remaining() {
wc -l "$queue_file" | cut -f1 -d' '
}
print_status() {
if is_only_instance; then
printf "stopped\n"
return
fi
printf "running\n"
}
main() {
setup
if [ "$ONLY_DO" = "clear" ]; then
@ -201,6 +213,9 @@ main() {
elif [ "$ONLY_DO" = "remaining" ]; then
print_queue_remaining
exit
elif [ "$ONLY_DO" = "status" ]; then
print_status
exit
fi
for url in "$@"; do