#!/bin/bash
# Function to display the menu and get user selection
function display_menu {
local options=("$@")
local PS3="Please select an option: "
select opt in "${options[@]}"; do
if [[ -n $REPLY && $REPLY -le ${#options[@]} ]]; then
echo "$REPLY"
break
else
echo "Invalid selection. Please try again."
fi
done
}
# Genre menu
genre_menu=("Lofi" "Synthwave" "Lounge and Chill" "Quit")
selected_genre_index=$(display_menu "${genre_menu[@]}")
# Convert the index to the actual genre name
selected_genre=${genre_menu[$selected_genre_index-1]}
echo "Selected genre: $selected_genre" # Debug statement
if [[ $selected_genre == "Quit" ]]; then
echo "Exiting..."
exit 0
fi
# Channel menus based on selected genre
case $selected_genre in
"Lofi")
channels=("lofi girl:
https://www.youtube.com/watch?v=jfKfPfyJRdk" "Lofi Cyber Ambient:
https://www.youtube.com/watch?v=L5a1xExnnZo" "lofi synthwave:
https://www.youtube.com/watch?v=4xDzrJKXOOY" "Sad Lofi:
https://www.youtube.com/watch?v=P6Segk8cr-c")
;;
"Synthwave")
channels=("synthwavefm:
https://www.youtube.com/watch?v=ZwWRrvJwFTM" "101.5FM:
https://www.youtube.com/watch?v=WPXlsahEUNU" "darksynth:
https://www.youtube.com/watch?v=MGJWPha7rJw" "Timewarpdrive:
https://www.youtube.com/watch?v=mzFASfW43-g")
;;
"Lounge and Chill")
channels=("Chill Lounge:
https://www.youtube.com/watch?v=9UMxZofMNbA" "Sunset Beach:
https://www.youtube.com/watch?v=j7lLuCKxGtU" "The Goodlife:
https://www.youtube.com/watch?v=36YnV9STBqc" "Chillout Lounge:
https://www.youtube.com/watch?v=tJqBG7ZQDc4")
;;
*)
echo "Invalid genre selection."
exit 1
;;
esac
echo "Channels: ${channels[@]}" # Debug statement
# Display channel menu and get user selection
selected_channel_index=$(display_menu "${channels[@]}")
# Convert the index to the actual channel name
selected_channel=${channels[$selected_channel_index-1]}
echo "Selected channel: $selected_channel" # Debug statement
# Extract the YouTube URL from the selected channel
youtube_url=$(echo $selected_channel | awk -F': ' '{print $2}')
echo "YouTube URL: $youtube_url" # Debug statement
# Call the mpv command with the selected YouTube URL
mpv --vo=caca "$youtube_url"