#!/bin/bash #RIPRODUTTORE SNAPCAST DA LINK YOUTUBE #set -xu #debug cnt=0 trappola() { stat=1 } trap trappola SIGINT #Crea dir 'songs' se non esiste if [ ! -d "songs" ]; then mkdir songs fi #Inizializza playlist clear rm /tmp/snapfifo touch /tmp/snapfifo echo -e "\nPlaylist riprodotta:" >> songs/playlist.txt 2 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 #userInput='https://www.youtube.com/watch?v=jm56jeM2b_Y' #per debug #Scarica audio da link YT if [ "$userInput" = "off" ]; then rm songs/play.wav rm /tmp/snapfifo; touch /tmp/snapfifo pkill ffmpeg break else clear 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