#!/bin/bash output="" get_zradylko() { local url="$1" local commonName="$2" local icon="$3" local html_snippet=$(curl -s "$url") local day_of_week=$(date '+%u') restaurant_name=$(echo "$html_snippet" | grep -oP '(?<=).*?(?=)') case "$day_of_week" in 1) soup=$(echo "$html_snippet" | grep -oP '(?<=

Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') main_course=$(echo "$html_snippet" | grep -oP '(?<=

Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') weekly_course=$(echo "$html_snippet" | grep -oP '(?<=

Celý týden nabízíme

).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | sed 's/ / /g') ;; 2) soup=$(echo "$html_snippet" | grep -oP '(?<=

Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') main_course=$(echo "$html_snippet" | grep -oP '(?<=

Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2' | sed 's/ / /g') weekly_course=$(echo "$html_snippet" | grep -oP '(?<=

Celý týden nabízíme

).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | sed 's/ / /g') ;; 3) soup=$(echo "$html_snippet" | grep -oP '(?<=

Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') main_course=$(echo "$html_snippet" | grep -oP '(?<=

Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3' | sed 's/ / /g') weekly_course=$(echo "$html_snippet" | grep -oP '(?<=

Celý týden nabízíme

).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | sed 's/ / /g') ;; 4) soup=$(echo "$html_snippet" | grep -oP '(?<=

Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') main_course=$(echo "$html_snippet" | grep -oP '(?<=

Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4' | sed 's/ / /g') weekly_course=$(echo "$html_snippet" | grep -oP '(?<=

Celý týden nabízíme

).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | sed 's/ / /g') ;; 5) soup=$(echo "$html_snippet" | grep -oP '(?<=

Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1' | sed 's/ / /g') main_course=$(echo "$html_snippet" | grep -oP '(?<=

Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5' | sed 's/ / /g') weekly_course=$(echo "$html_snippet" | grep -oP '(?<=

Celý týden nabízíme

).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | sed 's/ / /g') ;; *) echo "Spatnej den v tydnu brasko" exit 1 ;; esac main_course_with_newlines=$(echo "$main_course" | sed 's/ Kč/ Kč\\n/g') weekly_course_with_newlines=$(echo "$main_course" | sed 's/ Kč/ Kč\\n/g') # Create a JSON object with the desired fields # shellcheck disable=SC2016 output=''${output}' { "title": "**'"$commonName"'**", "author": { "name": "'"$restaurant_name"'", "icon_url": "'"${icon}"'" }, "fields": [ { "name": "Polevka", "value": "'"$soup"'" }, { "name": "Hlavni chod", "value": "'"$main_course_with_newlines"'" }, { "name": "Tydenni nabidka", "value": "'"$weekly_course_with_newlines"'" } ] },' } get_habibi() { local url="$1" local commonName="$2" local icon="$3" # Create a JSON object with the desired fields # shellcheck disable=SC2016 output=''${output}' { "title": "**'"$commonName"'**", "author": { "name": "'"$commonName"'", "icon_url": "'"${icon}"'" }, "fields": [ { "name": "Menu", "value": "'"https://www.foodora.cz/restaurant/qus9/kebab-house-galerie-slovany?utm_source=google&utm_medium=organic&utm_campaign=google_reserve_place_order_action"'" } ] },' } get_agent_orange() { local url="$1" local commonName="$2" local icon="$3" # Create a JSON object with the desired fields # shellcheck disable=SC2016 output=''${output}' { "title": "**'"$commonName"'**", "author": { "name": "'"$commonName"'", "icon_url": "'"${icon}"'" }, "fields": [ { "name": "Menu", "value": "'"https://www.foodora.cz/restaurant/r2xt/bistro-pho-time?utm_source=google&utm_medium=organic&utm_campaign=google_reserve_place_order_action"'" } ] },' } urlGarage="https://www.unasplzenchutna.cz/garage/cz/denni-nabidka/" get_zradylko "$urlGarage" "Salieriho bar" "https://png.pngtree.com/png-vector/20240211/ourlarge/pngtree-italy-round-flag-peeling-sticker-transparent-background-vector-png-image_11738118.png" urlSladovnicka="https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka/" get_zradylko "$urlSladovnicka" "V. pavilón" "https://i0.wp.com/life4you.cz/wp-content/uploads/2022/09/Pilsner-Urquell.png?fit=480%2C480&ssl=1" get_habibi "Habibi" "Habibi" "https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Flag_of_the_Islamic_State_of_Iraq_and_the_Levant.png/800px-Flag_of_the_Islamic_State_of_Iraq_and_the_Levant.png" get_agent_orange "Agent Orange" "Agent Orange" "https://www.postavy.cz/foto-dila/vietcong-foto.jpg" output=''${output}' { "image": { "url": '"$(curl "https://tenor.googleapis.com/v2/search?q=jirka+babica&key=AIzaSyBslfnEs3bkLvwbqp3iUWqKAHyop5aldEo&client_key=qrreader&limit=1&random=true&country=CZ" | jq .results[0].media_formats.gif.url)"' } },' # TODO # get_microsoft_support # Print the complete menu data echo "$output"