#!/bin/bash #RIPRODUTTORE SNAPCAST DA LINK YOUTUBE #set -xu cnt=0 trappola() { stat=1 } trap trappola SIGINT #Crea dir 'songs' se non esiste if [ ! -d "songs" ]; then mkdir songs fi #Inizializza playlist echo -e "\nPlaylist riprodotta:" >> songs/playlist.txt while : do #Input ((cnt++)) stat=0 echo -e '\e[37m- Player YouTube snapcast -' echo -e "\033[90mDigita 'off' per chiudere" read -p $'\033[97mLink \033[0;31mYoutube\033[97m: ' userInput #Scarica audio da link YT if [ "$userInput" = "off" ]; then rm songs/play.wav pkill ffmpeg break else title=$(yt-dlp --get-title $userInput) yt-dlp --extract-audio --audio-format wav -o songs/"${title}".wav $userInput > /dev/null fi #Sposta e Suona echo -e "\033[90mIn riproduzione:"; echo -e "\033[97m$title\n\n"; echo $title >> songs/playlist.txt clear; echo -e "\033[90mIn riproduzione:"; echo -e "\033[97m$title\n\n"; echo $title >> songs/playlist.txt ffmpeg -y -loglevel error -hide_banner -i songs/"${title}".wav -f u16le -acodec pcm_s16le -ac 2 -ar 48000 /tmp/snapfifo clear; echo -e "\033[90mIn riproduzione:"; echo -e "\033[97m$title\n\n"; echo $title >> songs/playlist.txt done