Update ufc.sh
This commit is contained in:
parent
702669f97a
commit
2bff491d12
5
ufc.sh
5
ufc.sh
|
@ -5,7 +5,6 @@ discord_webhook_url="https://discord.com/api/webhooks/"
|
||||||
|
|
||||||
# Get the current date in the desired format (e.g., "Sat, Feb 3")
|
# Get the current date in the desired format (e.g., "Sat, Feb 3")
|
||||||
current_date=$(date "+%a, %b %-d")
|
current_date=$(date "+%a, %b %-d")
|
||||||
echo $current_date
|
|
||||||
|
|
||||||
# Specify the URL of the webpage
|
# Specify the URL of the webpage
|
||||||
webpage_url="https://www.ufc.com/events"
|
webpage_url="https://www.ufc.com/events"
|
||||||
|
@ -13,21 +12,17 @@ webpage_url="https://www.ufc.com/events"
|
||||||
# Download the webpage content using curl
|
# Download the webpage content using curl
|
||||||
webpage_content=$(curl -s "$webpage_url")
|
webpage_content=$(curl -s "$webpage_url")
|
||||||
|
|
||||||
|
|
||||||
# Specify a pattern for a date and time in the format "Sat, Feb 24 / 10:00 PM EST"
|
# Specify a pattern for a date and time in the format "Sat, Feb 24 / 10:00 PM EST"
|
||||||
date_time_pattern="[A-Za-z]+, [A-Za-z]+ [0-9]+ / [0-9]+:[0-9]+ [APMapm]+ [A-Za-z]+"
|
date_time_pattern="[A-Za-z]+, [A-Za-z]+ [0-9]+ / [0-9]+:[0-9]+ [APMapm]+ [A-Za-z]+"
|
||||||
|
|
||||||
# Search for the date and time pattern using grep
|
# Search for the date and time pattern using grep
|
||||||
found_date_time=$(echo "$webpage_content" | grep -m 1 -o -E "$date_time_pattern")
|
found_date_time=$(echo "$webpage_content" | grep -m 1 -o -E "$date_time_pattern")
|
||||||
echo $found_date_time
|
|
||||||
|
|
||||||
# Extract the date from the found date and time
|
# Extract the date from the found date and time
|
||||||
event_date=$(echo "$found_date_time" | awk -F' / ' '{print $1}')
|
event_date=$(echo "$found_date_time" | awk -F' / ' '{print $1}')
|
||||||
echo $event_date
|
|
||||||
|
|
||||||
# Extract the time from the found date and time
|
# Extract the time from the found date and time
|
||||||
event_time=$(echo "$found_date_time" | awk -F' / ' '{print $2}')
|
event_time=$(echo "$found_date_time" | awk -F' / ' '{print $2}')
|
||||||
echo $event_time
|
|
||||||
# Check if the found date matches the current date
|
# Check if the found date matches the current date
|
||||||
if [ "$event_date" == "$current_date" ]; then
|
if [ "$event_date" == "$current_date" ]; then
|
||||||
echo "Sending Discord message for today's date and time."
|
echo "Sending Discord message for today's date and time."
|
||||||
|
|
Loading…
Reference in New Issue