You are not logged in.

#26 2017-09-19 21:40:55

misko_2083
Member
Registered: 2016-05-24
Posts: 434

Re: Poor Man's Radio Player - simple yet brilliant radio player

martix wrote:

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.
https://cdn.scrot.moe/images/2017/09/18/NobelsRadioPlayer.png
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.

Nobel's radio then it is. Even though, mostly Tesla and Marconi contributed to the invention of the radio. Tesla was a good sport, he wouldn't mind. Not sure about Marconi. wink
Icon looks good to me. Flat design.
I haven't done anything to the script for some time. Hopefully, sometime soon.


Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#27 2017-09-23 11:20:15

misko_2083
Member
Registered: 2016-05-24
Posts: 434

Re: Poor Man's Radio Player - simple yet brilliant radio player

To give you an update on this.
Some yad dialogs do not like non unicode characters. Forms and tooltip on notification icon dialog are giving errors when non-unicode characters are present in the station title:

(yad:19100): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 'g_utf8_validate (text, len, NULL)' failed

(yad:19100): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 'g_utf8_validate (text, len, NULL)' failed

(yad:19100): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 'g_utf8_validate (text, len, NULL)' failed

(yad:19100): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 'g_utf8_validate (text, len, NULL)' failed
Invalid UTF-8 in tooltip!
Invalid UTF-8 in tooltip!
Invalid UTF-8 in tooltip!
Invalid UTF-8 in tooltip!

Therefore no title is displayed in the left window pane and also tooltip on the notification icon is blank. It seems fine in the log, which is a text-info dialog.

Name      181.FM Salsa
Time: 12:37:43
Title          Richie Ray & Bobby Cruz - Lo Atara La Araché
Bitrate    128

In the next code there is no need to change anything to read the stations, (except maybe path to the file where the stations are). It will pick up all entries starting with "##" (e.g. "## Station_name" without the quotes).
I've also experimented with notification icons. Still need to figure out how to change the icons when the player is playing/paused/stopped and sent to tray. Maybe you know?

#!/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="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 start_values
{
  # loads fields on startup
  status_block "$APP_NAME:    ℕ????'? ℝ???? ℙ?????\n  - ℕ? ????? ??? ???????? -\n\n Licence: GNU PUPBLIC LICENCE Version 3\n\n$ascii_art"
}
export -f start_values

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 "^$APP_NAME:*")" = 1 ]];then
      PMRP="${1/#$APP_NAME:/}"
  fi

  set_notification "${1}"
  
  if [[ -z "$PMRP" ]]; then
    printf "%s\n" "$STATION\n$BITRATE\n$TITLE\n$STATUS" >> "$statuspipe"
    echo "tooltip:<b>${STATION/#Name    /Station : }\n<big>${TITLE/#Title         /Track : }</big></b>" | sed "s/\&/\&amp;/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:Nobels Radio Player" | sed "s/\&/\&amp;/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

echo "$APP_NAME: Ready to Play" >> "$ppipe"

killall mpv 2>/dev/null

  mpv --playlist=$PMRPLIST --input-file=$cpipe --no-video --cache 786 --no-config --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-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() {
  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" &

ascii_art='\t♫ ♪ ılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılı ♪ ♫\n\n\t\\ (•◡•) /  <--- martix'

  # loads fields on startup
  status_block "$APP_NAME:    ℕ????'? ℝ???? ℙ?????\n  - ℕ? ????? ??? ???????? -\n\n Licence: GNU PUPBLIC LICENCE Version 3\n\n$ascii_art"

  # 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=radio --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="Select a Category and click to Load Stations" --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
    echo "$APP_NAME: Preparing for radio silence" >> "$ppipe"
    echo "$APP_NAME: Zzzzzzz" >> "$ppipe"
    ;;
   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>&-

Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#28 2017-09-24 01:45:16

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

^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/\&/\&amp;/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/\&/\&amp;/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

#29 2017-09-26 19:08:26

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

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

#30 2017-09-29 01:05:56

misko_2083
Member
Registered: 2016-05-24
Posts: 434

Re: Poor Man's Radio Player - simple yet brilliant radio player

martix wrote:

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?

killall can be removed.

Network @Bandwidth of the mpv? Why do we need that.
All those networking tools require superuser.
Maybe if we trace system calls.

# First start the mpv and get pid
mpv "http://relay.181.fm:8000" --cache 786 --no-config 2>&1 >/dev/null & PIDP=$!
# We use strace to trace system calls and calculate rate with pv
strace -p $PIDP  -f -e trace=network -s 10000 2>&1 | pv -f --rate 3>&1  1>/dev/null 2>&3 | stdbuf -oL tr '\r' '\n' 2>&1 | tr '[]' '\0'

Not sure if ^this is correct. It's going fast 100-150 KiB.

 157KiB/s
 100KiB/s
 165KiB/s
98.9KiB/s
 162KiB/s
94.9KiB/s
 158KiB/s
96.4KiB/s
 152KiB/s
 100KiB/s
 155KiB/s

It's much closer to "bmon" command output if I grab only "sendto" system calls:

strace -p $PIDP  -f -e trace=network -s 10000 2>&1 | grep sendto | pv -f --rate 3>&1  1>/dev/null 2>&3 | stdbuf -oL tr '\r' '\n' 2>&1 | tr '[]' '\0'
15.9KiB/s
15.3KiB/s
20.7KiB/s
19.8KiB/s
15.1KiB/s
20.5KiB/s
16.2KiB/s
16.2KiB/s
19.6KiB/s
16.8KiB/s
15.8KiB/s

Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#31 2017-09-29 13:15:39

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

^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. smile

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

#32 2017-10-02 02:34:17

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

martix wrote:

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

#33 2017-10-02 05:50:11

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,258
Website

Re: Poor Man's Radio Player - simple yet brilliant radio player

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

#34 2017-10-02 20:18:37

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

^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

#35 2017-10-02 20:48:37

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,258
Website

Re: Poor Man's Radio Player - simple yet brilliant radio player

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).

martix wrote:

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

#36 2017-10-02 23:26:07

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

big_smile  Well, there are many categories and stations in that script...  devil  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

#37 2017-10-03 05:28:37

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,258
Website

Re: Poor Man's Radio Player - simple yet brilliant radio player

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

#38 2017-10-03 15:33:46

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Poor Man's Radio Player - simple yet brilliant radio player

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

#39 2017-10-19 09:42:31

ector1935
Member
Registered: 2017-05-03
Posts: 236

Re: Poor Man's Radio Player - simple yet brilliant radio player

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

#40 2021-03-11 13:30:41

ector1935
Member
Registered: 2017-05-03
Posts: 236

Re: Poor Man's Radio Player - simple yet brilliant radio player

Hi,
someone knows why on arch linux this script no longer works, while on bunsenlabs it works without problems.
Thank for helps

Offline

#41 2021-03-11 14:54:59

unklar
Member
From: #! BL
Registered: 2015-10-31
Posts: 1,437

Re: Poor Man's Radio Player - simple yet brilliant radio player

^^Maybe they 'kicked out' the package because it was last touched by the package handler in 2017 at the AUR.   big_smile

Offline

#42 2021-03-12 19:05:15

ohnonot
...again
Registered: 2015-09-29
Posts: 5,383
Website

Re: Poor Man's Radio Player - simple yet brilliant radio player

ector1935 wrote:

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?


Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

Board footer

Powered by FluxBB