Compare commits
No commits in common. "eaa9059fb5780a844cd1afe0907e79beeafdcfff" and "9a64735f3cacec31a49c7ac808bcce9452d9694b" have entirely different histories.
eaa9059fb5
...
9a64735f3c
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ueo pipefail
|
set -uexo pipefail
|
||||||
|
|
||||||
# Define PID file location
|
# Define PID file location
|
||||||
PID_FILE="/tmp/yt-dlp-ntfy.pid"
|
PID_FILE="/tmp/yt-dlp-ntfy.pid"
|
||||||
|
@ -12,15 +12,12 @@ fi
|
||||||
|
|
||||||
# Store the PID of the current process
|
# Store the PID of the current process
|
||||||
echo $$ > "$PID_FILE"
|
echo $$ > "$PID_FILE"
|
||||||
echo "Running as PID $(cat $PID_FILE)"
|
|
||||||
|
|
||||||
# Define ntfy server and channel
|
# Define ntfy server and channel
|
||||||
NTFY_SERVER="https://notify.kucharczyk.xyz"
|
NTFY_SERVER="https://notify.kucharczyk.xyz"
|
||||||
CHANNEL="clipboard"
|
CHANNEL="clipboard"
|
||||||
ACCESS_TOKEN="$NTFY_ACCESS_TOKEN"
|
ACCESS_TOKEN="$NTFY_ACCESS_TOKEN"
|
||||||
|
|
||||||
echo "Monitoring channel $CHANNEL of server $NTFY_SERVER"
|
|
||||||
|
|
||||||
# Run the script in an infinite loop to listen for new messages
|
# Run the script in an infinite loop to listen for new messages
|
||||||
while true; do
|
while true; do
|
||||||
while read -r message; do
|
while read -r message; do
|
||||||
|
@ -32,6 +29,8 @@ while true; do
|
||||||
echo "Downloading video from $video_url"
|
echo "Downloading video from $video_url"
|
||||||
yt-dlp "$video_url"
|
yt-dlp "$video_url"
|
||||||
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" -d "Finished downloading." "$NTFY_SERVER/$CHANNEL"
|
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" -d "Finished downloading." "$NTFY_SERVER/$CHANNEL"
|
||||||
|
else
|
||||||
|
echo "Received non-URL message: $video_url"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -41,5 +40,5 @@ while true; do
|
||||||
done < <(curl --no-buffer -s -H "Authorization: Bearer $ACCESS_TOKEN" "$NTFY_SERVER/$CHANNEL/json")
|
done < <(curl --no-buffer -s -H "Authorization: Bearer $ACCESS_TOKEN" "$NTFY_SERVER/$CHANNEL/json")
|
||||||
|
|
||||||
# Cleanup PID file on script exit
|
# Cleanup PID file on script exit
|
||||||
trap 'rm -f $PID_FILE' EXIT
|
trap "rm -f $PID_FILE" EXIT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue