-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: dump radio station streem #1214
Comments
Based on your dmenurecord I have created a script that dumps a stream to a file and plays it at once: #!/usr/bin/env zsh
# Filename: dumpceararural
# vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab ft=sh:
# Last Change: Sat, 15 Oct 2022 12:00:21
# Autor: Sérgio Araújo
# site: https://dev/to/voyeg3r
# Licence: GPL (see http://www.gnu.org/licenses/gpl.txt)
# Reference: https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/dmenurecord
# https://meleu.sh/trap-err/
# https://stackoverflow.com/questions/8363519/
# https://askubuntu.com/questions/1033866/
# set -euo pipefail
# trap 'echo "${BASH_SOURCE}:${LINENO}:${FUNCNAME:-}"' ERR
# Dependências: dunst, mpv, wget
#
# Usage:
# $0: Ask for recording via dmenu
# $0 start: Record the stream
# $0 stop: Stop recording
trap 'killrecording' INT
station="ceararural"
url="http://stm3.xcast.com.br:8560/stream"
filename="${station}-$(date +%d-%b-%Y-%H-%M).mp3"
killrecording () {
dunstify "Parando gravação de áudio"
if [ -f "/tmp/dump_pid" ]; then
pkill -P $(< "/tmp/dump_pid")
\rm -f "/tmp/dump_pid"
else
dunstify "Não há PIDs listados para matar"
exit 1
fi
exit 0
}
askrecording () {
choice=$(printf "yes\nno" | dmenu -i -p "Record Ceará Rural?")
case "$choice" in
yes) record;;
no) exit 0;;
*) exit 0;;
esac
}
asktoend() { \
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
[ "$response" = "Yes" ] && killrecording
exit 0
}
record () {
(
recdir="$XDG_MUSIC_DIR/ceararural"
[ ! -d "$recdir" ] && mkdir "$recdir"
cd "$recdir"
dunstify "Iniciando gravação em $recdir"
( wget -O- "$url" | tee -ai "$filename" | mpv - ) & echo $! > /tmp/dump_pid
)
}
case "$1" in
start) record;;
stop) killrecording;;
*) ([ -f "/tmp/dump_pid" ] && asktoend && exit) || askrecording;;
esac
|
If it's of any use to you, I wrote a similar radio-streaming script using dmenu albeit it lacks recording of stations.
It displays the currently playing song in the statusbar, although only if the station is sending out an "icy-title". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using your amazing dmenurecord script and I am thinking how to make something similar with radio stream stations. Record the audio and play at the same time.
for now all I have is:
I would like to implement some kind of menu like yours:
I have tried putting the recoding command in a subshell, something like this:
But, differently of your dmenurecord, here we have at least two processes that we have to manage, wget and mpv.
Thanks for your time!
The text was updated successfully, but these errors were encountered: