You are not logged in.
Welcome to the thread, misko! Good to see ya! U see: I was not just blabbering about having a thread for the player, now here it is! Dynamite Radio Player sounds good, but somehow I got fond of Nobel after ohnonot suggested "No bells". So “no bells” -> “Nobel’s”, but it’s also about the fear that it’ll explode like dynamite if we start to tweak that yad script.
How does it look? It’d be an idea to make an icon with an A. Nobel-like face with a headphone (nowdays you’d call that a hipster) or with a pocket radio.
I've been tweaking the script here and there, I'll try to update this thread soon. That option mentioned above "--no-ytdl" seems to make connections faster and I guess using also "--no-terminal" would be appropriate in this case. Somehow on the status panel after loading channels and starting a station there is only the title (the rest appears after closing to tray and opening again) and the station name won't get updated after a change. The yad script is great, thank you again for creating it! It's fun to learn about yad and trying to tweak it.
Offline
I almost forgot: I could not find working stream-urls for Dublab Dubstream, Dublab Dreamstream, Dublab.jp, Dublab.de and Dublab.es. Anyone maybe listening to these stations via url-stream?
Offline
there you go:
http://dublab.com/streams/dubstream
http://dublab.streamguys.com/themestream.mp3
http://dublab.streamguys.com/themestream_fallback.mp3
http://dublabde.out.airtime.pro:8000/dublabde_a
http://dublabde.out.airtime.pro:8000/dublabde_b
http://samcloud.spacial.com/api/listen?sid=75616&rid=133702&f=aac,any&br=64000,any&m=sc
that's all i was able to retrieve from their javascript heavy sites; themestream seems to be dead, but the others still work.
Offline
^Great, thank you @ohnonot! Indeed, those two themestreams did not work for me either and I could not start dublab.jp - not even through that website (there was a shoutcast stream and it did not work). So we have dublab main, dublab.es and two (same) streams for dublab.de. If anyone wanting to add them to the stations file to the Urban category, here is the code for copy&paste:
Urban: "Dublab Main" "Future. Roots. Radio" "http://dublab.com/streams/dubstream"
Urban: "Dublab.es" "Dublab Spain" "http://samcloud.spacial.com/api/listen?sid=75616&rid=133702&f=aac,any&br=64000,any&m=sc"
Urban: "Dublab.de" "Dublab Germany Stream A" "http://dublabde.out.airtime.pro:8000/dublabde_a"
Urban: "Dublab.de" "Dublab Germany Stream B" "http://dublabde.out.airtime.pro:8000/dublabde_b"
Offline
^Fantastic! Great work Misko! Now there are notifications and direct reading of categories. I'm wondering: Was it only me with not showing status panel information!? I mean after starting a station - as I mentioned - I got the Title but Station Name and Bitrate was missing. Did it work ok for you before? Anyhow I made a few changes here and there too, here it is to test (you have to change the stations path):
#!/bin/bash
command -v mpv >/dev/null 2>&1 || (yad --text="PMRP requires 'mpv' but it's not installed!\nInstall 'mpv' to enjoy PMRP."; exit 1)
TEXTDOMAIN=ydesk
TEXTDOMAINDIR=/usr/share/locale
LANG=C.UTF-8
export APP_NAME="Nobel's Radio Player"
export pmrp='@bash -c "run_stations %2"'
export pmrp_stations="$HOME/.config/NobelsRadioPlayer/stations"
# Declare default status
export STATUS="Playing"
export fpipe=$(mktemp -u --tmpdir pmrp.XXXXXXXX)
export ppipe=$(mktemp -u --tmpdir ppmrp.XXXXXXXX)
export cpipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export statuspipe=$(mktemp -u --tmpdir cpmrp.XXXXXXXX)
export nobelnotification=$(mktemp -u --tmpdir notifpmrp.XXXXXXXX)
export PMRPLIST=$(mktemp -u --tmpdir PMRPLIST.XXXXXXXX)
# Pipe for setting values in the form tab
mkfifo "$fpipe"
# control pipe - send commands to mpv
mkfifo "$cpipe"
# status pipe - send text to left text pane
mkfifo "$statuspipe"
# Pipe for notification icon
mkfifo "$nobelnotification"
# Create the list file
> $PMRPLIST
#File to store default category
export CAT_FILE=$(mktemp -u --tmpdir pmrpcat.XXXXXXXX)
> $CAT_FILE
trap "rm -f $fpipe $ppipe $cpipe $statuspipe $nobelnotification $PMRPLIST $CAT_FILE" EXIT
pmkey=$(($RANDOM * $$))
# Categories are defined with "## Station_name"
# Categories are separated with "!\n" (without quotes)
# Note: without trailing newline yad won't restore categories when reopened from tray
# The last item in category is without trailing "!"
Categories="$(awk '/^##.*/{if ($2=="Stations"){$2=""}else{printf "%s%s",sep,$2; sep="!\n"}} END{print ""}' $pmrp_stations)"
function stations
{
if [[ "$1" != "$CAT_DEFAULT" ]]; then
echo "Category: $1" >> "$ppipe"
fi
< "$pmrp_stations" sed -n -e 's/^.*'"$1: "'//p' \
| sed -e $'s/\" \"/\\\n/g;s/\"//g' >> "$fpipe"
}
export -f stations
function run_stations
{
echo "3:@disabled@"
echo -e '\f' >> "$fpipe"
echo "$1" > "$CAT_FILE"
stations "$1"
echo "3:$pmrp"
}
export -f run_stations
function load_url
{
LANG=C.UTF-8
status_block "$APP_NAME: Loading...\n\n $1"
echo "Station: $1 Url: $3" >> $ppipe
# Station to the list
echo "$3" > $PMRPLIST
# Unload current Playlist
echo "playlist_remove current" > $cpipe
# Load list
echo "loadlist $PMRPLIST" > $cpipe
}
export -f load_url
function status_block
{
LANG=C.UTF-8
if [[ ! -z "$PMRP" ]]; then
unset PMRP
else
if [[ "$(echo "$1" | grep -c "^Name*")" = 1 ]]; then
STATION="$1"
elif [[ "$(echo "$1" | grep -c "^Title*")" = 1 ]];then
TITLE="$1"
date +"Time: %T" >> $ppipe
elif [[ "$(echo "$1" | grep -c "^Bitrate")" = 1 ]];then
BITRATE="$1 Kb/s"
elif [[ "$(echo "$1" | grep -c "^Url*")" = 1 ]];then
URL="$1"
elif [[ "$(echo "$1" | grep -c "^$APP_NAME:*")" = 1 ]];then
PMRP="${1/#$APP_NAME:/}"
fi
set_notification "${1}"
if [[ -z "$PMRP" ]]; then
printf "%s\n" "$STATION\n$URL\n$BITRATE\n$TITLE\n$STATUS" >> "$statuspipe"
echo "tooltip:<b>${STATION/#Name /Station : }\n<big>${TITLE/#Title /Track : }</big></b>" | sed "s/\&/\&/g" >> $nobelnotification
else
echo "\n$PMRP\n" >> "$statuspipe"
fi
CAT_DEFAULT="$(cat $CAT_FILE)"
if [[ "$CAT_DEFAULT" == "" ]]; then
CAT_DEFAULT="181.FM"
fi
echo "$(for category in $Categories
do
if [[ "$category" == "$CAT_DEFAULT" ]]; then
printf "^%s" "$CAT_DEFAULT"
elif [[ "$category" != "$CAT_DEFAULT!" ]]; then
printf "%s" "$category"
else
printf "^%s!" "$CAT_DEFAULT"
fi
done
)" >> "$statuspipe"
# Load stations
echo "$pmrp" >> "$statuspipe"
fi
}
export -f status_block
function set_notification
{
LANG=C.UTF-8
if [[ "${1/#ANS_core-idle=/}" == "yes" ]];then
STATUS="Paused"
echo "icon:gtk-cancel" >> $nobelnotification
elif [[ "${1/#ANS_core-idle=/}" == "no" ]];then
STATUS="Playing"
echo "icon:play" >> $nobelnotification
elif [[ "${1}" == "Stop" ]];then
export STATUS=" ${1}"
echo "tooltip:Nobel's Radio Player" | sed "s/\&/\&/g" >> $nobelnotification
echo "icon:gtk-delete" >> $nobelnotification
fi
# Sets the right-click menu
echo "menu:$STATUS - Pause/Play!bash -c 'echo cycle pause >> $cpipe && echo \"get_property core-idle\" > $cpipe && set_notification'!gtk-ok|Stop!bash -c 'echo stop >> $cpipe && status_block "Stop" && set_notification'!stop|Close tray!quit!gtk-close" >> $nobelnotification
}
export -f set_notification
exec 3<> $fpipe
exec 4<> $ppipe
exec 5<> $cpipe
exec 6<> $statuspipe
exec 7<> $nobelnotification
killall mpv 2>/dev/null
mpv --no-ytdl --playlist=$PMRPLIST --input-file=$cpipe --no-video --cache 786 --no-config --term-playing-msg='print_text ${metadata}' --idle=yes 2>&1 \
| awk '/[statusline]/{if ($0 ~ "icy-br:*") {gsub(/^.*icy-br:/,"");print "Bitrate ", $0 ;}
else {if ($0 ~ "icy-name:*") {gsub(/^.*icy-name:/,"");print "Name ", $0;}
else {if ($0 ~ "icy-url:*") {gsub(/^.*icy-url:/,"");print "Url ", $0;}
else {if ($0 ~ "icy-genre:*") {gsub(/^.*icy-genre:/,"");print "Genre -", $0;}
else {if ($0 ~ "icy-title:*") {gsub(/^.*icy-title:/,"");print "Title ", $0;}
else {if ($0 ~ "ANS_core-idle*"){print $0;}}}}}}}
{fflush(stdout)}' | while read -r line; do status_block "$line"; echo "$line" >>"$ppipe"; done &
function main() {
# loads fields on startup
ascii_art='\t ♫ ♪ ılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılı ♪ ♫\n\n\t \\ (•◡•) / <--- misko'
status_block "$APP_NAME: $APP_NAME: Ready to Play \n Licence: GNU PUPBLIC LICENCE Version 3\n\n$ascii_art\n\n\n\n Select a Category and click to Load Stations"
yad --plug="$pmkey" --tabnum=1 --form --cycle-read --field "":TXT --field "Category":CB \
--image-ontop --field="Load Stations!gtk-add:fbtn" <&6 &
yad --plug="$pmkey" --tabnum=2 --list --no-markup --dclick-action='bash -c "load_url %s && echo \"add track-list/0/selected yes\" >> $cpipe"' --select-action='bash -c "load_url %s && echo \"get_property track-list/0/selected\" >> $cpipe"' \
--text "Select to play" --text-align=center --column="Name" --column="Category" --column="Url" \
--search-column=1 --expand-column=1 --print-column="3" <&3 &
# comment out next line if you want to start with log
# tail -f "$ppipe" | yad --text-info --title="$APP_NAME-Log" --tail --window-icon=radio --width=600 --height=500 --button="gtk-close" &
# Reprints metadata after returning from tray
echo 'print_text ${metadata}' > $cpipe
yad --paned --key="$pmkey" --button="Close to Tray!gtk-close":1 \
--button="Show Log":'bash -c "tail -f -n +1 $ppipe | yad --text-info --tail --title=$APP_NAME-Log --window-icon=accessories-notes --width=600 --height=500 --button=gtk-close" &' \
--button="Pause/Play":'bash -c "echo cycle pause >> $cpipe && echo \"get_property core-idle\" > $cpipe"' \
--button="Stop":'bash -c "echo stop >> $cpipe && status_block \"Stop\" "' --text=" Nobel's Radio Player\n*no bells, no whistles*" --width=700 --height=500 \
--title=$"$APP_NAME" --splitter=300 --window-icon="radio" --orient=hor --image=radio --image-on-top --posx=10 --posy=100
RET="$?"
case $RET in
252)
echo "quit" >> $cpipe
;;
1) yad --notification --command="quit" \
--image="radio" \
--listen <&7 & notifpid=$!
set_notification
# Waits for notification to exit
wait $notifpid
# Need to do this after returned from tray
status_block ""
run_stations "$(cat $CAT_FILE)" &>/dev/null
main
;;
*) exit 1
;;
esac
}
main
exec 3>&-
exec 4>&-
exec 5>&-
exec 6>&-
exec 7>&-
Now the status panel info is working fine through that "--term-playing-msg='print_text ${metadata}'" addition. It gave me some headaches to figure that out (btw --no-terminal was a bad idea as it stops printing out metadata). One click starts works, but not always - same with switching stations. I've seen the cache size was changed - hopefully it'll make connecting even faster.
If the player is closed to the status bar, "close tray!" does not work (it opens the player). There is a small issue with the log window: For me it only shows "Nobel's" when opened (changed the icon there for one that I found quickly but there might be a better option).
It's brilliant that it reads the categories now. I'm not sure about the default category in the script - it seems to be superfluous as otherwise the first Category in stations will be the default anyway. I did not have a look at the icons issue you mentioned yet, but I'll see what I can do.
EDIT II: I did not notice any issues with characters so far... The only station was this: http://radio2.serverradio.net:8444 But this a thai channel and hence the character issue.
EDIT III: I'm wondering: Which icon do you mean to change when playing/paused/stop?
Ok, I got it now! I noticed when I had a closer look at the set_notification part. You're right, the icon won't change in the systray, only for "stop", and it won't show the app_name on tooltip. I'm just getting familiar with the notification part, showing Title on tooltip while playing works great though.
Last edited by martix (2017-09-28 22:30:23)
Offline
Hmmm, when you play something in mpv like a music or video and Nobel's Radio Player gets opened, it always closes the other instance of mpv. It's probably because of "killall mpv" in the script.
I tried to find a basic terminal command to show network bandwith. Well, there is
ifstat -znS
but it would be more helpful to show the bandwith used by mpv. There is something like
netstat -putw | grep mpv
which shows the connection made by mpv, but without speed. Does someone maybe know a similar terminal command which also returns the connection speed?
Offline
^Meanwhile I removed that "mpv killall" line and did not notice any difference (apart from the "closing the other mpv instance"-issue was fixed).
Mainly I switched from windows to linux because the windows machine was doing something all the time but I just did not know what it was (and I doubt there is any M$ user who could tell all the time what is going on). So on linux it's great to have an overview (like via conky, terminal tools, etc.). This is why I suppose it'd be great if the player showed the bandwith use (and the server it's trying to connect to). Also this is how I try to find out if a station is alive: I click on it and look at the bandwith in conky to watch if it starts.
I noticed those root privileges too, e.g. with nethogs (otherwise there are not many tools delivering process bandwith). Out of curiosity I wanted to give NeTraf a try, but it requires this -> https://www.microsoft.com/net/core#linuxubuntu After all I decided NOT to try it.
I checked those commands and got strange figures (almost like true bandwith*100 - you had more like "*10" in the first case). Also I noticed that the PID values for mpv showed in conky were completely different from the ones in the terminal. Why? I have no idea. I will have to test the commands you mentioned a bit longer, but they're great for a start anyhow.
Offline
There is a small issue with the log window: For me it only shows "Nobel's" when opened (changed the icon there for one that I found quickly but there might be a better option).
Well, bash syntax does not really like that ' I guess.. I found a workaround in the end for this issue:
--button="Show Log":'bash -c "tail -f -n +1 "$ppipe" | yad --text-info --title='"Nobel\'s\\ \Radio\ \Player-Log"' --tail --window-icon=accessories-notes --width=600 --height=500 --button="gtk-close" &"' \
Offline
a. About the script, basically you are making mpv your slave with pipes and --idle combination?
b. About mpv, did you tested any replaygain stuff with streaming stations, like --af=lavfi=[loudnorm=LRA=10] < behaves totally unpredictable for me, like there isn't enough internal cache or something? (testing ' --cache-secs 7 --af=lavfi=[loudnorm=LRA=10]') and 6dB louder '--cache-secs 7 --af=lavfi=[loudnorm=LRA=10:I=-17]'.
Last edited by brontosaurusrex (2017-10-02 10:28:18)
Offline
^I cannot comment on the script part as I'm here mainly to test and break things so Misko has something to fix. The script goes back to hakerdefo's PMRP, but the GUI Version was created by Misko.
As for mpv: I've been testing that cache option too as there was "--cache 2048" in the script and now "--cache 786". Actually according to the mpv manual it's supposed to be "--cache=786" (--cache=<kBytes|yes|no|auto>) and also cache-secs=7 (--cache-secs=<seconds>), but no matter what I used (with or without "="), it just did not do much. Sometimes I had 1-3s and 0 KB cache, sometimes 6-7s and 8 KB - depending on the station. --af=lavfi=[loudnorm=LRA=10] did work however. I'm not sure about the exact figures but the second option was indeed louder.
Last edited by martix (2017-10-02 22:52:54)
Offline
I'll stick with
--cache-secs 7 --af=lavfi=[loudnorm=LRA=10:I=-17]
This is of course especially useful when switching from station to station (there can be a drastic volume jump).
The script goes back to hakerdefo's PMRP
I did a quick look at hakerdefo's script (horror in 6000 lines) and imho you can easily skip mentioning it.
Last edited by brontosaurusrex (2017-10-02 21:13:28)
Offline
^ Well, there are many categories and stations in that script... ]:D Above I wrote "no matter what I used (with or without "=")" <- bbcode made a smiley out of the last bit as = was without quotes.
After experimenting more it's starting to make some sense..."--cache=768" seems to require "=" (otherwise there is an error message), but checking several stations I did not notice any difference.
However I can tell that "--cache-sec 7" and "cache-sec=7" both work on certain stations like http://relay.181.fm:8026 or http://ice1.somafm.com/thetrip-32-aac (or generally speaking with any somafm station or relay station - better to check something like --cache-sec=21).
On other stations like http://wfmu.org/wfmu.pls or http://listen.xray.fm:8000/stream this option simply does not do anything (2-3s cache). On default without "--cache-sec 7" those other two - somafm and relay - use a 10s cache (+some KB).
I checked around a dozen stations jumping from one to the other. There is indeed a difference sometimes in volume (imho not much though). --af=lavfi=[loudnorm=LRA=10:I=-17] sets the volume a bit lower than the actual volume but there are still differences like between this oldies station http://66.85.88.2:7142 and e.g. xray.fm.
In Nobel's script there is atm
mpv --playlist=$PMRPLIST --input-file=$cpipe --no-ytdl --no-video --cache 786 --no-config --term-playing-msg='print_text ${metadata}' --idle=yes
so it seems "--cache 786" can be removed. I'm not sure about "--idle=yes".
Actually something like "--cache-sec=90" could be useful in combination with "--force-seekable=yes" for podcast streams.
Last edited by martix (2017-10-02 23:29:41)
Offline
Removing --idle will break your script logic, irc it means: wait for command if you have nothing to do and don't exit, which is related to so called command or slave mode.
About loudnorm, the bigger the I is, the louder will things be, default is -23, 6dB louder is -17 (reference level). I have some local stations that are so loud (without loudnorm), that you have to basically lower the volume before even be dare enough to switch (for headphone users it may actually mean danger to the human hearing health).
Thanks for testing cache stuff, I guess the only way to really understand it, it would be mpv sources.
Last edited by brontosaurusrex (2017-10-03 05:53:20)
Offline
Ah, ok. Without --idle it won't start and loudnorm is good to protect users(' ears) from overly loud stations.
After some more experimenting I'd say cache is especially relevant in the context of the "seek"-feature. Otherwise, for radio URLs (making faster connections, using less buffer, etc.) it does not do much. Or at least I'm not sure what is e.g. "--cache-secs 7" supposed to do.
Just discovered the option "--log-file=<path>" and no matter if I use --cache-secs or not, it shows after opening a stream: "[ 20.983][v][cache] Cache size set to 150000 KiB (75000 KiB backbuffer)". Otherwise (testing mpv in terminal with the option --cache-file=<TMP|path>) it also gave me an error message: "[file-cache] can't cache unseekable stream".
However: "--force-seekable" seems to be really useful as it makes it possible to simply jump back in time while listening to a station. Although using --cache-secs=7 makes the output showing max. 7s+someKB (and without max. 10s+someKB), I did not notice differences in behavior otherwise (on xray.fm).
At the moment I can't see any useful mpv option with cache, but it looks like a good idea to implement "--force-seekable".
Last edited by martix (2017-10-03 15:38:45)
Offline
Hi everyone in archlabs, do I have this error, when i start prmp, solutions?
prmp
yad: error while loading shared libraries: libwebkitgtk-3.0.so.0: cannot open shared object file: No such file or directory
yad: error while loading shared libraries: libwebkitgtk-3.0.so.0: cannot open shared object file: No such file or directory
yad: error while loading shared libraries: libwebkitgtk-3.0.so.0: cannot open shared object file: No such file or directory
thank for help!
Edit
I found the solution,reinstall yad from yaourt now works!
thank
Last edited by ector1935 (2017-10-19 10:02:34)
Offline
Hi,
someone knows why on arch linux this script no longer works, while on bunsenlabs it works without problems.
Thank for helps
Offline
^^Maybe they 'kicked out' the package because it was last touched by the package handler in 2017 at the AUR.
Offline
Hi,
someone knows why on arch linux this script no longer works, while on bunsenlabs it works without problems.
Thank for helps
It works for me, on Archlinux. Although many of the default radio stations seem to be dead.
pmrp (not prmp) is available as pmrp-git on the AUR. git packages need to be upgraded/re-installed every now and then. Tried that?
Offline