Page 1 of 2

DogRadio updated, v2

Posted: Thu Apr 06, 2023 4:33 pm
by fredx181

*** DogRadio Internet Radio Player v2 ***

Update 2023-06-03 : New DogRadio version 2.5 below attached with a small improvement, thanks @stemsee , see:viewtopic.php?p=90779#p90779

dogradio-2.5.0-noarch.pet
DogRadio v2.5
(491.07 KiB) Downloaded 117 times

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update 2023-04-09 : New DogRadio version 2.4 with some improvements thanks @stemsee , see: viewtopic.php?p=86475#p86475

Shared already "DogRadio" years back on the old forum, but it became outdated e.g. because of dependency of the "Radiosure" database (for searching), which doesn't exist anymore.
This v2 makes use of http://all.api.radio-browser.info/ and doing a search is direct online, so no local database is needed anymore.

Tested on FossaPup and Vanilla-Dpup (the latter has yad GTK3 version by default) (EDIT: And KLV-Airedale, see here for xbps package: viewtopic.php?p=86300#p86300)
For DebianDog: it's in the custom repository for Buster, Bullseye, Bookworm and Sid.

Other changes/bugfixes:
● Search for name of radio-station, or select a country, e.g. Australia from dropdown list
(Add/Remove button > New > Add Radiostation)
● Fixed that it sometimes failed adding a new radiostation to the main GUI
● Choice of player to use (mpv or mplayer). Can be chosen from right-click tray-icon menu > Select Player
● Supports now "yad" built with GTK3 (will look a bit different though)
● Config directory changed to ~/.dogradio2 (with earlier version it was ~/.dogradio)

Requirements:
● mpv or mplayer (note: old version of mplayer may not work well with some stream types, then mpv is recommended)
Can be chosen from right-click tray-icon menu > Select Player
● yad, not sure which exact version required, should be not very old anyway
(yad .pet packages v0.40 (GTK2) attached here viewtopic.php?p=74331#p74331)
● jq , for parsing the radio-browser api, install from PPM
● conky , for the "ticker" that displays station name and often song title, install from PPM
● Optional: streamripper, for ripping a stream (install from PPM)

Image
---------------------------------------------------------------------------------------------------------------------
Image


Re: DogRadio updated, v2

Posted: Thu Apr 06, 2023 4:33 pm
by fredx181

--- reserved ---


Re: DogRadio updated, v2

Posted: Fri Apr 07, 2023 12:08 pm
by stemsee

Very Nice....
I hope you don't mind I've ported to fatdog, and added vlc and ffplay, and ffmpeg for ripping.

Code: Select all

yad --icons --read-dir=$HOME/.dogradio2/data --title "Dog-Radio v2" --center --borders 3 --height="$HEIGHT" --width="$WIDTH" --window-icon "icons/audio-x-generic.png" --text "  <b>Single-click an icon to play a radio stream</b>  or  click 'Play' to resume last played if stopped" --single-click --sort-by-name --item-width 100 --buttons-layout=start --button="Add/Remove:/bin/bash -c bewerk" --button="Stop!gtk-stop:/bin/bash -c stop_stream" --button="Play!gtk-media-play:/bin/bash -c resume_play" --button="Drag N' Drop:/bin/bash -c dnd" --button="Info:/bin/bash -c info" 2> /dev/null

--single-click is undefined .... should it be --single-click="bash -c \""%s" \""


Re: DogRadio updated, v2

Posted: Fri Apr 07, 2023 2:38 pm
by fredx181
stemsee wrote: Fri Apr 07, 2023 12:08 pm

Very Nice....
I hope you don't mind I've ported to fatdog, and added vlc and ffplay, and ffmpeg for ripping.

Thanks. I don't mind that you're porting it, you make it sound easy, but I think it's a complicated task to get it work well with other player than mpv or mplayer (lots of modifying to do in dogradio script as well as in the "func" script).

Code: Select all

yad --icons --read-dir=$HOME/.dogradio2/data --title "Dog-Radio v2" --center --borders 3 --height="$HEIGHT" --width="$WIDTH" --window-icon "icons/audio-x-generic.png" --text "  <b>Single-click an icon to play a radio stream</b>  or  click 'Play' to resume last played if stopped" --single-click --sort-by-name --item-width 100 --buttons-layout=start --button="Add/Remove:/bin/bash -c bewerk" --button="Stop!gtk-stop:/bin/bash -c stop_stream" --button="Play!gtk-media-play:/bin/bash -c resume_play" --button="Drag N' Drop:/bin/bash -c dnd" --button="Info:/bin/bash -c info" 2> /dev/null

--single-click is undefined .... should it be --single-click="bash -c \""%s" \""

From what I know the --single-click should be undefined with --icons, without it you'll need to double-click an icon to run, not ??


Re: DogRadio updated, v2

Posted: Fri Apr 07, 2023 3:33 pm
by stemsee

I did the port this morning, ffplay and vlc both working fine. It was easy....just copy entries for mpv and replace mpv with ffplay and vlc in scripts. Of course I haven't tested all features, but ticker works (mostly), and streams play. More difficult will be ripping stream with ffmpeg, but mostly to keep all features of your scripts.

Yes, yad --icons ---single-click .... I was confusing it with yad --list --single-click, then I remembered %s is a .desktop file which is executable anyway!


Re: DogRadio updated, v2

Posted: Fri Apr 07, 2023 4:00 pm
by fredx181
stemsee wrote: Fri Apr 07, 2023 3:33 pm

I did the port this morning, ffplay and vlc both working fine. It was easy....just copy entries for mpv and replace mpv with ffplay and vlc in scripts. Of course I haven't tested all features, but ticker works (mostly), and streams play .....

Ok.. but.. why ? There's no problem AFAIK with availability of mpv or mplayer on most distro's (including fatdog), I think.
(but you may see it as a nice challenge perhaps ;) )


Re: DogRadio updated, v2

Posted: Fri Apr 07, 2023 7:36 pm
by stemsee

Yes, i like the challenge. I have kept mpv and mplayer options as well. I will try with mpv actually , just didn't think to try as I know you use 'which' command without redirection or specifyng 'busybox which' which makes your scripts fatdog compatible, so I just started with that and got carried away!


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 12:24 am
by stemsee

This is mplayer and mpv version, as original.
I had to make some adjustments for ticker colours to work properly. and the which command. Also in the func command changed xmessage to gxmessage, as you have the $MESSAGE definition in dogradio only. Everything works!

dogvol.png
dogvol.png (172.42 KiB) Viewed 1863 times

Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 9:59 am
by fredx181

Thanks @stemsee
I tested Dogradio now on Fatdog, what is exactly the problem with 'which' ? , couldn't reproduce it , /bin/which is symlink to busybox on my Fatdog version.
also there's /usr/bin/which , btw that is first in PATH
# which which
/usr/bin/which

The conky ticker doesn't work well with conky from Fatdog (v1.7.2, installed with gslapt), I made workaround by changing last lines of ~/.dogradio2/data/.conkyrc-radio to:
(edit: removed also the commented line just below TEXT, as it seems to cause a problem)

Code: Select all

TEXT
${color ffffff}${scroll 55 10Now Playing: ${exec cat $HOME/.dogradio2/tmp/nowplay | tr '\n' '|'                         }}

EDIT: Looked at your modification in the SFS. Perhaps the names .conkyrc-radio.new and .conkyrc-radio.old are confusing, .conkyrc-radio.new is for newest conky version (new syntax) and .conkyrc-radio.old is for older versions.
In the dogradio script it checks conky version and copies it (.old or .new) to ~/.dogradio2/data/.conkyrc-radio at first run.
EDIT2: Your modification in dogradio line 978 is wrong (is in section for new syntax):
sed -i "s/own_window_colour .*/own_window_colour '$CLR',/" $HOME/.dogradio2/data/.conkyrc-radio
should stay how it was with the '=' for new syntax :
sed -i "s/own_window_colour = .*/own_window_colour = '$CLR',/" $HOME/.dogradio2/data/.conkyrc-radio


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 11:51 am
by stemsee
fredx181 wrote: Sat Apr 08, 2023 9:59 am

Thanks @stemsee
I tested Dogradio now on Fatdog, what is exactly the problem with 'which' ? , couldn't reproduce it , /bin/which is symlink to busybox on my Fatdog version.
also there's /usr/bin/which , btw that is first in PATH
# which which
/usr/bin/which

The conky ticker doesn't work well with conky from Fatdog (v1.7.2, installed with gslapt), I made workaround by changing last lines of ~/.dogradio2/data/.conkyrc-radio to:
(edit: removed also the commented line just below TEXT, as it seems to cause a problem)

Code: Select all

TEXT
${color ffffff}${scroll 55 10Now Playing: ${exec cat $HOME/.dogradio2/tmp/nowplay | tr '\n' '|'                         }}

EDIT: Looked at your modification in the SFS. Perhaps the names .conkyrc-radio.new and .conkyrc-radio.old are confusing, .conkyrc-radio.new is for newest conky version (new syntax) and .conkyrc-radio.old is for older versions.
In the dogradio script it checks conky version and copies it (.old or .new) to ~/.dogradio2/data/.conkyrc-radio at first run.

full which is installed in fatdog, when used if a binary is not found it returns a string, it's never empty, so requires redirection 2>/dev/null or busybox which

I found that /root/.dogradio/data/conkyrc-radio needs two spaces on the last line to make it change background colour and foreground colour and not display the ${color ... code. One space before ${color .*} and one space between that and ${scroll 55 ... I should have modified both *-old and *-new configs.

It took a while to find it, but not a big deal. Works properly now. I wonder if those changes break functionality in other distros?


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 12:38 pm
by stemsee
Screenshot(1).gif
Screenshot(1).gif (85.03 KiB) Viewed 1653 times

Your app is excellent. It was coded so well that it's easy to customise or add other players.

In my personal version i added headphone volume (because there was a big gap in the gui for it! ;) ). Also i changed the Remove to multiple.

Code: Select all

RADIO=$(yad --title="Edit, remove or add Radiostation" --center --width=570 --window-icon "icons/audio-x-generic.png" --center  --text=" Choose a radiostation from the list to remove or to edit, or: \n Click 'New' to add (or play) new radiostation(s) by category or search " --list --search-column 1 --multiple --no-markup --column Name $EDIT --height 600 --width 450 --buttons-layout=spread --button="New!gtk-new:3" --button="Edit!gtk-edit:4" --button="Remove!gtk-remove:2" --button="Cancel!gtk-cancel:1")

ret=$?
[ $ret -eq 1 ] && exit
export RADIO=$RADIO
IFS="$OLDIFS"

case $ret in
1|252)
exit
;;
2)
if [ -z "$RADIO" ]; then
yad --center --borders 5 --title "Error" --text "      Nothing selected       " --button="Close!gtk-close:0"
bewerk
fi
REMOVE="$(echo $RADIO | tr '|' '\n')"
echo remove=$REMOVE
echo "$REMOVE" > /root/remove.txt
while read line
do
REMOVE=$(grep -il "Name=${line}$" $HOME/.dogradio2/data/*.desktop)
rm -f "$REMOVE"
done <<<$REMOVE

I also made it so that I can exit the gui, and leave the ticker, player and tray menu. I can also exit the tray menu and leave ticker and player running.

I also have ffmpeg -i ripping the stream,

Code: Select all

ffmpeg -i $(cat /root/.dogradio2/tmp/nowurl) /root/$URL-$(date +%d-%m-%y).mp3

Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 2:46 pm
by fredx181
stemsee wrote:

full which is installed in fatdog, when used if a binary is not found it returns a string, it's never empty, so requires redirection 2>/dev/null or busybox which

Ah, I see what you mean now, says not found in PATH, but... strange.. for me on Fatdog it still shows the proper gxmessage if something is not installed.
edit: and for example, I don't have mplayer installed, so doing [ -z $(which mplayer) ] && echo yes gives the 'not found' message from 'which' but also shows "yes".

I found that /root/.dogradio/data/conkyrc-radio needs two spaces on the last line to make it change background colour and foreground colour and not display the ${color ... code. One space before ${color .*}

Removing the commented line just below TEXT fixes that too (better I think because nothing in dogradio needs to be changed for that).
I got initially the same conky view on Fatdog as you show, the switching between one "bar" and two "bars" is not how it should be (probably has to do with old conky version), pipe it through tr if you don't want that:
viewtopic.php?p=86393#p86393 (just one "bar")

Also i changed the Remove to multiple.

That's nice improvement!


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 3:05 pm
by stemsee
fredx181 wrote: Sat Apr 08, 2023 2:46 pm

I got initially the same conky view on Fatdog as you show, the switching between one "bar" and two "bars" is not how it should be (probably has to do with old conky version), pipe it through tr if you don't want that:
viewtopic.php?p=86393#p86393 (just one "bar").

Are you kidding?? Two bars each printing in opposite directions! How cool is that!?! (rhetorical) :thumbup2:


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 3:15 pm
by fredx181
stemsee wrote: Sat Apr 08, 2023 3:05 pm
fredx181 wrote: Sat Apr 08, 2023 2:46 pm

I got initially the same conky view on Fatdog as you show, the switching between one "bar" and two "bars" is not how it should be (probably has to do with old conky version), pipe it through tr if you don't want that:
viewtopic.php?p=86393#p86393 (just one "bar").

Are you kidding?? Two bars each printing in opposite directions! How cool is that!?! (rhetorical) :thumbup2:

Mmm... ok let's call it a feature (unintended though) :D
EDIT:

Your app is excellent. It was coded so well that it's easy to customise or add other players.

Thanks anyway, but I think it's a complicated beast! (didn't change much of the code from many years ago, at that time I never heard of "compact coding" ;) )


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 3:45 pm
by stemsee

Probably should replace my headphonesVol, with ffmpeg rip function button!

Code: Select all

function ffmpegstreamripfn {
kill $(pgrep -n ffmpeg-64) $(pgrep -n ffmpeg)
URL=$(cat /root/.dogradio2/tmp/nowurl)
NAME=$(cat /root/.dogradio2/tmp/nowplay | head -1)
TITLE=$(cat /root/.dogradio2/tmp/nowplay | tail -1)
DL_DIR=$(yad --file --directory)
[ -z "$DL_DIR" ] && exit
ffmpeg -i "$URL" "$DL_DIR"/"$NAME"-"$TITLE"-$(date +%d-%m-%y).mp3 &
export FF=$!
}; export -f ffmpegstreamripfn

yad --icons --read-dir=$HOME/.dogradio2/data --title "Dog-Radio v2" --center --borders 3 --height="$HEIGHT" --width="$WIDTH" --window-icon "icons/audio-x-generic.png" --text "  <b>Single-click an icon to play a radio stream</b>  or  click 'Play' to resume last played if stopped" --single-click --sort-by-name --item-width 100 --buttons-layout=start --button="Add/Remove:/bin/bash -c bewerk" --button="Stop!gtk-stop:/bin/bash -c stop_stream" --button="Play!gtk-media-play:/bin/bash -c resume_play" --button="Drag N' Drop:/bin/bash -c dnd" --button="Info:/bin/bash -c info" --button="FFmpeg Rip:bash -c ffmpegstreamripfn" 2> /dev/null

Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 4:12 pm
by fredx181

IMO streamripper is nice because it rips to separate title-named files (if title naming is supported by the radiostation) into a directory named after the radio-station , can't see ffmpeg doing that (but correct me if I'm wrong).
EDIT: Also I'm not sure if ffmpeg can handle all stream types, e.g. playlist like m3u8 or ...


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 5:06 pm
by stemsee

streamripper is not readily available in fatdog repository!

I'm not sure ffmpeg can handle all streams, but I didn't encounter any obvious problems using it before in snapp 'yradio' function.


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 6:09 pm
by stemsee

streamripper-1.64.6 compiled @607k
i will package in the sfs.... this is my personal version for fatdog with ffplay, and ffmpeg ripper, also streamripper, compiled on fatdog 814 64bit, & packaged for original rip functionality.

Can exit maingui and still have ticker, tray and player running. Can restart main gui anytime. To kill ticker use tray menu option or exit. To close tray menu requires middle click, or 3 finger tap.

---removed---


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 6:24 pm
by stemsee

How to stop ripping from the gui or tray menu with streamripper?

With my addition of ffmpeg ripping can be stopped by pressing the 'FFmpeg Rip' button again and at the dialog for selecting a directory just cancel....in fact ffmpeg-64 or ffmpeg will be killed upon clicking the 'FFmpeg Rip' button.


Re: DogRadio updated, v2

Posted: Sat Apr 08, 2023 9:13 pm
by fredx181
stemsee wrote:

How to stop ripping from the gui or tray menu with streamripper?

The stream ripping window (yad GUI) should appear, stop ripping with the cancel button.


Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 7:56 am
by fredx181
fredx181 wrote: Sat Apr 08, 2023 9:13 pm
stemsee wrote:

How to stop ripping from the gui or tray menu with streamripper?

The stream ripping window (yad GUI) should appear, stop ripping with the cancel button.

The ripping window doesn't appear on Fatdog. The problem is that Fatdog doesn't have 'tempfile', fix by changing line 27 and 28 in /usr/local/bin/dogradiorip to:

Code: Select all

export stream=/tmp/stream$$
export list=/tmp/list$$
Untitled.png
Untitled.png (49.62 KiB) Viewed 1773 times

Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 1:28 pm
by stemsee

Yeah everything working.

I have found that I can play the radio station and get the ticker just by clicking directly on the *.desktop file in data/ directory. But I cannot get them to fire up from another app, like a yad --list with the desktop files.

I was trying to add 'TryExec=' line to the desktop file creator, with the hope of being able to play the stations from anywhere, the difference being instead of './func' there would be 'ffplay $URL'
EDIT: TryExec searches and tests for the executable in path, only.

This is just extra functionality ... beyond the purpose of dogradio V2 ..... Lots of innovation in there.

Re-enabled modified on_exit...
Download

cheers
over and out
....beam me back up Scotty!
stemsee


Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 6:04 pm
by fredx181

New .pet package (v2.4.0) attached at first post, changes / fixes (some fixes are probably just needed for Fatdog):
- Supports now removal of multiple icons from the main GUI (thanks @stemsee)
- conky ticker fix (Fatdog)
- Ripping window fix (Fatdog)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

DogRadio v2.4 package for Fatdog:

dogradio-2.4.0-x86_64.txz.tar
Remove fake .tar extension
(414.89 KiB) Downloaded 48 times

Streamripper for Fatdog (thanks @stemsee)

streamripper-1.64.4-x86_64.txz.tar
Remove fake .tar extension
(171.79 KiB) Downloaded 33 times

@stemsee I tested your setup, thought about possibly include support for ffplay as a player, but found that it's too limited compared to mpv or mplayer (e.g. streams as playlist like .pls or .m3u often fail to connect with ffplay).


Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 8:08 pm
by stemsee

Yes, ffplay stops playing eratically. Mpv is best. :thumbup:


Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 9:28 pm
by rockedge

DogRadio v2 for KLV-Airedale and Void Linux in general -> dogradio-2.4_0.noarch.xbps


Re: DogRadio updated, v2

Posted: Sun Apr 09, 2023 10:57 pm
by stemsee

FYI
I have just read up on the desktop specification, @https://specifications.freedesktop.org/ ... atest.html I learnt a lot. desktop files should contain no spaces or dashes (because of D-bus and reverse dns specs), only characters from the set [A-Za-z0-9-_] ... this might be part of the reason i can't fire them up from outside the directory.

EDIT: By adding mpv to Comment= and uncommenting URL=, I now source the desktop file and do

Code: Select all

$Comment $URL

, to play radio stations from snapp, which was my aim.

Code: Select all

[Desktop Entry]
URL=https://17633.live.streamtheworld.com:443/NOVABRASIL_SPAAC.aac
Name=Nova Brasil Fm São Paulo
Version=1.0
Comment=mpv
Exec=/bin/bash -c "export URL='https://17633.live.streamtheworld.com:443/NOVABRASIL_SPAAC.aac'; export NAME='Nova Brasil Fm São Paulo'; export ICON='icons/search.png'; ./func"
Icon=/root/.dogradio2/data/icons/search.png
StartupNotify=false
Terminal=false
Type=Application

data directory looks better when the full icon path is given in the .desktop files. So I added full path to the .desktop file templates in dogradio script.


Re: DogRadio updated, v2

Posted: Tue Apr 11, 2023 11:10 am
by stemsee

Conky ticker currently uses 5% cpu on my core i5 8 thread laptop. I think it's too much. By changing update_interval from 0.1 to 0.2 cpu goes down to 2%, spiking at 3%. Ticker works more slowly, but it'S better overall, imo. I'm researching if there are other optimisations available.


Re: DogRadio updated, v2

Posted: Tue Apr 11, 2023 1:31 pm
by fredx181
stemsee wrote:

By changing update_interval from 0.1 to 0.2 cpu goes down to 2%,

update_interval 0.1 (combined with scroll 55 1) is the "conky ticker smooth" setting enabled and yes, it's rather extreme, using much more cpu than when it's not enabled (default = not enabled).
The default is update_interval 1 (one second) (and scroll 55 10) which is using 0% cpu (from what top says).
Btw, how do you measure conky ticker cpu usage ?


Re: DogRadio updated, v2

Posted: Tue Apr 11, 2023 4:50 pm
by stemsee

I look at LXTask manager in fd tray! I didn't use another instance of conky to see it.... :lol:

My sttings now '0.3' and '46 1' @ 1% or less...with 1 image showing

Didn't you code a yad ticker before?


Re: DogRadio updated, v2

Posted: Tue Apr 11, 2023 5:40 pm
by fredx181
stemsee wrote:

Didn't you code a yad ticker before?

Not exactly like the conky "ticker" but YRadio has something like that as part of the GUI main window, every few seconds switching radio-station name and song title:
viewtopic.php?t=8273
Perhaps the conky ticker can be replaced with a yad 'ticker' like in Yradio, but then as separated window, not sure though if it would use less cpu.